Wednesday, January 6, 2016

tip: Launch a new terminal with F1

Back when I first switched to gnome-shell with Fedora 16, I read a lot of blog posts and wiki pages about keyboard shortcuts, extensions that people were using, praise and complaints, etc. Somewhere in all that (I can't remember where), I picked up a tip that I now use dozens of times a day and couldn't live without: remapping F1 to launch a new terminal.

It didn't even take much training to get used to it, because the method is just so much quicker than anything involving the mouse, or super key, or alt+f2, that I took to it immediately. And from there it was a small step to get used to using exit to actually quit a terminal, leading to drastically less mouse usage (yes my habits were quite crappy on gnome2).

It also has the added benefit of unmapping the help dialog from F1, which I've never once used intentionally, and every unintentional usage (of which there were many) would make my machine churn pretty hard for a good few seconds before popping up the dialog.

It's pretty easy to make the change on F23:

  • From gnome-shell desktop, go to Activities->Keyboard
  • Navigate to Shortcuts->Custom Shortcuts
  • Under launchers, disable 'Launch help browser'
  • Under 'Custom shortcuts', click '+', map F1 to gnome-terminal

I'm sure if you use a single terminal + tmux, or guake, this isn't interesting, but maybe it will help someone like it helped me.

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 :)