Xen ARM with Virtualization Extensions/qemu-system-aarch64: Difference between revisions
No edit summary |
No edit summary |
||
Line 7: | Line 7: | ||
== Build QEMU == |
== Build QEMU == |
||
QEMU v2.11 can run Xen out of the box. Build QEMU like this: |
|||
QEMU v2.10 requires a few fixes to be able to run Xen on ARM in a nested fashion. QEMU v2.11 will likely work out of the box. For now, the simplest thing to do is to apply the appended patch. The following steps apply the patch and build QEMU: |
|||
$ git clone git://git.qemu.org/qemu.git |
|||
If you are running QEMU <= v2.10, save [https://wiki.xenproject.org/wiki/Qemu-aarch64.patch this patch] to a text file, then: |
|||
$ patch -p1 < /path/to/Qemu-aarch64.patch |
|||
Finally build QEMU: |
|||
$ ./configure --target-list=aarch64-softmmu |
$ ./configure --target-list=aarch64-softmmu |
||
Line 42: | Line 34: | ||
Let's write a config file for it: |
Let's write a config file for it: |
||
$ vi /boot/xen.cfg |
$ vi /boot/efi/xen.cfg |
||
Let's use the following config: |
Let's use the following config: |
||
Line 50: | Line 42: | ||
dtb=virt-gicv3.dtb |
dtb=virt-gicv3.dtb |
||
Now we need the device tree binary. QEMU can generate one for you with the following command: |
Now we need the device tree binary, "virt-gicv3.dtb". QEMU can generate one for you with the following command: |
||
$ /path/to/qemu.git/aarch64-softmmu/qemu-system-aarch64 \ |
$ /path/to/qemu.git/aarch64-softmmu/qemu-system-aarch64 \ |
Revision as of 17:52, 5 February 2018
QEMU AArch64 Emulator
QEMU is an Open Source GPLv2 software emulator. It can emulate a large range of machines of different architectures, including Cortex A57s based platforms.
The following steps help you setup QEMU to emulate an ARM64 machine and run Xen inside it.
Build QEMU
QEMU v2.11 can run Xen out of the box. Build QEMU like this:
$ ./configure --target-list=aarch64-softmmu $ make
Install Xen
QEMU works well with UEFI firmware for the emulated machine. To get the system working, download an Aarch64 UEFI ready distro image, like xenial-server-cloudimg-arm64-uefi1.img. Then, clone Linux and build the kernel using the defconfig for arm64 (make defconfig && make Image.gz).
Run QEMU the first time, booting Linux directly (replace the MAC_ADDRESS and the paths). The following command uses user-networking and forwards port 2222 from the host to port 22 inside the virtual machine:
$ /path/to/qemu.git/aarch64-softmmu/qemu-system-aarch64 \ -machine virt,gic_version=3 -machine virtualization=true \ -cpu cortex-a57 -machine type=virt -nographic \ -smp 4 -m 4000 \ -kernel /path/to/linux.git/arch/arm64/boot/Image.gz --append "console=ttyAMA0 root=/dev/vda1" \ -netdev user,id=hostnet0,hostfwd=tcp::2222-:22 -device virtio-net-device,netdev=hostnet0,mac=MAC_ADDRESS \ -drive if=none,file=/path/to/xenial-server-cloudimg-arm64-uefi1.img,id=hd0 -device virtio-blk-device,drive=hd0
Follow Xen_ARM_with_Virtualization_Extensions#Building_Xen_on_ARM to build Xen on ARM. Then, copy the Xen on ARM efi binary and the Linux kernel to the image:
$ scp -P2222 /path/to/linux.git/arch/arm64/boot/Image.gz root@127.0.0.1:/boot/efi/kernel $ scp -P2222 /path/to/xen.git/xen/xen.efi root@127.0.0.1:/boot/efi
Let's write a config file for it:
$ vi /boot/efi/xen.cfg
Let's use the following config:
options=console=dtuart noreboot dom0_mem=512M kernel=kernel root=/dev/vda1 init=/bin/sh rw console=hvc0 dtb=virt-gicv3.dtb
Now we need the device tree binary, "virt-gicv3.dtb". QEMU can generate one for you with the following command:
$ /path/to/qemu.git/aarch64-softmmu/qemu-system-aarch64 \ -machine virt,gic_version=3 \ -machine virtualization=true \ -cpu cortex-a57 -machine type=virt \ -smp 4 -m 4096 -display none \ -machine dumpdtb=virt-gicv3.dtb.dtb $ scp -P2222 virt-gicv3.dtb.dtb root@127.0.0.1:/boot/efi
We have written everything we need to the disk image. Let's poweroff the virtual machine and proceed to download the UEFI firmware binary from Linaro: [1].
Run QEMU
The following command create a new emulated AArch64 machine with 4 Cortex A57s, 4G of RAM, booting from EFI. The command below uses user networking in QEMU, other network configuration (bridging) are possible. Please change MAC_ADDRESS for the emulated machine and path to the guest image.
$ /path/to/qemu.git/aarch64-softmmu/qemu-system-aarch64 \ -machine virt,gic_version=3 \ -machine virtualization=true \ -cpu cortex-a57 -machine type=virt \ -smp 4 -m 4096 -display none \ -serial mon:stdio \ -bios /path/to/QEMU_EFI.bin \ -netdev user,id=hostnet0,hostfwd=tcp::2222-:22 -device virtio-net-device,netdev=hostnet0,mac=MAC_ADDRESS \ -drive if=none,file=/path/to/xenial-server-cloudimg-arm64-uefi1.img,id=hd0 -device virtio-blk-device,drive=hd0