Skip to content

Commit d3a4551

Browse files
committedApr 2, 2024
osbuild: handle extra-kargs from image.yaml
I noticed that we were missing the `mitigations=auto,nosmt` from the kernel commandline on our FCOS built images that is defined in image-base.yaml in the FCOS configs. With OSBuild we regressed and weren't picking up these values. Adjust how extra kargs are passed from cmd-buildextend-metal into create_disk.sh and runvm-osbuild so that we can support this use case.
1 parent fe1bbf1 commit d3a4551

7 files changed

+28
-13
lines changed
 

‎src/cmd-buildextend-metal

+2-3
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,7 @@ if [ "${image_type}" == metal4k ]; then
234234
fi
235235

236236
set -x
237-
kargs="$(python3 -c 'import sys, json; args = json.load(sys.stdin)["extra-kargs"]; print(" ".join(args))' < "${image_json}")"
238-
kargs="$kargs ignition.platform.id=$ignition_platform_id"
237+
extra_kargs="$(python3 -c 'import sys, json; args = json.load(sys.stdin)["extra-kargs"]; print(" ".join(args))' < "${image_json}")"
239238

240239
qemu-img create -f ${image_format} "${path}.tmp" "${metal_image_size_mb}M"
241240

@@ -262,6 +261,7 @@ deploy-via-container: "${deploy_via_container}"
262261
osname: "${name}"
263262
ostree-container: "${ostree_container}"
264263
ostree-ref: "${ref}"
264+
extra-kargs-string: "${extra_kargs}"
265265
# Used by runvm-osbuild
266266
image-type: "${image_type}"
267267
ostree-repo: "${ostree_repo}"
@@ -298,7 +298,6 @@ else
298298
runvm "${qemu_args[@]}" -- \
299299
/usr/lib/coreos-assembler/create_disk.sh \
300300
--config "${image_for_disk_json}" \
301-
--kargs "${kargs}" \
302301
--platform "${ignition_platform_id}" \
303302
--platforms-json "${platforms_json}" \
304303
"${disk_args[@]}"

‎src/create_disk.sh

+9-8
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Fedora CoreOS style disk image from an OSTree.
2929
Options:
3030
--config: JSON-formatted image.yaml
3131
--help: show this help
32-
--kargs: kernel CLI args
3332
--platform: Ignition platform ID
3433
--platforms-json: platforms.yaml in JSON format
3534
--no-x86-bios-bootloader: don't install BIOS bootloader on x86_64
@@ -47,15 +46,13 @@ platforms_json=
4746
secure_execution=0
4847
ignition_pubkey=
4948
x86_bios_bootloader=1
50-
extrakargs=""
5149

5250
while [ $# -gt 0 ];
5351
do
5452
flag="${1}"; shift;
5553
case "${flag}" in
5654
--config) config="${1}"; shift;;
5755
--help) usage; exit;;
58-
--kargs) extrakargs="${extrakargs} ${1}"; shift;;
5956
--no-x86-bios-bootloader) x86_bios_bootloader=0;;
6057
--platform) platform="${1}"; shift;;
6158
--platforms-json) platforms_json="${1}"; shift;;
@@ -82,9 +79,6 @@ cp "${platforms_json}" /tmp/platforms.json
8279
platforms_json=/tmp/platforms.json
8380
platform_grub_cmds=$(jq -r ".${arch}.${platform}.grub_commands // [] | join(\"\\\\n\")" < "${platforms_json}")
8481
platform_kargs=$(jq -r ".${arch}.${platform}.kernel_arguments // [] | join(\" \")" < "${platforms_json}")
85-
if [ -n "${platform_kargs}" ]; then
86-
extrakargs="${extrakargs} ${platform_kargs}"
87-
fi
8882

8983
disk=$(realpath /dev/disk/by-id/virtio-target)
9084

@@ -131,6 +125,13 @@ container_imgref=$(getconfig "container-imgref" "")
131125
os_name=$(getconfig "osname")
132126
buildid=$(getconfig "buildid")
133127
imgid=$(getconfig "imgid")
128+
extra_kargs=$(getconfig "extra-kargs-string" "")
129+
130+
# populate remaining kargs
131+
extra_kargs+=" ignition.platform.id=${platform}"
132+
if [ -n "${platform_kargs}" ]; then
133+
extra_kargs+=" ${platform_kargs}"
134+
fi
134135

135136
set -x
136137

@@ -148,7 +149,7 @@ if [[ ${secure_execution} -eq 1 ]]; then
148149
SDPART=1
149150
BOOTVERITYHASHPN=5
150151
ROOTVERITYHASHPN=6
151-
extrakargs="${extrakargs} swiotlb=262144"
152+
extra_kargs="${extra_kargs} swiotlb=262144"
152153
fi
153154
# shellcheck disable=SC2031
154155
case "$arch" in
@@ -328,7 +329,7 @@ if [ "${rootfs_type}" = "ext4verity" ] && [ -z "${composefs}" ]; then
328329
fi
329330

330331
# Compute kargs
331-
allkargs="$extrakargs"
332+
allkargs="$extra_kargs"
332333
# shellcheck disable=SC2031
333334
if [ "$arch" != s390x ]; then
334335
# Note that $ignition_firstboot is interpreted by grub at boot time,

‎src/osbuild-manifests/coreos.osbuild.aarch64.mpp.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ pipelines:
137137
kernel_opts:
138138
- rw
139139
- '$ignition_firstboot'
140+
- mpp-format-string: '{extra_kargs}'
140141
inputs:
141142
images:
142143
type: org.osbuild.containers
@@ -159,6 +160,7 @@ pipelines:
159160
kernel_opts:
160161
- rw
161162
- '$ignition_firstboot'
163+
- mpp-format-string: '{extra_kargs}'
162164
inputs:
163165
images:
164166
type: org.osbuild.containers
@@ -179,6 +181,7 @@ pipelines:
179181
kernel_opts:
180182
- rw
181183
- '$ignition_firstboot'
184+
- mpp-format-string: '{extra_kargs}'
182185
inputs:
183186
commits:
184187
type: org.osbuild.ostree

‎src/osbuild-manifests/coreos.osbuild.ppc64le.mpp.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ pipelines:
131131
kernel_opts:
132132
- rw
133133
- '$ignition_firstboot'
134+
- mpp-format-string: '{extra_kargs}'
134135
inputs:
135136
images:
136137
type: org.osbuild.containers
@@ -152,6 +153,7 @@ pipelines:
152153
kernel_opts:
153154
- rw
154155
- '$ignition_firstboot'
156+
- mpp-format-string: '{extra_kargs}'
155157
inputs:
156158
images:
157159
type: org.osbuild.containers
@@ -171,6 +173,7 @@ pipelines:
171173
kernel_opts:
172174
- rw
173175
- '$ignition_firstboot'
176+
- mpp-format-string: '{extra_kargs}'
174177
inputs:
175178
commits:
176179
type: org.osbuild.ostree

‎src/osbuild-manifests/coreos.osbuild.s390x.mpp.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ pipelines:
117117
- rw
118118
## '$ignition_firstboot' only works with GRUB, not available on s390x
119119
#- '$ignition_firstboot'
120+
- mpp-format-string: '{extra_kargs}'
120121
inputs:
121122
images:
122123
type: org.osbuild.containers
@@ -138,6 +139,7 @@ pipelines:
138139
kernel_opts:
139140
- rw
140141
- '$ignition_firstboot'
142+
- mpp-format-string: '{extra_kargs}'
141143
inputs:
142144
images:
143145
type: org.osbuild.containers
@@ -158,6 +160,7 @@ pipelines:
158160
- rw
159161
## '$ignition_firstboot' only works with GRUB, not available on s390x
160162
#- '$ignition_firstboot'
163+
- mpp-format-string: '{extra_kargs}'
161164
inputs:
162165
commits:
163166
type: org.osbuild.ostree

‎src/osbuild-manifests/coreos.osbuild.x86_64.mpp.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mpp-vars:
66
container_imgref: $container_imgref
77
container_repo: $container_repo
88
container_tag: $container_tag
9+
extra_kargs: $extra_kargs
910
metal_image_size_mb: $metal_image_size_mb
1011
cloud_image_size_mb: $cloud_image_size_mb
1112
bios_boot_size_mb: 1
@@ -137,6 +138,7 @@ pipelines:
137138
kernel_opts:
138139
- rw
139140
- '$ignition_firstboot'
141+
- mpp-format-string: '{extra_kargs}'
140142
inputs:
141143
images:
142144
type: org.osbuild.containers
@@ -159,6 +161,7 @@ pipelines:
159161
kernel_opts:
160162
- rw
161163
- '$ignition_firstboot'
164+
- mpp-format-string: '{extra_kargs}'
162165
inputs:
163166
images:
164167
type: org.osbuild.containers
@@ -179,6 +182,7 @@ pipelines:
179182
kernel_opts:
180183
- rw
181184
- '$ignition_firstboot'
185+
- mpp-format-string: '{extra_kargs}'
182186
inputs:
183187
commits:
184188
type: org.osbuild.ostree

‎src/runvm-osbuild

+4-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ cloud_image_size_mb=$(getconfig "cloud-image-size")
5656
container_imgref=$(getconfig "container-imgref")
5757
container_repo=$(getconfig_def "container-repo" "")
5858
container_tag=$(getconfig_def "container-tag" "")
59+
extra_kargs=$(getconfig "extra-kargs-string" "")
5960
# If we are deploying via container let's go ahead and pull
6061
# the oci archive path from the config
6162
ostree_container=""
@@ -84,8 +85,9 @@ osbuild-mpp \
8485
-D ociarchive=\""${ostree_container}"\" \
8586
-D osname=\""${osname}"\" \
8687
-D container_imgref=\""${container_imgref}"\" \
87-
-D container_repo=\""${container_repo}"\" \
88-
-D container_tag=\""${container_tag}"\" \
88+
-D container_repo=\""${container_repo}"\" \
89+
-D container_tag=\""${container_tag}"\" \
90+
-D extra_kargs=\""${extra_kargs}"\" \
8991
-D metal_image_size_mb="${metal_image_size_mb}" \
9092
-D cloud_image_size_mb="${cloud_image_size_mb}" \
9193
"${mppyaml}" "${processed_json}"

0 commit comments

Comments
 (0)
Please sign in to comment.