@@ -11,7 +11,7 @@ execute_remote(){
1111
1212wait_for_ssh (){
1313 local service_name=" $1 "
14- retry=800
14+ retry=1800
1515 wait=1
1616 while ! execute_remote true ; do
1717 if ! systemctl is-active " $service_name " ; then
@@ -54,7 +54,7 @@ cleanup_nested_core_vm(){
5454 # remove the swtpm
5555 # TODO: we could just remove/reset the swtpm instead of removing the snap
5656 # wholesale
57- snap remove swtpm-mvo
57+ snap remove test-snapd-swtpm
5858 fi
5959
6060 # delete the image file
@@ -74,13 +74,10 @@ start_nested_core_vm_unit(){
7474 cp " ${SETUPDIR} /pc.img" " ${IMAGE_FILE} "
7575
7676 # use only 2G of RAM for qemu-nested
77- if [ " ${SPREAD_BACKEND} " = " google-nested" ]; then
78- # Do not enable SMP on GCE as it will cause boot issues. There is most likely
79- # a bug in the combination of the kernel version used in GCE images, combined with
80- # a new qemu version (v6) and OVMF
81- # TODO try again to enable more cores in the future to see if it is fixed
77+ if [ " ${SPREAD_BACKEND} " = " google-nested" ] ||
78+ [ " ${SPREAD_BACKEND} " = " google-nested-arm" ]; then
8279 PARAM_MEM=" -m 4096"
83- PARAM_SMP=" -smp 1 "
80+ PARAM_SMP=" -smp 4 "
8481 elif [ " ${SPREAD_BACKEND} " = " lxd-nested" ]; then
8582 PARAM_MEM=" -m 4096"
8683 PARAM_SMP=" -smp 2"
@@ -103,40 +100,55 @@ start_nested_core_vm_unit(){
103100 PARAM_SERIAL=" -serial file:${WORK_DIR} /serial.log"
104101 PARAM_TPM=" "
105102
106- ATTR_KVM=" "
107- if [ " $ENABLE_KVM " = " true" ]; then
108- ATTR_KVM=" ,accel=kvm"
109- # CPU can be defined just when kvm is enabled
110- PARAM_CPU=" -cpu host"
111- fi
112-
113103 # TODO: enable ms key booting for i.e. nightly edge jobs ?
114- OVMF_CODE =" "
115- OVMF_VARS =" "
104+ VMF_CODE =" "
105+ VMF_VARS =" "
116106 if [ " ${ENABLE_SECURE_BOOT:- false} " = " true" ]; then
117- OVMF_CODE =" .secboot "
107+ VMF_CODE =" .ms "
118108 fi
119109 if [ " ${ENABLE_OVMF_SNAKEOIL:- false} " = " true" ]; then
120- OVMF_VARS =" .snakeoil"
110+ VMF_VARS =" .snakeoil"
121111 fi
122112
123113 mkdir -p " ${WORK_DIR} /image/"
124- cp -f " /usr/share/OVMF/OVMF_VARS${OVMF_VARS} .fd" " ${WORK_DIR} /image/OVMF_VARS${OVMF_VARS} .fd"
125- PARAM_BIOS=" -drive file=/usr/share/OVMF/OVMF_CODE${OVMF_CODE} .fd,if=pflash,format=raw,unit=0,readonly=on -drive file=${WORK_DIR} /image/OVMF_VARS${OVMF_VARS} .fd,if=pflash,format=raw"
126- PARAM_MACHINE=" -machine q35${ATTR_KVM} -global ICH9-LPC.disable_s3=1"
114+ if os.query is-pc-amd64; then
115+ ATTR_KVM=" "
116+ if [ " $ENABLE_KVM " = " true" ]; then
117+ ATTR_KVM=" ,accel=kvm"
118+ # CPU can be defined just when kvm is enabled
119+ PARAM_CPU=" -cpu host"
120+ fi
121+ QEMU_BIN=qemu-system-x86_64
122+ PARAM_MACHINE=" -machine q35${ATTR_KVM} -global ICH9-LPC.disable_s3=1"
123+ PARAM_BIOS=" -drive file=/usr/share/OVMF/OVMF_CODE${VMF_CODE} .fd,if=pflash,format=raw,unit=0,readonly=on -drive file=${WORK_DIR} /image/OVMF_VARS${VMF_VARS} .fd,if=pflash,format=raw"
124+ TPM_DEVICE=tpm-tis
125+ cp -f " /usr/share/OVMF/OVMF_VARS${VMF_VARS} .fd" " ${WORK_DIR} /image/OVMF_VARS${VMF_VARS} .fd"
126+ elif os.query is-arm64; then
127+ # Assume arm64
128+ # Unfortunately gce does not offer kvm enabled arm64 VMs
129+ PARAM_CPU=" -cpu cortex-a57"
130+ QEMU_BIN=qemu-system-aarch64
131+ PARAM_MACHINE=" -machine virt"
132+ PARAM_BIOS=" -drive file=/usr/share/AAVMF/AAVMF_CODE${VMF_CODE} .fd,if=pflash,format=raw,unit=0,readonly=on -drive file=${WORK_DIR} /image/AAVMF_VARS${VMF_VARS} .fd,if=pflash,format=raw"
133+ TPM_DEVICE=tpm-tis-device
134+ cp -f " /usr/share/AAVMF/AAVMF_VARS${VMF_VARS} .fd" " ${WORK_DIR} /image/AAVMF_VARS${VMF_VARS} .fd"
135+ else
136+ printf " ERROR: unsupported archtecture\n"
137+ exit 1
138+ fi
127139
128- # Unfortunately the swtpm-mvo snap does not work correctly in lxd container. It's not possible
140+ # Unfortunately the test-snapd-swtpm snap does not work correctly in lxd container. It's not possible
129141 # for the socket to come up due to being containerized.
130142 if [ " ${ENABLE_TPM:- false} " = " true" ]; then
131- TPMSOCK_PATH=" /var/snap/swtpm-mvo /current/swtpm-sock"
143+ TPMSOCK_PATH=" /var/snap/test-snapd-swtpm /current/swtpm-sock"
132144 if [ " ${SPREAD_BACKEND} " = " lxd-nested" ]; then
133145 mkdir -p /tmp/qtpm
134146 swtpm socket --tpmstate dir=/tmp/qtpm --ctrl type=unixio,path=/tmp/qtpm/sock --tpm2 -d -t
135147 TPMSOCK_PATH=" /tmp/qtpm/sock"
136- elif ! snap list swtpm-mvo > /dev/null; then
137- snap install swtpm-mvo --beta
148+ elif ! snap list test-snapd-swtpm > /dev/null; then
149+ snap install test-snapd-swtpm --beta
138150 retry=60
139- while ! test -S /var/snap/swtpm-mvo /current/swtpm-sock; do
151+ while ! test -S /var/snap/test-snapd-swtpm /current/swtpm-sock; do
140152 retry=$(( retry - 1 ))
141153 if [ $retry -le 0 ]; then
142154 echo " Timed out waiting for the swtpm socket. Aborting!"
@@ -145,14 +157,15 @@ start_nested_core_vm_unit(){
145157 sleep 1
146158 done
147159 fi
148- PARAM_TPM=" -chardev socket,id=chrtpm,path=${TPMSOCK_PATH} -tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-tis ,tpmdev=tpm0"
160+ PARAM_TPM=" -chardev socket,id=chrtpm,path=${TPMSOCK_PATH} -tpmdev emulator,id=tpm0,chardev=chrtpm -device $TPM_DEVICE ,tpmdev=tpm0"
149161 fi
150162
151163 PARAM_IMAGE=" -drive file=${IMAGE_FILE} ,cache=none,format=raw,id=disk1,if=none -device virtio-blk-pci,drive=disk1,bootindex=1"
152164
153165 SVC_NAME=" nested-vm-$( systemd-escape " ${SPREAD_JOB:- unknown} " ) "
166+ # shellcheck disable=SC2086
154167 if ! systemd-run --service-type=simple --unit=" ${SVC_NAME} " -- \
155- qemu-system-x86_64 \
168+ " $QEMU_BIN " \
156169 ${PARAM_SMP} \
157170 ${PARAM_CPU} \
158171 ${PARAM_MEM} \
0 commit comments