Tuesday, July 15, 2014

virt-manager: changing the default storage path and default virtual network

When creating a new virtual machine via virt-manager or virt-install, the tools make some assumptions about the default location for disk images, and the default network source.

For example, in the 'New VM' wizard, the storage page will offer to create a disk image in the default location:


The default location for most uses of virt-manager is /var/lib/libvirt/images, which is created by libvirt and has the expected selinux labelling and permission to run QEMU/KVM VMs.

Behind the scenes, virt-manager is using a libvirt storage pool for creating disk images. When the 'New VM' wizard is first run, virt-manager looks for a storage pool named 'default'; if it doesn't find that it will create a storage pool named 'default' pointing to /var/lib/libvirt/images. It then uses that 'default' pool for the disk provisioning page.

The default virtual network works similarly. The libvirt-daemon-config-network package will dynamically create a libvirt virtual network named 'default'. You can see the XML definition over here in libvirt.git.

When virt-manager reaches the last page of the 'New VM' wizard, if there's a virtual network named 'default', we automatically select it as the network source:


It's also the network source used when no explicit network configuration is passed to virt-install.

Every now and then someone asks how to make virt-manager/virt-install use a different storage pool or network as the default. As the above logic describes, just name the desired virtual network or storage pool 'default', and the tools will do the right thing.

You can rename storage pools and virtual networks using virt-manager's UI from Edit->Connection Details. It only works on a stopped object though. Here's an example renaming a virtual network 'default' to 'new-name':


3 comments:

  1. Why doesn't virt-manager work like VirtualBox which saves everything in the home directory eliminating the need to superuser privileges and there by not chowning ISO?

    ReplyDelete
    Replies
    1. Basically, even if you use a different storage location, ISO used will be chowned to either qemu or root.

      Delete
    2. There's a few reasons virt-manager behaves the way it does. A lot of it is historical bits, but some is due to the fact that running VMs as a regular user lacks some functionality that running VMs as higher privilege can give you. I explained some more in a follow up to your mail on fedora virt list: https://lists.fedoraproject.org/pipermail/virt/2014-July/004096.html

      Delete