Monday, January 4, 2016

Polkit password-less access for the 'libvirt' group

Many users, who admin their own machines, want to be able to use tools like virt-manager without having to enter a root password. Just google 'virt-manager without password' and see all the hits. I've seen many blogs and articles over the years describing various ways to work around it.

The password prompting is via libvirt's polkit integration. The idea is that we want the applications to run as a regular unprivileged user (running GUI apps as root is considered a no-no), and only use the root authentication for talking to system libvirt instance. Most workarounds suggest installing a polkit rule to allow your user, or a particular user group, to access libvirt without needing to enter the root password.

In libvirt v1.2.16 we finally added official support for this (and backported to Fedora22+). The group is predictably called 'libvirt'. This matches polkit rules that debian and suse were already shipping too.

So just add your user to the 'libvirt' group and enjoy passwordless virt-manager usage:

$ usermod --append --groups libvirt `whoami`

Saturday, January 2, 2016

UEFI support in virt-install and virt-manager

One of the new features in virt-manager 1.2.0 (from back in May) is user friendly support for enabling UEFI.

First a bit about terminology: When UEFI is packaged up to run in an x86 VM, it's often called OVMF. When UEFI is packaged up to run in an AArch64 VM, it's often called AAVMF. But I'll just refer to all of it as UEFI.

Using UEFI with virt-install and virt-manager


The first step to enable this for VMs is to install the binaries. UEFI still has some licensing issues that make it incompatible with Fedora's policies, so the bits are hosted in an external repo. Details for installing the repo and UEFI bits are over here.

Once the bits are installed (and you're on Fedora 22 or later), virt-manager and virt-install provide simple options to enable UEFI when creating VMs.

Marcin has a great post with screenshots describing this for virt-manager (for aarch64, but the steps are identical for x86 VMs).

For virt-install it's as simple as doing:

$ sudo virt-install --boot uefi ...

virt-install will get the binary paths from libvirt and set everything up with the optimal config. If virt-install can't figure out the correct parameters, like if no UEFI binaries are installed, you'll see an error like: ERROR    Error: --boot uefi: Don't know how to setup UEFI for arch 'x86'

See 'virt-install --boot help' if you need to tweak the parameters individually.

Implementing support in applications


Libvirt needs to know about UEFI<->NVRAM config file mapping, so it can advertise it to tools like virt-manager/virt-install. Libvirt looks at a hardcoded list of known host paths to see if any firmware is installed, and if so, lists those paths in domain capabilities output (virsh domcapabilities). Libvirt in Fedora 22+ knows to look for the paths provided by the repo mentioned above, so just installing the firmware is sufficient to make libvirt advertise UEFI support.

The domain capabilities output only lists the firmware path and the associated variable store path. Notably lacking is any indication of what architecture the binaries are meant for. So tools need to determine this mapping themselves.

virt-manager/virt-install and libguestfs use a similar path matching heuristic. The libguestfs code is a good reference:

    match guest_arch with
    | "i386" | "i486" | "i586" | "i686" ->
       [ "/usr/share/edk2.git/ovmf-ia32/OVMF_CODE-pure-efi.fd",
         "/usr/share/edk2.git/ovmf-ia32/OVMF_VARS-pure-efi.fd" ]
    | "x86_64" ->
       [ "/usr/share/OVMF/OVMF_CODE.fd",
         "/usr/share/OVMF/OVMF_VARS.fd";
         "/usr/share/edk2.git/ovmf-x64/OVMF_CODE-pure-efi.fd",
         "/usr/share/edk2.git/ovmf-x64/OVMF_VARS-pure-efi.fd" ]
    | "aarch64" ->
       [ "/usr/share/AAVMF/AAVMF_CODE.fd",
         "/usr/share/AAVMF/AAVMF_VARS.fd";
         "/usr/share/edk2.git/aarch64/QEMU_EFI-pflash.raw",
         "/usr/share/edk2.git/aarch64/vars-template-pflash.raw" ]
    | arch ->
       error (f_"don't know how to convert UEFI guests for architecture %s")
             guest_arch in

Having to track this in every app is quite crappy, but it's the only good solution at the moment. Hopefully long term libvirt will grow some solution that makes this easier for applications.

Wednesday, November 25, 2015

virt-manager 1.3.0 released!

Last night I released virt-manager-1.3.0. Not too much exciting in this release, just a lot of little improvements and bug fixes.

The highlights:
  • Git hosting moved to http://github.com/virt-manager/virt-manager
  • Switch translation infrastructure from transifex to fedora.zanata.org
  • Add dogtail UI tests and infrastructure
  • Improved support for s390x kvm (Kevin Zhao)
  • virt-install and virt-manager now remove created disk images if VM install startup fails
  • Replace urlgrabber usage with requests and urllib2
  • virt-install: add --network virtualport support for openvswitch (Daniel P. Berrange)
  • virt-install: support multiple --security labels
  • virt-install: support --features kvm_hidden=on|off (Pavel Hrdina)
  • virt-install: add --features pmu=on|off
  • virt-install: add --features pvspinlock=on|off (Abhijeet Kasurde)
  • virt-install: add --events on_lockfailure=on|off (Abhijeet Kasurde)
  • virt-install: add --network link_state=up|down
  • virt-install: add --vcpu placement=static|auto

Monday, May 4, 2015

virt-manager 1.2.0 released!

Today I released virt-manager-1.2.0. You can read the release announcement here:

This release includes:
  • OVMF/AAVMF Support (Laszlo Ersek, Giuseppe Scrivano, Cole Robinson)
  • Improved support for AArch64 qemu/kvm
  • virt-install: Support --disk type=network parameters
  • virt-install: Make --disk $URL just work
  • virt-install: Add --disk sgio= option (Giuseppe Scrivano)
  • addhardware: default to an existing bus when adding a new disk (Giuseppe Scrivano)
  • virt-install: Add --input device option
  • virt-manager: Unify storagebrowser and storage details functionality
  • virt-manager: allow setting a custom connection row name
  • virt-install: Support --hostdev scsi passthrough
  • virt-install: Fill in a bunch of --graphics spice options
  • Disable spice image compression for new local VMs
  • virt-manager: big reworking of the migration dialog

Look out for future posts on the first 4 line items :)

Monday, April 13, 2015

Fedora 22 Virt Test Day is Thu Apr 16!

A reminder that the Fedora 22 Virt Test Day is this coming Thu Apr 16. Check out the test day landing page:

https://fedoraproject.org/wiki/Test_Day:2015-04-16_Virtualization

It's a great time to make sure your virt workflow is still working correctly with the latest packages in Fedora 22. No requirement to run through test cases on the wiki, just show up and let us know what works (or breaks).

Updating to a development release of Fedora scares some people, but it's NOT required to help out with the test day: you can test the latest virt bits on the latest Fedora release courtesy of the virt-preview repo. For more details, as well as easy instructions on updating to Fedora 22, see:

https://fedoraproject.org/wiki/Test_Day:2015-04-16_Virtualization#What.27s_needed_to_test

Though running latest Fedora 22 on a physical machine is still preferred :)

If you want to help out, pop into #fedora-test-day on Thursday and give us a shout!