QEMU

Differences between revisions 8 and 12 (spanning 4 versions)
Revision 8 as of 2015-04-20 17:31:44
Size: 2199
Editor: dannf
Comment: note fixed cloud images
Revision 12 as of 2016-01-08 22:27:08
Size: 2049
Editor: dannf
Comment:
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
 1. Install QEMU  1. Install QEMU and the EFI image for QEMU:
Line 9: Line 9:
 $ sudo apt-get install qemu-system-aarch64  $ sudo apt-get install qemu-system-arm qemu-efi
Line 11: Line 11:
 1. Get a tianocore UEFI image. Eventually Ubuntu should provide this in a package called qemu-efi (there's one currently in Debian's NEW queue), but for now you can download [[http://releases.linaro.org/15.01/components/kernel/uefi-linaro/release/qemu64-intelbds/QEMU_EFI.fd|one from Linaro]].
Line 15: Line 14:
 $ dd if=QEMU_EFI.fd of=flash0.img conv=notrunc  $ dd if=/usr/share/qemu-efi/QEMU_EFI.fd of=flash0.img conv=notrunc
Line 18: Line 17:
 1. Now you should be able to boot/ into a -arm64-uefi1.img type [[http://cloud-images.ubuntu.com|cloud image]]. (Note: as of 2015-04-20, only vivid images are fully functional. Canonical is working on fixing this for trusty and utopic).  1. Now you should be able to boot/ into a -arm64-uefi1.img type [[http://cloud-images.ubuntu.com|cloud image]].
Line 23: Line 22:
  '''Note: For GICv3 systems, such as Cavium ThunderX, you must use QEMU from Ubuntu 16.04 or newer, and pass "-M virt,gic_version=3". Additionally, you must use a 15.10 (wily) or newer cloud image for guests.'''
Line 28: Line 28:

Ubuntu/arm64 can run inside the QEMU emulator. You can either do this fully emulated (e.g. on an x86 host) or, accelerated w/ KVM if you have an arm64 host. This page describes how to do both.

I've chosen to describe a UEFI-based system here so I can make use of the kernel on the guest's disk image. It is possible to boot directly into Linux instead.

Note: this requires Ubuntu 15.04 or greater

Getting the bits

  1. Install QEMU and the EFI image for QEMU:
     $ sudo apt-get install qemu-system-arm qemu-efi
  2. Now you'll need to create pflash volumes for UEFI. Two volumes are required, one static one for the UEFI firmware, and another dynamic one to store variables. Both need to be exactly 64M in size.
     $ dd if=/dev/zero of=flash0.img bs=1M count=64
     $ dd if=/usr/share/qemu-efi/QEMU_EFI.fd of=flash0.img conv=notrunc
     $ dd if=/dev/zero of=flash1.img bs=1M count=64
  3. Now you should be able to boot/ into a -arm64-uefi1.img type cloud image.

    1. For accelerated VMs (arm64 host w/ KVM support)
        $ sudo qemu-system-aarch64 -enable-kvm -m 1024 -cpu host -M virt -nographic -pflash flash0.img -pflash flash1.img -drive if=none,file=vivid-server-cloudimg-arm64-uefi1.img,id=hd0 -device virtio-blk-device,drive=hd0 -netdev type=tap,id=net0 -device virtio-net-device,netdev=net0,mac=$randmac

      Note: For GICv3 systems, such as Cavium ThunderX, you must use QEMU from Ubuntu 16.04 or newer, and pass "-M virt,gic_version=3". Additionally, you must use a 15.10 (wily) or newer cloud image for guests.

    2. For emulated VMs (e.g. x86 host)
        $ sudo qemu-system-aarch64 -m 1024 -cpu cortex-a57 -M virt -nographic -pflash flash0.img -pflash flash1.img -drive if=none,file=vivid-server-cloudimg-arm64-uefi1.img,id=hd0 -device virtio-blk-device,drive=hd0 -netdev type=tap,id=net0 -device virtio-net-device,netdev=net0,mac=$randmac

References

ARM64/QEMU (last edited 2016-01-08 22:27:08 by dannf)