Skip to content

Commit 6ffe317

Browse files
qemu-secex: generate fake-secure-vm.qcow2 for local build
1 parent 23732a4 commit 6ffe317

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/cmd-buildextend-metal

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ EOF
2727

2828
# Parse options
2929
genprotimgvm=/data.secex/genprotimgvm.qcow2
30+
hostkey=/srv/secex-hostkey
3031
ignition_pubkey=
3132
rc=0
3233
build=
3334
force=
34-
options=$(getopt --options h --longoptions help,force,build:,genprotimgvm: -- "$@") || rc=$?
35+
options=$(getopt --options h --longoptions help,force,build:,genprotimgvm:,hostkey: -- "$@") || rc=$?
3536
[ $rc -eq 0 ] || {
3637
print_help
3738
exit 1
@@ -54,6 +55,10 @@ while true; do
5455
genprotimgvm="$2"
5556
shift
5657
;;
58+
--hostkey)
59+
hostkey="$2"
60+
shift
61+
;;
5762
--)
5863
shift
5964
break
@@ -227,7 +232,19 @@ runvm_with_cache_snapshot "$snapshot" -- /usr/lib/coreos-assembler/runvm-osbuild
227232

228233
if [[ "${image_type}" == "qemu-secex" ]]; then
229234
if [ ! -f "${genprotimgvm}" ]; then
230-
fatal "No genprotimgvm provided at ${genprotimgvm}"
235+
if [ ! -f "${hostkey}" ]; then
236+
fatal "No hostkey and no genprotimgvm provided"
237+
fi
238+
echo "Generating genprotimgvm locally"
239+
ignition=$(mktemp -p "${tmp_builddir}")
240+
butane -p -d "$(dirname "${hostkey}")" /usr/lib/coreos-assembler/secex-genprotimgvm-scripts/genprotimg.bu -o "${ignition}"
241+
242+
genprotimgvm=/srv/fake-secure-vm.qcow2
243+
cp "/srv/builds/latest/${basearch}/${name}-${build}-qemu.${basearch}.${image_format}" "${genprotimgvm}"
244+
chmod +w "${genprotimgvm}"
245+
genvm_args=("-drive" "if=none,id=hda,file=${genprotimgvm},auto-read-only=off,cache=unsafe" \
246+
"-device" "virtio-blk,drive=hda,bootindex=1")
247+
kola qemuexec -i "${ignition}" -- "${genvm_args[@]}"
231248
fi
232249

233250
# Basic qemu args:

0 commit comments

Comments
 (0)