@@ -190,20 +190,9 @@ disk_args=()
190
190
qemu_args=()
191
191
# SecureExecution extra stuff
192
192
if [[ $secure_execution -eq " 1" ]]; then
193
- ignition_pubkey=$( mktemp -p " ${tmp_builddir} " )
194
- disk_args+=(" --with-secure-execution" " --write-ignition-pubkey-to" " ${ignition_pubkey} " )
195
- if [ -z " ${hostkey} " ]; then
196
- if [ ! -f " ${genprotimgvm} " ]; then
197
- fatal " No genprotimgvm provided at ${genprotimgvm} "
198
- fi
199
- genprotimg_img=" ${PWD} /secex-genprotimg.img"
200
- qemu-img create -f raw " ${genprotimg_img} " 512M
201
- mkfs.ext4 " ${genprotimg_img} "
202
- qemu_args+=(" -drive" " if=none,id=genprotimg,format=raw,file=${genprotimg_img} " \
203
- " -device" " virtio-blk,serial=genprotimg,drive=genprotimg" )
204
- else
205
- qemu_args+=(" -drive" " if=none,id=hostkey,format=raw,file=$hostkey ,readonly=on" \
206
- " -device" " virtio-blk,serial=hostkey,drive=hostkey" )
193
+ disk_args+=(" --with-secure-execution" )
194
+ if [ ! -f " ${genprotimgvm} " ]; then
195
+ fatal " No genprotimgvm provided at ${genprotimgvm} "
207
196
fi
208
197
fi
209
198
@@ -219,10 +208,12 @@ rootfs_size_mb="$(jq '."estimate-mb".final' "$PWD/tmp/ostree-size.json")"
219
208
# the platforms require and we want a "default" disk size that has some
220
209
# free space.
221
210
nonroot_partition_sizes=513
222
- # In the Secure Execution case, we need to also include the sizes of the se and verity
223
- # partitions so that they don't "eat into" the 35% buffer (though note this is
224
- # all blown away on first boot anyway).
225
- if [[ $secure_execution -eq " 1" ]]; then
211
+ # On s390x there is one more build - Secure Execution case, which has
212
+ # different image layout. We add the sizes of the se and verity
213
+ # partitions so that they don't "eat into" the 35% buffer (though note
214
+ # this is all blown away on first boot anyway). For 's390x.mpp.yaml'
215
+ # simplicity all s390x images have same size (of secex image).
216
+ if [[ $basearch == " s390x" ]]; then
226
217
nonroot_partition_sizes=$(( nonroot_partition_sizes + 200 + 128 + 256 + 1 ))
227
218
fi
228
219
metal_image_size_mb=" $(( rootfs_size_mb + nonroot_partition_sizes )) "
@@ -274,10 +265,11 @@ platforms_json="${tmp_builddir}/platforms.json"
274
265
yaml2json " ${configdir} /platforms.yaml" " ${platforms_json} "
275
266
276
267
# Currently we only support OSBuild for qemu and metal disk images
268
+ osbuild_extra_args=()
277
269
if [ " ${image_type} " == " qemu" ] || [ " ${image_type} " == " metal" ] || [ " ${image_type} " == " metal4k" ]; then
278
- # Right now we don't have support fully fleshed out for secex on s390x
279
- if [[ $secure_execution -ne " 1" ]]; then
280
- OSBUILD_SUPPORTED=1
270
+ OSBUILD_SUPPORTED=1
271
+ if [[ $secure_execution -eq " 1" ]]; then
272
+ osbuild_extra_args+=( " --secex " " 1 " )
281
273
fi
282
274
fi
283
275
@@ -293,7 +285,7 @@ if [ "${OSBUILD_SUPPORTED:-}" != "" ] && [ "${COSA_USE_OSBUILD:-}" != "0" ]; the
293
285
runvm_with_cache_snapshot " $snapshot " -- /usr/lib/coreos-assembler/runvm-osbuild \
294
286
--config " ${image_for_disk_json} " \
295
287
--mpp " /usr/lib/coreos-assembler/osbuild-manifests/coreos.osbuild.${basearch} .mpp.yaml" \
296
- --filepath " ${path} .tmp"
288
+ --filepath " ${path} .tmp" " ${osbuild_extra_args[@]} "
297
289
else
298
290
runvm " ${qemu_args[@]} " -- \
299
291
/usr/lib/coreos-assembler/create_disk.sh \
@@ -309,9 +301,36 @@ else
309
301
fi
310
302
fi
311
303
312
- if [[ $secure_execution -eq " 1" && -z " ${hostkey} " ]]; then
304
+ if [[ $secure_execution -eq " 1" ]]; then
305
+ # SecureVM (holding Universal Key for all IBM Z Mainframes) requires scripts to execute genprotimg
306
+ se_script_dir=" /usr/lib/coreos-assembler/secex-genprotimgvm-scripts"
307
+ genprotimg_img=" ${PWD} /secex-genprotimg.img"
308
+ genprotimg_dir=$( mktemp -p " ${tmp_builddir} " -d)
309
+ cp " ${se_script_dir} /genprotimg-script.sh" " ${se_script_dir} /post-script.sh" " ${genprotimg_dir} "
310
+ # Extra kargs with dm-verity hashes
311
+ secex_kargs=" ignition.firstboot rootfs.roothash=$( < " ${PWD} " /rootfs_hash) bootfs.roothash=$( < " ${PWD} " /bootfs_hash) "
312
+ echo " ${secex_kargs} " > " ${genprotimg_dir} /parmfile"
313
+ virt-make-fs --format=raw --type=ext4 " ${genprotimg_dir} " " ${genprotimg_img} "
314
+ rm -rf " ${genprotimg_dir} "
315
+ qemu_args+=(" -drive" " if=none,id=genprotimg,format=raw,file=${genprotimg_img} " \
316
+ " -device" " virtio-blk,serial=genprotimg,drive=genprotimg" )
317
+
318
+ # GPG keys used for protecting Ignition config
319
+ tmp_gpg_home=$( mktemp -p " ${tmp_builddir} " -d)
320
+ ignition_pubkey=$( mktemp -p " ${tmp_builddir} " )
321
+ ignition_prikey=$( mktemp -p " ${tmp_builddir} " )
322
+ gpg --homedir " ${tmp_gpg_home} " --batch --passphrase ' ' --yes --quick-gen-key " Secure Execution (secex) ${build} " rsa4096 encr none
323
+ gpg --homedir " ${tmp_gpg_home} " --armor --export secex > " ${ignition_pubkey} "
324
+ gpg --homedir " ${tmp_gpg_home} " --armor --export-secret-key secex > " ${ignition_prikey} "
325
+ exec 9< " ${ignition_prikey} "
326
+ rm -rf " ${tmp_gpg_home} " " ${ignition_prikey} "
327
+ qemu_args+=(" -add-fd" " fd=9,set=3" " -drive" " if=none,id=gpgkey,format=raw,file=/dev/fdset/3,readonly=on" \
328
+ " -device" " virtio-blk,serial=gpgkey,drive=gpgkey" )
329
+
313
330
/usr/lib/coreos-assembler/secex-genprotimgvm-scripts/runvm.sh \
314
331
--genprotimgvm " ${genprotimgvm} " -- " ${qemu_args[@]} "
332
+ rm -f " ${genprotimg_img} "
333
+ exec 9>& -
315
334
fi
316
335
317
336
/usr/lib/coreos-assembler/finalize-artifact " ${path} .tmp" " ${path} "
0 commit comments