summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xgenerator.py1
-rw-r--r--libvir.c47
-rw-r--r--libvirt-python-api.xml5
3 files changed, 53 insertions, 0 deletions
diff --git a/generator.py b/generator.py
index d921f98..48cd3ee 100755
--- a/generator.py
+++ b/generator.py
@@ -260,6 +260,7 @@ foreign_encoding_args = (
# code is still automatically generated (so they are not in skip_function()).
skip_impl = (
'virConnectListDomainsID',
+ 'virConnectListDefinedDomains',
'virConnGetLastError',
'virGetLastError',
'virDomainGetInfo',
diff --git a/libvir.c b/libvir.c
index 6d14fb2..1d8e422 100644
--- a/libvir.c
+++ b/libvir.c
@@ -241,6 +241,52 @@ libvirt_virConnectListDomainsID(PyObject *self ATTRIBUTE_UNUSED,
}
static PyObject *
+libvirt_virConnectListDefinedDomains(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args) {
+ PyObject *py_retval;
+ char **names = NULL;
+ int c_retval, i;
+ virConnectPtr conn;
+ PyObject *pyobj_conn;
+
+
+ if (!PyArg_ParseTuple(args, (char *)"O:virConnectListDomains", &pyobj_conn))
+ return(NULL);
+ conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
+
+ c_retval = virConnectNumOfDefinedDomains(conn);
+ if (c_retval < 0) {
+ Py_INCREF(Py_None);
+ return (Py_None);
+ }
+
+ if (c_retval) {
+ names = malloc(sizeof(char *) * c_retval);
+ if (!names) {
+ Py_INCREF(Py_None);
+ return (Py_None);
+ }
+ c_retval = virConnectListDefinedDomains(conn, (const char **)names, c_retval);
+ if (c_retval < 0) {
+ free(names);
+ Py_INCREF(Py_None);
+ return(Py_None);
+ }
+ }
+ py_retval = PyList_New(c_retval);
+
+ if (names) {
+ for (i = 0;i < c_retval;i++) {
+ PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
+ free(names[i]);
+ }
+ free(names);
+ }
+
+ return(py_retval);
+}
+
+static PyObject *
libvirt_virDomainGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
PyObject *py_retval;
int c_retval;
@@ -364,6 +410,7 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virDomainFree", libvirt_virDomainFree, METH_VARARGS, NULL},
{(char *) "virConnectClose", libvirt_virConnectClose, METH_VARARGS, NULL},
{(char *) "virConnectListDomainsID", libvirt_virConnectListDomainsID, METH_VARARGS, NULL},
+ {(char *) "virConnectListDefinedDomains", libvirt_virConnectListDefinedDomains, METH_VARARGS, NULL},
{(char *) "virDomainGetInfo", libvirt_virDomainGetInfo, METH_VARARGS, NULL},
{(char *) "virNodeGetInfo", libvirt_virNodeGetInfo, METH_VARARGS, NULL},
{(char *) "virDomainGetUUID", libvirt_virDomainGetUUID, METH_VARARGS, NULL},
diff --git a/libvirt-python-api.xml b/libvirt-python-api.xml
index 302ba02..1a658a3 100644
--- a/libvirt-python-api.xml
+++ b/libvirt-python-api.xml
@@ -6,6 +6,11 @@
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
<return type='int *' info="the list of ID or None in case of error"/>
</function>
+ <function name='virConnectListDefinedDomains' file='python'>
+ <info>list the defined domains, stores the pointers to the names in @names</info>
+ <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
+ <return type='str *' info='the list of Names of None in case of error'/>
+ </function>
<function name='virDomainLookupByUUID' file='python'>
<info>Try to lookup a domain on the given hypervisor based on its UUID.</info>
<return type='virDomainPtr' info='a new domain object or NULL in case of failure'/>