In recent versions of the libvirt
virtualisation libraries, you to create and manage virtual machines as a regular user, using the qemu:///session
connection.
This is great, but the networking is quite limited. I found that machines defined in Gnome Boxes could not speak to each-other, and that libvirt commands for networking were unavailable.
For this reason, I’ve written this quick guide for booting up an existing same VM image under the qemu:///system
instance, which is faster than re-installing the machine. Unlike most sorts of migrations, this leaves the disk image at the same location on the same host machine.
There’s many different ways to do VM’s in Linux. This setup will be useful only if you use libvirt/kvm using qcow2 images on Debian. As always, consider doing a backup before trying new things.
Configuration files
First, find your virtual machine in virsh
, and dump its configuration to a text file in your home directory, as a regular user.
|
|
Now remove the VM definition from your user:
|
|
Import the definitions into virsh as the root user:
|
|
Attempt to start the new VM definition. Depending on where the disk image is, expect an error.
|
|
Disk images
The disk image needs to be accessible to the libvirt-qemu
user. There’s two basic ways to achieve this: Re-permission the directories above it, or move it.
I chose to just re-permission it, since it’s not an issue to have world-readable directories on this particular box:
|
|
This one-liner outputs the commands to run to make a directory work/navigable:
|
|
And the user account needs to be able to write as well:
|
|
Once you have the permissions right, the VM should start, using the same command as before:
|
|
More importantly, you can now hook up virt-manager and view your machine on qemu:///system
, allowing you to configure the VM with any network settings you need.