[libvirt] qemu or kvm?

Hi, Given a virDomainPtr variable, how can we know that it is a QEMU or KVM machine? Is there any API for that? Many thanks, Jun

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. Rich. [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. http://et.redhat.com/~rjones/virt-p2v

On Fri, Sep 12, 2008 at 6:37 PM, Richard W.M. Jones <rjones@redhat.com> wrote:
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.
That is clear now, thanks! Yes, I am using C. Is there any code sample on using libxml2 in libvirt code? Thanks, Jun

On Fri, Sep 12, 2008 at 09:50:35PM +0900, Jun Koi wrote:
Yes, I am using C. Is there any code sample on using libxml2 in libvirt code?
Well libxml2 is used extensively within libvirt, so if you look at the sources to libvirt I'm sure you'll find plenty of examples. You may also find information here: http://xmlsoft.org/docs.html Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones Read my OCaml programming blog: http://camltastic.blogspot.com/ Fedora now supports 68 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
participants (2)
-
Jun Koi
-
Richard W.M. Jones