Skip to content

Commit ed1db27

Browse files
committed
simplify building the qemu-secex artifacts
We shouldn't need to pass extra parameters around for qemu-secex and should be able to just ask for that "platform" to be produced from OSBuild without specifying more. This commit removes a bunch of extra variables that get set and passed around and also refactors the osbuild manifests to have qemu-secex treated more like the other platforms that we have in its own qemu-secex.ipp.yaml file. This commit also introduces a symlink cmd-buildextend-qemu-secex that points to cmd-buildextend-metal too (in addition to the existing cmd-buildextend-secex symlink). Since `qemu-secex` is the ID that is used in the meta.json I think we should try to stick with it more.
1 parent b449ac7 commit ed1db27

File tree

6 files changed

+346
-296
lines changed

6 files changed

+346
-296
lines changed

src/cmd-buildextend-metal

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,14 @@ dn=$(dirname "$0")
55
# shellcheck source=src/cmdlib.sh
66
. "${dn}"/cmdlib.sh
77

8-
# IBM SecureExecution
9-
secure_execution=
10-
image_suffix=
11-
128
# This script is used for creating both the bare metal and the canonical VM
139
# image (qemu). `buildextend-qemu` is a symlink to `buildextend-metal`.
1410
case "$(basename "$0")" in
1511
"cmd-buildextend-metal") image_type=metal;;
1612
"cmd-buildextend-metal4k") image_type=metal4k;;
1713
"cmd-buildextend-qemu") image_type=qemu;;
18-
"cmd-buildextend-secex")
19-
secure_execution=1
20-
image_type=qemu
21-
image_suffix=-secex
22-
;;
14+
"cmd-buildextend-qemu-secex") image_type=qemu-secex;;
15+
"cmd-buildextend-secex") image_type=qemu-secex;;
2316
*) fatal "called as unexpected name $0";;
2417
esac
2518

@@ -112,9 +105,9 @@ trap 'rm -f ${build_semaphore}' EXIT
112105

113106
# check if the image already exists in the meta.json
114107
if [ -z "${force}" ]; then
115-
meta_img=$(meta_key "images.${image_type}${image_suffix}.path")
108+
meta_img=$(meta_key "images.${image_type}.path")
116109
if [ "${meta_img}" != "None" ]; then
117-
echo "${image_type}${image_suffix} image already exists:"
110+
echo "${image_type} image already exists:"
118111
echo "$meta_img"
119112
exit 0
120113
fi
@@ -139,11 +132,11 @@ import_ostree_commit_for_build "${build}"
139132
image_json=${workdir}/tmp/image.json
140133

141134
image_format=raw
142-
if [[ $image_type == qemu ]]; then
135+
if [[ "${image_type}" == "qemu" || "${image_type}" == "qemu-secex" ]]; then
143136
image_format=qcow2
144137
fi
145138

146-
imgname=${name}-${build}-${image_type}${image_suffix}.${basearch}.${image_format}
139+
imgname=${name}-${build}-${image_type}.${basearch}.${image_format}
147140
imgpath=${PWD}/${imgname}
148141

149142
# We do some extra handling of the rootfs here; it feeds into size estimation.
@@ -220,11 +213,6 @@ cat "${image_json}" "${image_dynamic_json}" | jq -s add > "${image_for_disk_json
220213
platforms_json="${tmp_builddir}/platforms.json"
221214
yaml2json "${configdir}/platforms.yaml" "${platforms_json}"
222215

223-
osbuild_extra_args=()
224-
if [[ $secure_execution -eq "1" ]]; then
225-
osbuild_extra_args+=("--secex" "1")
226-
fi
227-
228216
# In the jenkins pipelines we build the qemu image first and that operation
229217
# will do a lot of the same work required for later artifacts (metal, metal4k, etc)
230218
# so we want the cached output from that run to persist. The later artifacts get
@@ -235,9 +223,9 @@ fi
235223
runvm_with_cache_snapshot "$snapshot" -- /usr/lib/coreos-assembler/runvm-osbuild \
236224
--config "${image_for_disk_json}" \
237225
--mpp "/usr/lib/coreos-assembler/osbuild-manifests/coreos.osbuild.${basearch}.mpp.yaml" \
238-
--filepath "${imgpath}" "${osbuild_extra_args[@]}"
226+
--filepath "${imgpath}"
239227

240-
if [[ $secure_execution -eq "1" ]]; then
228+
if [[ "${image_type}" == "qemu-secex" ]]; then
241229
if [ ! -f "${genprotimgvm}" ]; then
242230
fatal "No genprotimgvm provided at ${genprotimgvm}"
243231
fi
@@ -283,7 +271,7 @@ sha256=$(sha256sum_str < "${imgpath}")
283271
cosa meta --workdir "${workdir}" --build "${build}" --dump | python3 -c "
284272
import sys, json
285273
j = json.load(sys.stdin)
286-
j['images']['${image_type}${image_suffix}'] = {
274+
j['images']['${image_type}'] = {
287275
'path': '${imgname}',
288276
'sha256': '${sha256}',
289277
'size': $(stat -c '%s' "${imgpath}")

src/cmd-buildextend-qemu-secex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./cmd-buildextend-metal

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

Lines changed: 2 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ mpp-vars:
1717
efi_system_size_mb: 127
1818
se_size_mb: 200
1919
boot_size_mb: 384
20-
root_size_mb:
21-
mpp-format-int: $rootfs_size_mb
2220
boot_verity_size_mb: 128
2321
root_verity_size_mb: 256
2422
sector_size: 512
@@ -46,8 +44,6 @@ mpp-vars:
4644
# the host buildroot is the default if nothing is specified.
4745
# We're still defining it here in an attempt to be explicit.
4846
qemu_stage_buildroot: ""
49-
# IBM Secure Execution
50-
qemu_secex: $qemu_secex
5147
mpp-define-images:
5248
- id: image
5349
sector_size:
@@ -83,40 +79,6 @@ mpp-define-images:
8379
- name: root
8480
type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
8581
partnum: 4
86-
# Secure Execution image. It MUST contain same partitions as `image` plus 3 additional
87-
- id: image_secex
88-
sector_size:
89-
mpp-format-int: "{sector_size}"
90-
size:
91-
mpp-format-string: "{metal_image_size_mb * 1024 * 1024}"
92-
table:
93-
uuid: 00000000-0000-4000-a000-000000000001
94-
label: gpt
95-
partitions:
96-
- name: se
97-
type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
98-
partnum: 1
99-
size:
100-
mpp-format-int: "{se_size_mb * 1024 * 1024 / sector_size}"
101-
- name: boot
102-
type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
103-
partnum: 3
104-
size:
105-
mpp-format-int: "{boot_size_mb * 1024 * 1024 / sector_size}"
106-
- name: root
107-
type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
108-
partnum: 4
109-
size:
110-
mpp-format-int: "{root_size_mb * 1024 * 1024 / sector_size}"
111-
- name: boothash
112-
partnum: 5
113-
size:
114-
mpp-format-int: "{boot_verity_size_mb * 1024 * 1024 / sector_size}"
115-
- name: roothash
116-
type: B325BFBE-C7BE-4AB8-8357-139E652D2F6B
117-
partnum: 6
118-
size:
119-
mpp-format-int: "{root_verity_size_mb * 1024 * 1024 / sector_size}"
12082
pipelines:
12183
# If installing from container then let's pull the container file into a pipeline
12284
- name: oci-archive
@@ -196,13 +158,6 @@ pipelines:
196158
# filesystem by OSTree (boot -> .) that makes it so that /boot paths
197159
# will always work.
198160
bootprefix: true
199-
# If on s390x with secex then mkdir for filesytem labeled `se`, where `sdboot` image gets stored
200-
- mpp-if: qemu_secex != ''
201-
then:
202-
type: org.osbuild.mkdir
203-
options:
204-
paths:
205-
- path: /se
206161
- type: org.osbuild.ignition
207162
# Deploy via OSTree repo if specified, otherwise ociarchive or container.
208163
- mpp-if: ostree_repo != ''
@@ -530,131 +485,9 @@ pipelines:
530485
source: mount
531486
deployment:
532487
default: true
533-
# IBM Secure Execution (secex) image has special layout
534-
- name: raw-secex-image
535-
build:
536-
mpp-format-string: '{buildroot}'
537-
stages:
538-
- type: org.osbuild.truncate
539-
options:
540-
filename: disk.img
541-
size:
542-
mpp-format-string: '{image_secex.size}'
543-
- type: org.osbuild.sfdisk
544-
devices:
545-
device:
546-
type: org.osbuild.loopback
547-
options:
548-
filename: disk.img
549-
options:
550-
mpp-format-json: '{image_secex.layout}'
551-
- type: org.osbuild.mkfs.ext4
552-
devices:
553-
device:
554-
type: org.osbuild.loopback
555-
options:
556-
filename: disk.img
557-
start:
558-
mpp-format-int: '{image_secex.layout[''se''].start}'
559-
size:
560-
mpp-format-int: '{image_secex.layout[''se''].size}'
561-
lock: true
562-
options:
563-
uuid: random
564-
label:
565-
mpp-format-string: '{sd_fs_label}'
566-
- type: org.osbuild.mkfs.ext4
567-
devices:
568-
device:
569-
type: org.osbuild.loopback
570-
options:
571-
filename: disk.img
572-
start:
573-
mpp-format-int: '{image_secex.layout[''boot''].start}'
574-
size:
575-
mpp-format-int: '{image_secex.layout[''boot''].size}'
576-
lock: true
577-
options:
578-
uuid:
579-
mpp-format-string: '{boot_fs_uuid}'
580-
label:
581-
mpp-format-string: '{boot_fs_label}'
582-
# Set manually the metadata_csum_seed ext4 option otherwise changing the
583-
# filesystem UUID while it's mounted doesn't work. Can remove this when
584-
# metadata_csum_seed is default in RHEL, which can be checked by looking
585-
# in /etc/mke2fs.conf.
586-
metadata_csum_seed: true
587-
- type: org.osbuild.mkfs.xfs
588-
devices:
589-
device:
590-
type: org.osbuild.loopback
591-
options:
592-
filename: disk.img
593-
start:
594-
mpp-format-int: '{image_secex.layout[''root''].start}'
595-
size:
596-
mpp-format-int: '{image_secex.layout[''root''].size}'
597-
lock: true
598-
options:
599-
uuid:
600-
mpp-format-string: '{root_fs_uuid}'
601-
label:
602-
mpp-format-string: '{root_fs_label}'
603-
- type: org.osbuild.copy
604-
inputs:
605-
tree:
606-
type: org.osbuild.tree
607-
origin: org.osbuild.pipeline
608-
references:
609-
- name:tree
610-
options:
611-
paths:
612-
- from: input://tree/
613-
to: mount://root/
614-
devices:
615-
disk:
616-
type: org.osbuild.loopback
617-
options:
618-
filename: disk.img
619-
partscan: true
620-
mounts:
621-
- name: root
622-
type: org.osbuild.xfs
623-
source: disk
624-
partition:
625-
mpp-format-int: '{image_secex.layout[''root''].partnum}'
626-
target: /
627-
- name: boot
628-
type: org.osbuild.ext4
629-
source: disk
630-
partition:
631-
mpp-format-int: '{image_secex.layout[''boot''].partnum}'
632-
target: /boot
633-
- type: org.osbuild.chattr
634-
options:
635-
items:
636-
mount://root/:
637-
immutable: true
638-
devices:
639-
disk:
640-
type: org.osbuild.loopback
641-
options:
642-
filename: disk.img
643-
partscan: true
644-
mounts:
645-
- name: root
646-
type: org.osbuild.xfs
647-
source: disk
648-
partition:
649-
mpp-format-int: '{image_secex.layout[''root''].partnum}'
650-
target: /
651-
- name: ostree.deployment
652-
type: org.osbuild.ostree.deployment
653-
options:
654-
source: mount
655-
deployment:
656-
default: true
657488
- mpp-import-pipelines:
658489
path: platform.metal.ipp.yaml
659490
- mpp-import-pipelines:
660491
path: platform.qemu.ipp.yaml
492+
- mpp-import-pipelines:
493+
path: platform.qemu-secex.ipp.yaml

0 commit comments

Comments
 (0)