LWN.net Logo

Anatomy of the libvirt virtualization library (developerWorks)

Over at developerWorks, M. Tim Jones examines the libvirt virtualization control API. "From just the small amount of capabilities that I've demonstrated in this article, you can see the power that libvirt provides. And as you can expect, there are a number of applications that are being successfully built on libvirt. One of the interesting applications is virsh (demonstrated here), which is a virtualization shell. There's also virt-install, which can be used to provision new domains from operating system distributions. The utility virt-clone can be used to clone a VM from another VM (covering both operating system and disk replication). Some of the higher-level applications include virt-manager, which is a general-purpose desktop-management tool, and virt-viewer, which is a lightweight tool for securely attaching to the graphical console of VMs."
(Log in to post comments)

Anatomy of the libvirt virtualization library (developerWorks)

Posted Jan 13, 2010 23:11 UTC (Wed) by Darkmere (subscriber, #53695) [Link]

Libvirt and most of all it's UI is quite neat, and works reasonably well across distributions as well as locally, however I lack a way to pass flags from a domain specification to the VM (kvm in this case) to further specify things that you cannot find in the UI.

Strange that I have to move from Libvirt/Virt-manager and towards a basic console launched KVM in order to get my cpu selection.

Anatomy of the libvirt virtualization library (developerWorks)

Posted Jan 13, 2010 23:48 UTC (Wed) by nix (subscriber, #2304) [Link]

Quite so. I also find that I need monitor support fairly often, and
whenever I need it I have to drop libvirt on the floor.

I suspect I'm just going to grant qemu CAP_NET_ADMIN privs so it can get
its tap socket and use a simple shell script to kick off VMs.

Anatomy of the libvirt virtualization library (developerWorks)

Posted Jan 14, 2010 19:57 UTC (Thu) by rwmj (subscriber, #5474) [Link]

By monitor you mean qemu monitor? What specific qemu monitor commands do you need to run?
We can add those to libvirt to make you happy.

Anatomy of the libvirt virtualization library (developerWorks)

Posted Jan 14, 2010 21:02 UTC (Thu) by jimparis (subscriber, #38647) [Link]

To expand on Richard's comment a bit -- there are a lot of things that you can do from within the qemu monitor that would cause problems for libvirt. For example anything that changes the state of the VM, like attaching or detaching devices, would lead to inconsistencies in libvirt's view of the vm, which can cause problems later when libvirt tries to make changes. TSo the general approach is to just add whatever support you need directly into libvirt. In my experience the developers are very receptive to adding new features this way.

If you really want to add an additional monitor interface and you're willing to accept the risk, you can always use a wrapper script to adjust the commandline, and point libvirt to that wrapper in your domain XML. I occasionally use this approach as a quick-and-dirty way to enable some particular qemu feature while waiting for libvirt to add support.

Anatomy of the libvirt virtualization library (developerWorks)

Posted Jan 18, 2010 2:34 UTC (Mon) by lutchann (subscriber, #8872) [Link]

Just use tunctl to create static ("persistent") tun/tap devices owned by the user that will run KVM. Then KVM can use those taps without any special privileges.

Anatomy of the libvirt virtualization library (developerWorks)

Posted Jan 18, 2010 21:56 UTC (Mon) by nix (subscriber, #2304) [Link]

Aha, nice, thanks: I misread drivers/net/tun.c:tun_set_iff() to say that
you needed CAP_NET_ADMIN *and* appropriate ownership :) but either will
do. (Also I didn't realise static tun/tap devices were even possible.)

Anatomy of the libvirt virtualization library (developerWorks)

Posted Jan 27, 2010 20:58 UTC (Wed) by nix (subscriber, #2304) [Link]

They're possible, but it still doesn't work. Sigh.

Lots of annoying kernel recompiling ahead now, to pile in printk()s and
try to figure out where things are going wrong. If I had SystemTap running
this would probably be much easier :/

Copyright © 2010, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds