title: QEMU: how to use the virt board
body: <p>I'm trying to play with QEMU, especially with the virt board and device trees, but there isn't much documentation about it.
  I managed to emulate a vexpress a9 board and install archlinux on it, mainly thanks to this <a href="https://medicineyeh.wordpress.com/2016/03/29/buildup-your-arm-image-for-qemu/" rel="nofollow noreferrer">link</a>, with the following commands:</p>
  
  <pre><code>wget http://archlinuxarm.org/os/ArchLinuxARM-armv7-latest.tar.gz
  mkdir archlinux_arm_root
  bsdtar -xpf ArchLinuxARM-armv7-latest.tar.gz -C archlinux_arm_root
  qemu-img create -f raw disk_img.img 1G
  mkfs.ext4 -F disk_img.img
  sudo mkdir /mnt/root
  sudo mount -o loop disk_img.img /mnt/root
  sudo cp -rf archlinux_arm_root/* /mnt/root/
  sudo umount /mnt/root
  cp archlinux_arm_root/boot/zImage zImage
  cp archlinux_arm_root/boot/dtbs/vexpress-v2p-ca9.dtb device_tree.dtb
  qemu-system-arm -m 1024M -M vexpress-a9 -cpu cortex-a9 -kernel zImage -dtb device_tree.dtb -append "root=/dev/mmcblk0 rw roottype=ext4 console=ttyAMA0" -drive if=sd,driver=raw,cache=writeback,file=disk_img.img -nographic
  </code></pre>
  
  <p>I created a raw disk image, then manually installed archlinux (by mounting the disk image and copying the root file system of arch on it).
  The command to emulate the board and boot on arch specifies the <code>machine/cpu/kernel/device tree/disk image</code> to use. The <code>-drive</code> option defines a new drive, and since it's an SD one I need to tell qemu to use <code>/dev/mmcblk0</code> with <code>-append</code>. Please correct me if I said anything incorrect.</p>
  
  <p>Firstly I simply want to emulate this machine without using the sd interface, but somehow just can't manage to do so.
  But more importantly I'd like to emulate a virt board.</p>