How to update QEMU on Ubuntu 18.04

Ubuntu 18.04 ships with QEMU version 2.11. If you want to use a newer version, 4.1 in my case, you can build it on your own. In case you are using Libvirt qith QEMU, keep in mind that you might need to update Libvirt as well.

The easiest way to update QEMU and Libvirt, is to simply use a custom PPA archive like this one.

How to build QEMU 4.1 on Ubuntu 18.04

This article is basically copy and paste from the excellent reddit post by liquify. It was suggested to use checkinstall in order to create an .deb-file and install it via aptitude (this would for example automatically take care of the apparmor configuration).

Unfortunately, I was unable to get this working. Thus, I sticked with the original post by liquify. This way the hand build version will not compromise the distro managed version.

  • Enable source apt list (check Source Code in “Software & Updates“, “Ubuntu Software” tab.)
  • Download the build dependencies for qemu via:
    sudo apt-get build-dep qemu
  • Download the latest qemu source code (4.1 in my case)
wget https://download.qemu.org/qemu-4.1.0.tar.xz 
tar xvJf qemu-4.1.0.tar.xz 
cd qemu-4.1.0
./configure --target-list=x86_64-softmmu --audio-drv-list=alsa,pa
make
  • When this is done we can move the qemu binary and the BIOS directory to a place were it can be used
    sudo cp x86_64-softmmu/qemu-system-x86_64 /usr/local/bin/qemu4.1-system-x86_64
    sudo cp -r pc-bios /usr/local/share/qemu
  • Add the first apparmor addition
    sudo nano /etc/apparmor.d/abstractions/libvirt-qemu
  • … and paste this block at the end of the file
    # Custom QEMU binary rules
    /usr/local/bin/qemu4.1-system-x86_64 rmix, /usr/local/share/qemu/** r,
  • Make sure the indent is matchting with the other lines. Save and close the file.
  • Add the second apparmor addition
    sudo nano /etc/apparmor.d/usr.sbin.libvirtd
  • … and paste this block at the end of the file
    # Custom QEMU binary rule
    /usr/local/bin/qemu4.1-system-x86_64 PUx,
  • Make sure the indent is matchting with the other lines. Save and close the file.
  • Reload the apparmor service, or reboot. Reload is triggered via:
    sudo service apparmor reload
  • When this is done you can later use in your libvirt config file.
<os>
   ...
   <type arch='x86_64' machine='pc-q35-4.1'>hvm</type>
   ...
</os>
and 
<devices>
   ...
   <emulator>/usr/local/bin/qemu4.1-system-x86_64</emulator>
   ...
</devices>

How to use a custom archive to update QEMU on Ubuntu 18.04

I use the virtualisation ppa from Jakob Zimmermann.

For the sake of completeness and beginner friendliness this is how you use it.

Open a terminal and run:
sudo add-apt-repository ppa:jacob/virtualisation

When the repository is added successfully, you can update QEMU and libvirt.
sudo apt-get update
sudo apt-get upgrade

Sources

Great reddit post by liquify, and askubuntu.com answer by N0rbert

Leave a Reply

Wir benutzen Cookies um die Nutzerfreundlichkeit der Webseite zu verbessen. Durch Deinen Besuch stimmst Du dem zu.