summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@redhat.com>2007-12-07 08:41:01 +0000
committerDaniel Veillard <veillard@redhat.com>2007-12-07 08:41:01 +0000
commit205dd748b9917dda70212aff0d296389e378f21a (patch)
tree0126578e8f9c55c34199bb4372ad1d1e5b652ecb
parent33ed12a754be58e87faab059e13b6646d67f4e9b (diff)
downloadlibvirt-python-split-205dd748b9917dda70212aff0d296389e378f21a.tar.gz
libvirt-python-split-205dd748b9917dda70212aff0d296389e378f21a.tar.xz
libvirt-python-split-205dd748b9917dda70212aff0d296389e378f21a.zip
* python/generator.py python/libvir.c python/libvirt-python-api.xml:
add a python binding for virNodeGetCellsFreeMemory Daniel
-rwxr-xr-xgenerator.py1
-rw-r--r--libvir.c40
-rw-r--r--libvirt-python-api.xml7
3 files changed, 48 insertions, 0 deletions
diff --git a/generator.py b/generator.py
index bf384e1..5d94ec9 100755
--- a/generator.py
+++ b/generator.py
@@ -278,6 +278,7 @@ skip_impl = (
'virNetworkLookupByUUID',
'virDomainBlockStats',
'virDomainInterfaceStats',
+ 'virNodeGetCellsFreeMemory',
)
def skip_function(name):
diff --git a/libvir.c b/libvir.c
index bab34b3..91f3acc 100644
--- a/libvir.c
+++ b/libvir.c
@@ -27,6 +27,7 @@ PyObject *libvirt_virGetLastError(PyObject *self ATTRIBUTE_UNUSED, PyObject *arg
PyObject *libvirt_virConnGetLastError(PyObject *self ATTRIBUTE_UNUSED, PyObject *args);
PyObject * libvirt_virDomainBlockStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args);
PyObject * libvirt_virDomainInterfaceStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args);
+PyObject * libvirt_virNodeGetCellsFreeMemory(PyObject *self ATTRIBUTE_UNUSED, PyObject *args);
/************************************************************************
* *
@@ -844,7 +845,45 @@ libvirt_virNetworkGetAutostart(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
return(py_retval);
}
+PyObject * libvirt_virNodeGetCellsFreeMemory(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args)
+{
+ PyObject *py_retval;
+ PyObject *pyobj_conn;
+ int startCell, maxCells, c_retval, i;
+ virConnectPtr conn;
+ unsigned long long *freeMems;
+
+ if (!PyArg_ParseTuple(args, (char *)"Oii:virNodeGetCellsFreeMemory", &pyobj_conn, &startCell, &maxCells))
+ return(NULL);
+ if ((startCell < 0) || (maxCells <= 0) || (startCell + maxCells > 10000))
+ goto error;
+
+ conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
+ freeMems = (unsigned long long *)
+ malloc(maxCells * sizeof(unsigned long long));
+ if (freeMems == NULL)
+ goto error;
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_retval = virNodeGetCellsFreeMemory(conn, freeMems, startCell, maxCells);
+ LIBVIRT_END_ALLOW_THREADS;
+
+ if (c_retval < 0) {
+ free(freeMems);
+error:
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+ py_retval = PyList_New(c_retval);
+ for (i = 0;i < c_retval;i++) {
+ PyList_SetItem(py_retval, i,
+ libvirt_longlongWrap((long long) freeMems[i]));
+ }
+ free(freeMems);
+ return(py_retval);
+}
/************************************************************************
* *
@@ -875,6 +914,7 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virNetworkGetAutostart", libvirt_virNetworkGetAutostart, METH_VARARGS, NULL},
{(char *) "virDomainBlockStats", libvirt_virDomainBlockStats, METH_VARARGS, NULL},
{(char *) "virDomainInterfaceStats", libvirt_virDomainInterfaceStats, METH_VARARGS, NULL},
+ {(char *) "virNodeGetCellsFreeMemory", libvirt_virNodeGetCellsFreeMemory, METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
};
diff --git a/libvirt-python-api.xml b/libvirt-python-api.xml
index b6154e7..46b2fa2 100644
--- a/libvirt-python-api.xml
+++ b/libvirt-python-api.xml
@@ -75,5 +75,12 @@
<arg name='domain' type='virDomainPtr' info='a domain object'/>
<arg name='path' type='char *' info='the path for the interface device'/>
</function>
+ <function name="virNodeGetCellsFreeMemory" file='python'>
+ <info>Returns the availbale memory for a list of cells</info>
+ <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
+ <arg name='startCell' type='int' info='first cell in the list'/>
+ <arg name='maxCells' type='int' info='number of cell in the list'/>
+ <return type='int *' info="the list available memory in the cells"/>
+ </function>
</symbols>
</api>