Your submission was sent successfully! Close

1. Overview

When developing for Ubuntu Core it is often convenient to work in a virtual machine [VM]. Unfortunately, the archive build of qemu on Ubuntu doesn’t support graphics passthrough. This is a quick guide to setting up an Ubuntu Core VM using qemu-virgil.

2. Setup qemu with graphics support

As the default build of qemu on Ubuntu doesn’t support graphics, we will use a handy snap containing a build that enables this:

$ sudo snap install qemu-virgil
$ sudo snap connect qemu-virgil:kvm

Check the snap is working:

$ qemu-virgil --version

3. Download and prepare the Ubuntu Core image

We also download an Ubuntu Core image. On an x86 computer download the ubuntu-core-20-amd64.img.xz image from here:

Now, uncompress the image and move it to a convenient location:

$ unxz ~/Downloads/ubuntu-core-20-amd64.img.xz
$ mv ~/Downloads/ubuntu-core-20-amd64.img ~/snap/qemu-virgil/common/

4. Initialize a VM with the Ubuntu Core image

$ qemu-virgil -enable-kvm -m 512 -device virtio-vga,virgl=on\
 -display sdl,gl=on -netdev user,id=ethernet.0,hostfwd=tcp::10022-:22\
 -device rtl8139,netdev=ethernet.0\
 -drive file=/snap/qemu-virgil/current/usr/share/qemu/edk2-x86_64-code.fd,if=pflash,format=raw,unit=0,readonly=on\

This will create a QEMU window on your desktop and you need to follow through the prompts to initialise the VM with your launchpad account. (If you don’t have a launchpad account, you will need it to work with Ubuntu Core: get one and set up a public SSH key.)

Connect to the VP using ssh from a terminal window (ignore the address shown in the QEMU window and use the port set in the above command):

$ ssh -p 10022 <launchpad account>@localhost

5. Congratulations!