summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2009-11-12 10:53:26 -0500
committerCole Robinson <crobinso@redhat.com>2009-11-12 10:53:26 -0500
commitd0e7cc1264533d6a6e4ad2a5b9252f97dc96cba3 (patch)
tree3e21b67a1e3932267af472667b0b47ffef90af7d
parentbdb9c70e015181fba5f974cf233ceccbe29f1307 (diff)
downloadlibvirt-python-split-d0e7cc1264533d6a6e4ad2a5b9252f97dc96cba3.zip
libvirt-python-split-d0e7cc1264533d6a6e4ad2a5b9252f97dc96cba3.tar.gz
libvirt-python-split-d0e7cc1264533d6a6e4ad2a5b9252f97dc96cba3.tar.xz
Add virConnectGetLibvirtVersion API
There is currently no way to determine the libvirt version of a remote libvirtd we are connected to. This is a useful piece of data to enable feature detection.
-rwxr-xr-xgenerator.py1
-rw-r--r--libvirt-override-api.xml5
-rw-r--r--libvirt-override.c26
3 files changed, 32 insertions, 0 deletions
diff --git a/generator.py b/generator.py
index 21b4137..0b32116 100755
--- a/generator.py
+++ b/generator.py
@@ -255,6 +255,7 @@ foreign_encoding_args = (
# Class methods which are written by hand in libvir.c but the Python-level
# code is still automatically generated (so they are not in skip_function()).
skip_impl = (
+ 'virConnectGetLibVersion',
'virConnectListDomainsID',
'virConnectListDefinedDomains',
'virConnectListNetworks',
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index 148b89b..4e55182 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -1,6 +1,11 @@
<?xml version="1.0"?>
<api name='libvir-python'>
<symbols>
+ <function name="virConnectGetLibVersion" file='python'>
+ <info>Returns the libvirt version of the connection host</info>
+ <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
+ <return type='int' info="0 on success, -1 on error"/>
+ </function>
<function name="virConnectListDomainsID" file='python'>
<info>Returns the list of the ID of the domains on the hypervisor</info>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
diff --git a/libvirt-override.c b/libvirt-override.c
index 6c6155b..20037ef 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -728,6 +728,31 @@ libvirt_virGetVersion (PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
return Py_BuildValue ((char *) "kk", libVer, typeVer);
}
+static PyObject *
+libvirt_virConnectGetLibVersion (PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args)
+{
+ unsigned long libVer;
+ int c_retval;
+ virConnectPtr conn;
+ PyObject *pyobj_conn;
+
+ if (!PyArg_ParseTuple(args, (char *)"O:virConnectGetLibVersion",
+ &pyobj_conn))
+ return(NULL);
+ conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+
+ c_retval = virConnectGetLibVersion(conn, &libVer);
+
+ LIBVIRT_END_ALLOW_THREADS;
+
+ if (c_retval == -1)
+ return VIR_PY_INT_FAIL;
+
+ return PyInt_FromLong (libVer);
+}
static PyObject *
libvirt_virConnectListDomainsID(PyObject *self ATTRIBUTE_UNUSED,
@@ -2398,6 +2423,7 @@ libvirt_virEventInvokeTimeoutCallback(PyObject *self ATTRIBUTE_UNUSED,
static PyMethodDef libvirtMethods[] = {
#include "libvirt-export.c"
{(char *) "virGetVersion", libvirt_virGetVersion, METH_VARARGS, NULL},
+ {(char *) "virConnectGetLibVersion", libvirt_virConnectGetLibVersion, METH_VARARGS, NULL},
{(char *) "virConnectOpenAuth", libvirt_virConnectOpenAuth, METH_VARARGS, NULL},
{(char *) "virConnectListDomainsID", libvirt_virConnectListDomainsID, METH_VARARGS, NULL},
{(char *) "virConnectListDefinedDomains", libvirt_virConnectListDefinedDomains, METH_VARARGS, NULL},