[libvirt] qemu or kvm?

Richard W.M. Jones rjones at redhat.com
Fri Sep 12 09:37:03 UTC 2008

On Fri, Sep 12, 2008 at 04:26:28PM +0900, Jun Koi wrote:
> Given a virDomainPtr variable, how can we know that it is a QEMU or
> KVM machine? Is there any API for that?

Yes - use virDomainGetXMLDesc[1] to get the XML description of the
domain, then parse out the <domain type='...'> field[2] which will be
either 'qemu' or 'kvm'.  This is a pain if you're using a language
which doesn't support XML parsing, but you can usually find a library
to help you, eg. in C use libxml2.

Now there's an additional question: is KVM using hardware acceleration
or is it falling back to software emulation (ie. because the hardware
doesn't support hardware virtualization)?  IIRC you can answer this by
looking at the capabilities XML[3], but I think you'll need to do a
bit of experimentation and look at the source code.


[1] http://libvirt.org/html/libvirt-libvirt.html#virDomainGetXMLDesc
[2] http://libvirt.org/formatdomain.html#elementsMetadata
[3] http://libvirt.org/html/libvirt-libvirt.html#virConnectGetCapabilities

Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.

More information about the libvir-list mailing list