Tuesday, March 4, 2014

virt-xml: Edit libvirt XML from the command line

We shipped a new tool with virt-manager 1.0.0 called virt-xml. virt-xml uses virt-install's command line options to allow building and editing libvirt domain XML. A few basic examples:

Change the <description> of domain 'example':
# virt-xml example --edit --metadata description="my new description"  

Enable the boot device menu for domain 'example':
# virt-xml example --edit --boot bootmenu=on  

Hotplug host USB device 001.003 to running domain 'fedora19':
# virt-xml f19 --add-device --host-device 001.003 --update

The virt-xml man page also has a comprehensive set of examples.

While I doubt anyone would call it sexy, virt-xml fills a real need in the libvirt ecosystem. Prior to virt-xml, a question like 'how do I change the cache mode for my VM disk' had two possible answers:

1) Use 'virsh edit'

'virsh edit' drops you into $EDITOR and allows you to edit the XML manually. Now ignoring the fact that editing XML by hand is a pain, 'virsh edit' requires the user to know the exact XML attribute or property name, and where to put it. And if its in the wrong place or mis-named, in most cases libvirt will happily ignore it with no feedback (this is actually useful at the API level but not very friendly for direct user interaction).

But more than that, have you ever seen what happens when you drop a less than savvy user into vim for the first time? It doesn't end well :) And this happens more than you might expect.

2) Use virt-manager

The more newbie friendly option for sure, the UI is intuitive enough that people can usually find the XML bit they want to twiddle... provided it actually exists in virt-manager.

And that's the problem: over time these types of requests put pressure on virt-manager to expose many kind-of-obscure-but-not-so-obscure-that-virsh-edit-is-an-acceptable-answer XML properties in the UI. It was unclear where to draw the line on what should be in the UI and what shouldn't, and we ended up with various UI bits that very few people were actually interacting with.

Enter virt-xml

So here's virt-xml, that allows us to easily make these types of XML changes with a single command. This takes the pressure off virt-manager, and provides a friendly middle ground between the GUI and 'virsh edit'. It also greatly simplifies documentation and wiki pages (like fedora test day test cases).

The CLI API surface is huge compared to virt-manager's UI. There's no reason that virt-xml can't expand to support every XML property exposed by libvirt. And we've worked on making it trivially easy to to extend the tool to handle new XML options: in many cases, it's only 3 lines of code to add a new --disk/--network/... sub option, including unit testing, command line introspection, and virt-install support.

Thursday, February 27, 2014

virt-install command line introspection

A new feature shipped with virt-manager 1.0.0 is simple command line introspection for virt-install and virt-xml.

Basically, any of the compound options like --disk or --graphics that take sub arguments of the form opt1=val1,opt2=val2,... will print all their sub arguments if invoked like --disk=? or --graphics=help. Example:

 $ virt-install --disk=? --network=help  
 --disk options:  
  backing_store  
  boot_order  
  bus  
  cache  
  clearxml  
  device  
  driver_name  
  driver_type  
  error_policy  
  format  
  io  
  path  
  pool  
  read_bytes_sec  
  read_iops_sec  
  readonly  
  removable  
  serial  
  shareable  
  size  
  sparse  
  startup_policy  
  target  
  total_bytes_sec  
  total_iops_sec  
  vol  
  write_bytes_sec  
  write_iops_sec
  
 --network options:  
  boot_order  
  clearxml  
  driver_name  
  driver_queues  
  filterref  
  mac  
  model  
  source  
  source_mode  
  target  
  type  
  virtualport_instanceid  
  virtualport_managerid  
  virtualport_type  
  virtualport_typeid  
  virtualport_typeidversion  

We aim to document common bits in the virt-install man page, but for less commonly used options it's better to see the official libvirt XML documenation.

Friday, February 14, 2014

virt-manager 1.0.0 released!

I'm happy to announce the release of virt-manager 1.0.0!

Our version numbers were starting to get awkward, and this release was suitably featureful, so it felt like time to bump the major version. (And it's trendy these days, right?).

virt-manager is a desktop application for managing KVM, Xen, and LXC virtualization via libvirt.

The release can be downloaded from:

http://virt-manager.org/download/

The direct download links are:

http://virt-manager.org/download/sources/virt-manager/virt-manager-1.0.0.tar.gz

This release includes:

- virt-manager: Snapshot support
- New tool virt-xml: Edit libvirt XML in one shot from the command line:
http://www.redhat.com/archives/libvir-list/2014-January/msg01226.html
- Improved defaults: qcow2, USB2, host CPU model, guest agent channel, ...
- Introspect command line options like --disk=? or --network=help
- The virt-image tool will be removed before the next release, speak up
if you have a good reason not to remove it.
- virt-manager: Support arm vexpress VM creation
- virt-manager: Add guest memory usage graphs (Thorsten Behrens)
- virt-manager: UI for editing devices (Cédric Bosdonnat)
- Spice USB redirection support (Guannan Ren)
- tpm  UI and command line support (Stefan Berger)
- rng UI and command line support (Giuseppe Scrivano)
- panic UI and command line support (Chen Hanxiao)
- blkiotune command line support (Chen Hanxiao)
- virt-manager: support for glusterfs storage pools (Giuseppe Scrivano)
- cli: New options --memory, --features, --clock, --metadata, --pm
- Greatly improve app responsiveness when connecting to remote hosts
- Lots of UI cleanup and improvements 


Over the next few weeks I'll be on writing a bit more in depth about some of the above changes.

Tuesday, December 3, 2013

KVM migration from Fedora 17 to Fedora 21+ is not supported

With qemu 1.7.0 in rawhide/Fedora 21, we've dropped some non-upstream back compatibility patches that allow migration from Fedora 17 vintage qemu and earlier.

This affects not just live migration (which I doubt anyone cares about in this context), but also any qemu memory snapshots or libvirt 'save' data created on <= F17. Trying to restore this data on F21 will not work.

In reality I don't expect this to affect anybody really. If you have saved data or snapshots that are important, you can load/restore them on Fedora 20, fully poweroff the VM, virsh edit and change the machine= value to something newer like pc-1.6, start the VM, and recreate the data to the best of your ability. save data/memory snapshots created on F20 will load correctly on F21. I realize this isn't ideal but hopefully no one is affected and it doesn't matter in practice.

Some background: In Fedora 17 and earlier, we shipped a qemu package based on qemu-kvm.git, which was a fork of qemu.git containing KVM support and a few other bits. Over time the QEMU and KVM community worked to merge all the forked bits into mainline qemu, which was fully completed with the qemu 1.3 release. Fedora 18 was the first Fedora release to ship this merged codebase

Unfortunately, qemu-kvm.git had accumulated some unintentional incompatibilities with qemu.git: minor internal bits that affected migration but had little other functional impact. The end result was that a qemu-kvm-1.2 guest could not be migrated to the new merged qemu-1.3.

This sucked for Fedora where we had always shipped qemu-kvm.git: migration/saves/snapshots made on Fedora 17 would not work on Fedora 18, and there would be no easy upgrade path. So we decided to maintain this migration back compatibility with qemu-kvm.git. However this required non-upstream patches, which we obviously do not want to carry forever.

I think after 3 stable releases (F20 is out soon enough) this shouldn't have much practical impact, so bye bye non-upstream patches :)

Tuesday, November 19, 2013

qemu-system-x86_64: error while loading shared libraries: libGL.so.1: failed to map segment from shared object: Permission denied

Are you getting this error when trying to start a libvirt KVM VM on Fedora 20?

qemu-system-x86_64: error while loading shared libraries: libGL.so.1: failed to map segment from shared object: Permission denied

Seems to be caused by Nvidia proprietary drivers. Whatever black magic they are doing behind the scenes is upsetting the selinux restrictions qemu is run under.

The fix:

sudo setsebool -P virt_use_execmem=on


(update Jan 2016: the original bug that prompted this post had some follow up discussion about a possible cause, so maybe it's fixable: https://bugzilla.redhat.com/show_bug.cgi?id=966695)