The first QEMU command you posted above should work, and does for me. It may of been an issue with the image you created ?
You should be able to eliminate an image issue by using testing with the Canonical provided image. Also, note that you don’t have to
sudo that command, and shouldn’t write to to the VARS file in the system installed location in any case [ you are better of keeping that file pristine ].
You should be able to do the following:
# Grab the reference image
# keep the downloaded image for futer tests from scratch
xzcat ubuntu-core-22-arm64.img.xz > ubuntu-core-22-arm64.img
# Copy the VARS file locally for use with this particaulr VM instance
cp /usr/share/AAVMF/AAVMF_VARS.fd .
# run it
-smp 2 \
-m 2048 \
-machine virt \
-cpu cortex-a57 \
-net nic,model=virtio \
-drive file=/usr/share/AAVMF/AAVMF_CODE.fd,if=pflash,format=raw,unit=0,readonly=on \
-drive file=AAVMF_VARS.fd,if=pflash,format=raw,unit=1 \
-drive "file=ubuntu-core-22-arm64.img",if=none,format=raw,id=disk1 \
-device virtio-blk-pci,drive=disk1,bootindex=1 \
-serial mon:stdio \
One more thing to note. Performance without KVM is pretty bad, so you can expect the UC bootstrap process to take a while, it will vary depending on hardware but could easily could be 20 mins plus.
If you have ARM hardware available, running on that with the following will help speed things up a lot:
qemu-system-aarch64 -machine virt,accel=kvm -cpu host