35
35
36
36
# Parse options
37
37
hostkey=src/config/secex-hostkey
38
+ genprotimgvm=
38
39
rc=0
39
40
build=
40
41
force=
41
- options=$( getopt --options h --longoptions help,force,build:,hostkey: -- " $@ " ) || rc=$?
42
+ options=$( getopt --options h --longoptions help,force,build:,hostkey:,genprotimgvm: -- " $@ " ) || rc=$?
42
43
[ $rc -eq 0 ] || {
43
44
print_help
44
45
exit 1
@@ -58,8 +59,13 @@ while true; do
58
59
shift
59
60
;;
60
61
--hostkey)
61
- hostkey=" $2 "
62
- shift ;;
62
+ hostkey=$( realpath " $2 " )
63
+ shift
64
+ ;;
65
+ --genprotimgvm)
66
+ genprotimgvm=" $2 "
67
+ shift
68
+ ;;
63
69
--)
64
70
shift
65
71
break
88
94
if [[ " $basearch " != " s390x" && $image_type == dasd ]]; then
89
95
fatal " $basearch is not supported for building dasd images"
90
96
fi
91
- disk_args=()
92
- # SecureExecution extra stuff
93
- secex_hostkey_drive=()
94
- if [[ $secure_execution -eq " 1" ]]; then
95
- hostkey=$( realpath " $hostkey " )
96
- disk_args+=(" --with-secure-execution" )
97
- secex_hostkey_drive=(" -drive" " if=none,id=hostkey,format=raw,file=$hostkey ,readonly=on" \
98
- " -device" " virtio-blk,serial=hostkey,drive=hostkey" )
99
- fi
100
97
101
98
# shellcheck disable=SC2031
102
99
export LIBGUESTFS_BACKEND=direct
@@ -185,6 +182,23 @@ if [ "${rootfs_type}" = "ext4verity" ]; then
185
182
BLKSIZE=" $( getconf PAGE_SIZE) "
186
183
fi
187
184
185
+ disk_args=()
186
+ qemu_args=()
187
+ # SecureExecution extra stuff
188
+ if [[ $secure_execution -eq " 1" ]]; then
189
+ disk_args+=(" --with-secure-execution" )
190
+ if [ -z " ${genprotimgvm} " ]; then
191
+ qemu_args+=(" -drive" " if=none,id=hostkey,format=raw,file=$hostkey ,readonly=on" \
192
+ " -device" " virtio-blk,serial=hostkey,drive=hostkey" )
193
+ else
194
+ genprotimg_img=" ${PWD} /secex-genprotimg.img"
195
+ qemu-img create -f raw " ${genprotimg_img} " 512M
196
+ mkfs.ext4 " ${genprotimg_img} "
197
+ qemu_args+=(" -drive" " if=none,id=genprotimg,format=raw,file=${genprotimg_img} " \
198
+ " -device" " virtio-blk,serial=genprotimg,drive=genprotimg" )
199
+ fi
200
+ fi
201
+
188
202
echo " Estimating disk size..."
189
203
# The additional 35% here is obviously a hack, but we can't easily completely fill the filesystem,
190
204
# and doing so has apparently negative performance implications.
@@ -223,7 +237,7 @@ extra_target_device_opts=""
223
237
if [[ $image_type == dasd || $image_type == metal4k ]]; then
224
238
extra_target_device_opts=" ,physical_block_size=4096,logical_block_size=4096"
225
239
fi
226
- target_drive =(" -drive" " if=none,id=target,format=${image_format} ,file=${path} .tmp,cache=unsafe" \
240
+ qemu_args+ =(" -drive" " if=none,id=target,format=${image_format} ,file=${path} .tmp,cache=unsafe" \
227
241
" -device" " virtio-blk,serial=target,drive=target${extra_target_device_opts} " )
228
242
229
243
# Generate the JSON describing the disk we want to build
@@ -246,13 +260,19 @@ if [ -e "${configdir}/platforms.yaml" ]; then
246
260
platforms_json=" ${workdir} /tmp/platforms.json"
247
261
yaml2json " ${configdir} /platforms.yaml" " ${platforms_json} "
248
262
fi
249
- runvm " ${target_drive[@]} " " ${secex_hostkey_drive [@]}" -- \
263
+ runvm " ${qemu_args [@]} " -- \
250
264
/usr/lib/coreos-assembler/create_disk.sh \
251
265
--config " $( pwd) " /image-for-disk.json \
252
266
--kargs " \" ${kargs} \" " \
253
267
--platform " ${ignition_platform_id} " \
254
268
${platforms_json: +--platforms-json " ${platforms_json} " } \
255
269
" ${disk_args[@]} "
270
+
271
+ if [[ $secure_execution -eq " 1" && -n " ${genprotimgvm} " ]]; then
272
+ /usr/lib/coreos-assembler/secex-genprotimgvm-scripts/runvm.sh \
273
+ --genprotimgvm " ${genprotimgvm} " -- " ${qemu_args[@]} "
274
+ fi
275
+
256
276
/usr/lib/coreos-assembler/finalize-artifact " ${path} .tmp" " ${path} "
257
277
258
278
sha256=$( sha256sum_str < " ${img} " )
0 commit comments