Libvirt provides a portable, long term stable C API for managing the virtualization technologies provided by many operating systems. It includes support for QEMU, KVM, Xen, LXC, bhyve, Virtuozzo, VMware vCenter and ESX, VMware Desktop, Hyper-V, VirtualBox and the POWER Hypervisor.
Go to file
Matthias Bolte b10bca09f9 Avoid virGetVersion failure on specific driver support configurations
virGetVersion itself doesn't take a virConnectPtr, but in order to obtain
the hypervisor version against which libvirt was compiled it is used in
combination with virConnectGetType like this:

hvType = virConnectGetType(conn)
virGetVersion(&libVer, hvType, &typeVer)

When virConnectGetType is called on a remote connection then the remote
driver returns the type of the underlying driver on the server side, for
example QEMU. Then virGetVersion compares hvType to a set of strings that
depend on configure options and returns LIBVIR_VERSION_NUMBER in most
cases. Now this fails in case libvirt on the client side is just compiled
with the remote driver enabled only and the server side has the actual
driver such as the QEMU driver. It just happens to work when the actual
driver is enabled on client and server side. But that's not always true.
I noticed this on FreeBSD:

freebsd# virsh -c qemu+tcp://192.168.178.22/system version
Compiled against library: libvir 0.9.2
error: failed to get the library version
error: this function is not supported by the connection driver: virGetVersion

This is not FreeBSD specific, happens on Windows as well due to the
similar driver support configuration. The problem is that virConnectGetType
returns QEMU, but virGetVersion on the client side only accepts Remote
as hvType due to all other drivers being disabled on the client side.

Daniel P. Berrange suggested to get rid of all the conditional code in
virGetVersion, ignoring the hvType and always setting typeVer to
LIBVIR_VERSION_NUMBER. virConnectGetVersion is supposed to be used to
obtain the hypervisor version.
2011-06-07 09:41:35 +02:00
.gnulib@9d196fad05 build: avoid strerror_r pitfalls 2011-05-25 10:12:35 -06:00
daemon remote: avoid leak on failure 2011-06-03 08:11:43 -06:00
docs docs: Make hvsupport.pl pick up the host device drivers 2011-06-06 10:45:59 +02:00
examples Introduce a new event emitted when a virtualization failure occurs 2011-05-29 20:21:53 +08:00
include API: consolidate common unreleased enums 2011-06-04 09:58:53 +02:00
m4 tests: Lower stack usage below 4096 bytes 2011-04-30 19:59:52 +02:00
po Release of libvirt-0.9.2 2011-06-06 11:46:37 +08:00
python Introduce a new event emitted when a virtualization failure occurs 2011-05-29 20:21:53 +08:00
src Avoid virGetVersion failure on specific driver support configurations 2011-06-07 09:41:35 +02:00
tests Support leases in guest XML and lock manager 2011-06-02 10:54:00 +01:00
tools API: consolidate common unreleased enums 2011-06-04 09:58:53 +02:00
.dir-locals.el maint: make spacing in .sh files easier 2011-03-14 21:57:42 -06:00
.gitignore * .gitignore: Exempt a new test binary. 2011-05-31 11:35:32 -06:00
.gitmodules make .gnulib a submodule 2009-07-08 16:17:51 +02:00
.mailmap qemu: allow blkstat/blkinfo calls during migration 2011-05-26 11:05:04 -06:00
AUTHORS Correct 'cputune' documentation example. 2011-06-03 08:40:51 -06:00
autobuild.sh Remove the Open Nebula driver 2011-03-28 14:09:11 +01:00
autogen.sh build: avoid problems with autogen.sh runs from tarball 2011-02-12 06:28:28 -07:00
bootstrap build: update to latest gnulib 2011-05-18 08:31:33 -06:00
bootstrap.conf build: require newer gettext 2011-05-19 17:54:47 -06:00
cfg.mk Pass graphics setup from dst back to src via migration cookies 2011-05-16 15:18:21 +01:00
ChangeLog-old generate ChangeLog from git logs into distribution tarball 2009-07-08 16:17:51 +02:00
configure.ac Release of libvirt-0.9.2 2011-06-06 11:46:37 +08:00
COPYING.LIB remove all trailing blank lines 2009-07-16 15:06:42 +02:00
HACKING maint: rename virBufferVSprintf to virBufferAsprintf 2011-05-05 13:47:40 -06:00
libvirt.pc.in * libvirt.pc.in: applied patch from Daniel Berrange to fix --cflags 2006-03-24 13:18:12 +00:00
libvirt.spec.in Release of libvirt-0.9.2 2011-06-06 11:46:37 +08:00
Makefile.am Re-add libvirt.spec to tarball to allwo "make rpm" 2011-05-09 14:23:19 +08:00
Makefile.nonreentrant Ban use of all inet_* functions 2010-10-22 11:59:23 +01:00
mingw32-libvirt.spec.in Remove iohelper on Win32 since it is not required 2011-03-31 17:41:51 +01:00
README Correct typos in the documentation (Atsushi SAKAI) 2008-01-24 10:15:13 +00:00
README-hacking maint: relax git minimum version 2010-02-24 14:29:27 -05:00
TODO Update todo list file to point at bugzilla/website 2010-10-13 16:45:26 +01:00

         LibVirt : simple API for virtualization

  Libvirt is a C toolkit to interact with the virtualization capabilities
of recent versions of Linux (and other OSes). It is free software
available under the GNU Lesser General Public License. Virtualization of
the Linux Operating System means the ability to run multiple instances of
Operating Systems concurrently on a single hardware system where the basic
resources are driven by a Linux instance. The library aim at providing
long term stable C API initially for the Xen paravirtualization but
should be able to integrate other virtualization mechanisms if needed.

Daniel Veillard <veillard@redhat.com>