diff --git a/mantle/cmd/kola/switchkernel.go b/mantle/cmd/kola/switchkernel.go
index eabe3b2429..77f0087dd1 100644
--- a/mantle/cmd/kola/switchkernel.go
+++ b/mantle/cmd/kola/switchkernel.go
@@ -60,7 +60,7 @@ var (
if [[ $FROM_KERNEL == "default" && $TO_KERNEL == "rt-kernel" ]]; then
# Switch from default to RT Kernel
- # https://github.com/openshift/machine-config-operator/blob/master/pkg/daemon/update.go#L711
+ # https://github.com/openshift/machine-config-operator/blob/e246be62e7839a086bc4494203472349c406dcae/pkg/daemon/update.go#L711
RT_KERNEL_REPO=$3
if [[ -z $(ls ${RT_KERNEL_REPO}) ]]; then
echo "No kernel-rt package available in the repo: ${RT_KERNEL_REPO}"
diff --git a/src/cmd-buildextend-metal b/src/cmd-buildextend-metal
index 87f6dac3cd..a4767c4713 100755
--- a/src/cmd-buildextend-metal
+++ b/src/cmd-buildextend-metal
@@ -182,15 +182,7 @@ fi
set -x
kargs="$(python3 -c 'import sys, json; args = json.load(sys.stdin)["extra-kargs"]; print(" ".join(args))' < "${image_json}")"
-tty="console=tty0 console=${DEFAULT_TERMINAL},115200n8"
-# On each s390x hypervisor, a tty would be automatically detected by the kernel
-# and systemd, there is no need to specify one. However, we keep DEFAULT_TERMINAL
-# as ttysclp0, which is helpful for building/testing with KVM+virtio (cmd-run).
-# For aarch64, ttyAMA0 is used as the default console
-case "$basearch" in
- "aarch64"|"s390x") tty= ;;
-esac
-kargs="$kargs $tty ignition.platform.id=$ignition_platform_id"
+kargs="$kargs ignition.platform.id=$ignition_platform_id"
qemu-img create -f ${image_format} "${path}.tmp" "${image_size}"
@@ -217,10 +209,17 @@ cat >image-dynamic.json << EOF
}
EOF
cat "${image_json}" image-dynamic.json | jq -s add > image-for-disk.json
+platforms_json=
+if [ -e "${configdir}/platforms.yaml" ]; then
+ platforms_json="${workdir}/tmp/platforms.json"
+ yaml2json "${configdir}/platforms.yaml" "${platforms_json}"
+fi
runvm "${target_drive[@]}" -- \
/usr/lib/coreos-assembler/create_disk.sh \
--config "$(pwd)"/image-for-disk.json \
--kargs "\"${kargs}\"" \
+ --platform "${ignition_platform_id}" \
+ ${platforms_json:+--platforms-json "${platforms_json}"} \
"${disk_args[@]}"
/usr/lib/coreos-assembler/finalize-artifact "${path}.tmp" "${path}"
diff --git a/src/cosalib/qemuvariants.py b/src/cosalib/qemuvariants.py
index c683bf66c3..4dec7906ea 100644
--- a/src/cosalib/qemuvariants.py
+++ b/src/cosalib/qemuvariants.py
@@ -221,7 +221,7 @@ def image_meta(self):
return None
def set_platform(self):
- run_verbose(['/usr/lib/coreos-assembler/gf-platformid',
+ run_verbose(['/usr/lib/coreos-assembler/gf-set-platform',
self.image_qemu, self.tmp_image, self.platform])
def mutate_image(self):
diff --git a/src/create_disk.sh b/src/create_disk.sh
index 47af408b83..555d3f71f1 100755
--- a/src/create_disk.sh
+++ b/src/create_disk.sh
@@ -29,6 +29,8 @@ Options:
--disk: disk device to use
--help: show this help
--kargs: kernel CLI args
+ --platform: Ignition platform ID
+ --platforms-json: platforms.yaml in JSON format
--no-x86-bios-bootloader: don't install BIOS bootloader on x86_64
You probably don't want to run this script by hand. This script is
@@ -38,6 +40,8 @@ EOC
config=
disk=
+platform=metal
+platforms_json=
x86_bios_bootloader=1
extrakargs=""
@@ -50,6 +54,8 @@ do
--help) usage; exit;;
--kargs) extrakargs="${extrakargs} ${1}"; shift;;
--no-x86-bios-bootloader) x86_bios_bootloader=0;;
+ --platform) platform="${1}"; shift;;
+ --platforms-json) platforms_json="${1}"; shift;;
*) echo "${flag} is not understood."; usage; exit 10;;
esac;
done
@@ -62,6 +68,27 @@ udevtrig() {
export PATH=$PATH:/sbin:/usr/sbin
arch="$(uname -m)"
+if [ -n "$platforms_json" ]; then
+ platform_grub_cmds=$(jq -r ".${arch}.${platform}.grub_commands // [] | join(\"\\\\n\")" < "${platforms_json}")
+ platform_kargs=$(jq -r ".${arch}.${platform}.kernel_arguments // [] | join(\" \")" < "${platforms_json}")
+else
+ # Add legacy kargs and console settings
+ platform_grub_cmds='serial --speed=115200\nterminal_input serial console\nterminal_output serial console'
+ DEFAULT_TERMINAL=$(. $(dirname "$0")/cmdlib.sh; echo $DEFAULT_TERMINAL)
+ # On each s390x hypervisor, a tty would be automatically detected by the
+ # kernel and systemd, there is no need to specify one. However, we keep
+ # DEFAULT_TERMINAL as ttysclp0, which is helpful for building/testing
+ # with KVM+virtio (cmd-run). For aarch64, ttyAMA0 is used as the
+ # default console
+ case "$arch" in
+ "aarch64"|"s390x") platform_kargs= ;;
+ *) platform_kargs="console=tty0 console=${DEFAULT_TERMINAL},115200n8" ;;
+ esac
+fi
+if [ -n "${platform_kargs}" ]; then
+ extrakargs="${extrakargs} ${platform_kargs}"
+fi
+
disk=$(realpath /dev/disk/by-id/virtio-target)
config="${config:?--config must be defined}"
@@ -364,7 +391,16 @@ install_grub_cfg() {
# 0700 to match the RPM permissions which I think are mainly in case someone has
# manually set a grub password
mkdir -p -m 0700 $rootfs/boot/grub2
- printf "%s" "$grub_script" > $rootfs/boot/grub2/grub.cfg
+ printf "%s\n" "$grub_script" | \
+ sed -E 's@(^# CONSOLE-SETTINGS-START$)@\1'"${platform_grub_cmds:+\\n${platform_grub_cmds}}"'@' \
+ > $rootfs/boot/grub2/grub.cfg
+ if [ -n "$platforms_json" ]; then
+ # Copy platforms table if it's non-empty for this arch
+ if jq -e ".$arch" < "$platforms_json" > /dev/null; then
+ mkdir -p "$rootfs/boot/coreos"
+ jq ".$arch" < "$platforms_json" > "$rootfs/boot/coreos/platforms.json"
+ fi
+ fi
}
# Other arch-specific bootloader changes
@@ -406,7 +442,7 @@ s390x)
# this is only a temporary solution until we are able to do firstboot check at bootloader
# stage on s390x, either through zipl->grub2-emu or zipl standalone.
# See https://github.com/coreos/ignition-dracut/issues/84
- # A similar hack is present in https://github.com/coreos/coreos-assembler/blob/main/src/gf-platformid#L55
+ # There's a similar hack in gf-set-platform
echo "$(grep options $blsfile | cut -d' ' -f2-) ignition.firstboot" > $tmpfile
# ideally we want to invoke zipl with bls and zipl.conf but we might need
diff --git a/src/gf-platformid b/src/gf-set-platform
similarity index 64%
rename from src/gf-platformid
rename to src/gf-set-platform
index 429ca1beb5..adf447732e 100755
--- a/src/gf-platformid
+++ b/src/gf-set-platform
@@ -7,8 +7,8 @@ dn=$(dirname "$0")
# shellcheck source=src/libguestfish.sh
. "${dn}"/libguestfish.sh
-# Usage: gf-platformid