How to use libvirt in Multipass

Note: Please see instead How to set up the driver.

If you want more control over your VMs after they are launched, you can use the experimental libvirt driver:

Contents:

Switch to the libvirt driver

Make sure you have libvirt installed, as Multipass is using the libvirt daemon running on your host:

# use the equivalent for your distribution
$ sudo apt install libvirt-daemon-system

Allow Multipass to use your local libvirt:

# connect the libvirt interface/plug
$ snap connect multipass:libvirt

You can then switch the driver

# you'll need to stop all the instances first
$ multipass stop --all

# and tell Multipass to use libvirt
$ sudo multipass set local.driver=libvirt

All your existing instances will be migrated and can be used straight away.

NOTE: You can still use the multipass client and the tray icon, and any changes you make to the configuration of the instance in libvirt will be persistent. They may not be represented in Multipass commands such as multipass info, though.

Using virsh

After launching an instance, you can see it show up in virsh (see man virsh for a command reference):

$ virsh list                             
 Id   Name                   State
--------------------------------------
 1    unaffected-gyrfalcon   running

Using virt-manager

You can also use the graphical virt-manager interface:
obraz

Switching back

To switch back to the default, use the qemu driver:

# stop all instances again
$ multipass stop --all

# and switch back to the qemu driver
$ sudo multipass set local.driver=qemu

Here, too, existing instances will be migrated.

NOTE: this will make you lose any customizations you made to the instance in libvirt.

3 Likes

Hey Saviq,

there seems to be some apparmor setup missing. Getting the below when trying to start a multipass vm:

[Wed Oct  7 20:55:38 2020] audit: type=1400 audit(1602416318.740:8200): apparmor="DENIED" operation="open" profile="snap.multipass.multipassd" name="/etc/libvirt/libvirt.conf" pid=2742920 comm="multipassd" requested_mask="r" denied_mask="r" fsuid=0 ouid=0

Hi @chrome0, you need to manually connect the libvirt interface: snap connect multipass:libvirt. Thanks for pointing that out, we’ll update the post.

Hi @chrome0,

The libvirt interface does not give access to the daemon config, and it’s not necessary for Multipass to function.

Are you having problems with instances launching, or did you just notice this denial?

1 Like

Hey @saviq, after connecting the libvirt interface I can launch instances fine – cheers