Booting aarch64 generic in libvirt/qemu doesn't work

This is for ARMv8 based devices

Booting aarch64 generic in libvirt/qemu doesn't work

Postby XenGi » Sun Mar 15, 2020 1:42 pm

Ahoi,

I'm trying to setup up a gitlab-runner as a VM on a server. I'm using libvirtd on the server and ibvirt manager on my notebook. So I created the VM via GUI.

Here's what I did so far to create the VM:

$this->bbcode_second_pass_code('', '
# load nbd module
modprobe nbd max_part=8
# connect qcow2 image
qemu-nbd --connect=/dev/nbd0 /var/lib/libvirt/images/gitlab-runner-aarch64.qcow2
# partition the 16GB image with:
# p1 vfat LABEL=ESP 256M
# p2 swap LABEL=SWAP 1G
# p3 ext4 LABEL=ALARM REST
cfdisk /dev/nbd0
# format partitions
mkdosfs -F32 -n ESP /dev/nbd0p1
mkswap -L SWAP /dev/nbd0p2
mkfs.ext4 -L ALARM -O metadata_csum /dev/nbd0p3
# download alarm rootfs
wget http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz
# mount everything
mount /dev/nbd0p3 /mnt/
mkdir /mnt/boot
mount /dev/nbd0p1 /mnt/boot/
# unpack alarm rootfs
bsdtar -xpf ArchLinuxARM-aarch64-latest.tar.gz -C /mnt/
# create startup.nsh
echo "Image root=/dev/vda3 initrd=initramfs-linux.img" > /mnt/boot/startup.nsh
# unmount everything
umount -R /mnt
# disconnect image
qemu-nbd --disconnect /dev/nbd0
# remove nbd module
rmmod nbd
')

When I boot the VM lot's of services fail and it doesn't recognise my keyboard inputs. I added a USB keyboard and SPICE display to the VM. Now I don't see the boot process but the display comes back on the login screen and I can type things. Sadly it doesn't accept the default accounts.

Here's the qemu call that I snatched from ps output:

$this->bbcode_second_pass_code('', '
/usr/bin/qemu-system-aarch64 \
-name guest=gitlab-runner-aarch64,debug-threads=on \
-S \
-object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-6-gitlab-runner-aarch6/master-key.aes \
-blockdev {"driver":"file","filename":"/usr/share/qemu/edk2-aarch64-code.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"} \
-blockdev {"node-name":"libvirt-pflash0-format","read-only":true,"driver":"raw","file":"libvirt-pflash0-storage"} \
-blockdev {"driver":"file","filename":"/var/lib/libvirt/qemu/nvram/gitlab-runner-aarch64_VARS.fd","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"} \
-blockdev {"node-name":"libvirt-pflash1-format","read-only":false,"driver":"raw","file":"libvirt-pflash1-storage"} \
-machine virt-4.2,accel=tcg,usb=off,dump-guest-core=off,gic-version=2,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format \
-cpu cortex-a57 \
-m 1024 \
-overcommit mem-lock=off \
-smp 2,sockets=2,cores=1,threads=1 \
-uuid afdb37bc-66b9-4b9c-956a-5c95158eba76 \
-no-user-config \
-nodefaults \
-chardev socket,id=charmonitor,fd=35,server,nowait \
-mon chardev=charmonitor,id=monitor,mode=control \
-rtc base=utc \
-no-shutdown \
-boot menu=on,strict=on \
-device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \
-device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \
-device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \
-device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \
-device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \
-device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \
-device pcie-root-port,port=0xe,chassis=7,id=pci.7,bus=pcie.0,addr=0x1.0x6 \
-device qemu-xhci,p2=15,p3=15,id=usb,bus=pci.2,addr=0x0 \
-device virtio-serial-pci,id=virtio-serial0,bus=pci.3,addr=0x0 \
-blockdev {"driver":"file","filename":"/var/lib/libvirt/images/kvmpool/gitlab-runner-aarch64.qcow2","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"} \
-blockdev {"node-name":"libvirt-1-format","read-only":false,"driver":"qcow2","file":"libvirt-1-storage","backing":null} \
-device virtio-blk-pci,scsi=off,bus=pci.4,addr=0x0,drive=libvirt-1-format,id=virtio-disk0,bootindex=1 \
-netdev tap,fd=37,id=hostnet0 \
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:fa:67:81,bus=pci.1,addr=0x0 \
-chardev pty,id=charserial0 \
-serial chardev:charserial0 \
-chardev socket,id=charchannel0,fd=38,server,nowait \
-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0 \
-chardev spicevmc,id=charchannel1,name=vdagent \
-device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,id=channel1,name=com.redhat.spice.0 \
-device usb-tablet,id=input0,bus=usb.0,port=1 \
-spice port=5901,addr=127.0.0.1,disable-ticketing,seamless-migration=on \
-device virtio-gpu-pci,id=video0,max_outputs=1,bus=pci.7,addr=0x0 \
-device virtio-balloon-pci,id=balloon0,bus=pci.5,addr=0x0 \
-object rng-random,id=objrng0,filename=/dev/urandom \
-device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.6,addr=0x0 \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
-msg timestamp=on
')

Does anyone have any idea what I'm doing wrong? Is there some official guide on how to do this?
XenGi
 
Posts: 5
Joined: Fri Jan 10, 2020 4:58 pm

Return to ARMv8 Devices

Who is online

Users browsing this forum: No registered users and 8 guests