]> xenbits.xensource.com Git - libvirt.git/commitdiff
* python/generator.py python/libvir.c python/libvirt-python-api.xml:
authorDaniel Veillard <veillard@redhat.com>
Fri, 7 Dec 2007 08:41:01 +0000 (08:41 +0000)
committerDaniel Veillard <veillard@redhat.com>
Fri, 7 Dec 2007 08:41:01 +0000 (08:41 +0000)
  add a python binding for virNodeGetCellsFreeMemory
Daniel

ChangeLog
python/generator.py
python/libvir.c
python/libvirt-python-api.xml

index 4eadab2d5a62e34810d68c4302610fa6894c8b4a..fe255aed48807788710b07b8afb610a37dfbe435 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Dec  7 09:39:41 CET 2007 Daniel Veillard <veillard@redhat.com>
+
+       * python/generator.py python/libvir.c python/libvirt-python-api.xml:
+         add a python binding for virNodeGetCellsFreeMemory
+
 Thu Dec  6 12:41:18 CET 2007 Jim Meyering <meyering@redhat.com>
 
        * qemud/qemud.c (qemudInitPaths): Remove unused code.
index bf384e1c1887bb81b74f60e580136470d2f50508..5d94ec911729f6873026f669d9f8daa0e8e27b84 100755 (executable)
@@ -278,6 +278,7 @@ skip_impl = (
     'virNetworkLookupByUUID',
     'virDomainBlockStats',
     'virDomainInterfaceStats',
+    'virNodeGetCellsFreeMemory',
 )
 
 def skip_function(name):
index bab34b3ad8f7e3e256f0a213e6a64cf85c7f7699..91f3acc3ce5c0b0407c3ff52ffb434b7a423767b 100644 (file)
@@ -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}
 };
 
index b6154e75abd7d79e91885e7acc5cf747c1477676..46b2fa2e61169955f671a5e0b03422699a5fcfe3 100644 (file)
       <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>