Usecases/XenOnTCG
Running Xen under TCG emulation
You might want to do this is you are debugging the hypervisor which is tricky to do on a real machine. While Xen supports x86 and ARM architectures for TCG emulation we are only concerned with ARM as the x86 emulation support for virtualization is limited and only lightly tested.
Traditional Boot
The normal boot sequence is:
- Firmware/BIOS (e.g. EDK2) - which loads..
- Grub2 - which loads both Xen and the Kernel (via xen_hypervisor/xen_module) - which the boots...
- Xen - which boots and then loads the Dom0 kernel
So for this to work you want a boot using firmware (-drive pflash) with virtualisation enabled:
qemu-system-aarch64 -cpu cortex-a57 -machine type=virt,virtualization=on,gic-version=3 \ -display none -serial mon:stdio -netdev user,id=unet,hostfwd=tcp::2222-:22 \ -device virtio-net-pci,netdev=unet,id=virt-net,disable-legacy=on \ -device virtio-scsi-pci,id=virt-scsi,disable-legacy=on \ -blockdev driver=raw,node-name=hd,discard=unmap,file.driver=host_device,file.filename=/dev/zen-disk/debian-buster-arm64 \ -device scsi-hd,drive=hd,id=virt-scsi-hd \ -drive if=pflash,file=/usr/share/AAVMF/AAVMF_CODE.fd,format=raw,readonly=on \ -drive if=pflash,file=/home/alex/models/qemu-arm64-efivars,format=raw \ -smp 1 -m 4096
Direct boot
In this boot sequence example, we load the xen EFI app directly and provide the dom0 guest kernel and initrd with the guest-loader device.
qemu-system-aarch64 \ -machine type=virt,virtualization=on,acpi=off \ -cpu cortex-a57 \ -smp 8 \ -accel tcg \ -drive if=virtio,format=qcow2,file=./disk-deb13-nocloud-u1.qcow2 \ -device virtio-net-pci,netdev=unet \ -device virtio-scsi-pci \ -netdev user,id=unet,hostfwd=tcp::2222-:22 \ -serial mon:stdio \ -m 8192 \ -object memory-backend-memfd,id=mem,size=8G,share=on \ -display none \ -kernel ./xen-4.20-arm64.efi \ -append "dom0_mem=4G,max:4G loglvl=all guest_loglvl=all" \ -device guest-loader,addr=0x49000000,kernel=./vmlinuz-6.12.27-arm64,bootargs="console=hvc0 earlyprintk=xen root=PARTUUID=cfd073c4-1452-42f4-a257-c08ca114f113 ro" \ -device guest-loader,addr=0x55000000,initrd=./initrd.img-6.12.27-arm64
Note that we have to specify guest-loader twice, once for the dom0 kernel and once for the initrd.