summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Privoznik <mprivozn@redhat.com>2014-09-25 17:02:49 +0200
committerMichal Privoznik <mprivozn@redhat.com>2014-09-26 12:01:17 +0200
commita03b509d1cf90e83ad7e2f0e35eae51ddee78bcf (patch)
tree3483b75b6b0cfa3b89191b28afa0ab139d468c6f
parent4acfb169400497da2a82a849dc8aaa65f88ac6d1 (diff)
downloadlibvirt-python-a03b509d1cf90e83ad7e2f0e35eae51ddee78bcf.tar.gz
Implement new virNodeAllocPages API
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
-rwxr-xr-xgenerator.py1
-rw-r--r--libvirt-override-api.xml9
-rw-r--r--libvirt-override.c67
3 files changed, 77 insertions, 0 deletions
diff --git a/generator.py b/generator.py
index 8ee046a..e8e29b9 100755
--- a/generator.py
+++ b/generator.py
@@ -465,6 +465,7 @@ skip_impl = (
'virNodeGetFreePages',
'virNetworkGetDHCPLeases',
'virDomainBlockCopy',
+ 'virNodeAllocPages',
)
lxc_skip_impl = (
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index 51d8273..4fe3c4d 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -649,5 +649,14 @@
<arg name='flags' type='unsigned int' info='bitwise-OR of virDomainBlockCopyFlags'/>
<return type='int' info='0 if the operation has started, -1 on failure'/>
</function>
+ <function name="virNodeAllocPages" file='python'>
+ <info>Allocate or free some pages in the huge pages pool</info>
+ <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
+ <arg name='pages' type='char *' info='dictionary of desired page sizes, key is page size, value is page count'/>
+ <arg name='startCell' type='int' info='optional first cell in the list'/>
+ <arg name='cellCount' type='int' info='optional number of cell in the list'/>
+ <arg name='flags' type='unsigned int' info='an OR&apos;ed set of virNodeAllocPagesFlags'/>
+ <return type='int' info='the number of nodes successfully adjusted or -1 in case of an error'/>
+ </function>
</symbols>
</api>
diff --git a/libvirt-override.c b/libvirt-override.c
index 872e33b..c5017a5 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -8129,6 +8129,70 @@ libvirt_virDomainBlockCopy(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
#endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
+#if LIBVIR_CHECK_VERSION(1, 2, 9)
+static PyObject *
+libvirt_virNodeAllocPages(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args)
+{
+ PyObject *pyobj_conn;
+ PyObject *pyobj_pages;
+ Py_ssize_t size = 0;
+ Py_ssize_t pos = 0;
+ PyObject *key, *value;
+ virConnectPtr conn;
+ unsigned int npages = 0;
+ unsigned int *pageSizes = NULL;
+ unsigned long long *pageCounts = NULL;
+ int startCell = -1;
+ unsigned int cellCount = 1;
+ unsigned int flags = VIR_NODE_ALLOC_PAGES_ADD;
+ int c_retval;
+
+ if (!PyArg_ParseTuple(args, (char *)"OOiii:virConnectGetAllDomainStats",
+ &pyobj_conn, &pyobj_pages,
+ &startCell, &cellCount, &flags))
+ return NULL;
+ conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
+
+ if ((size = PyDict_Size(pyobj_pages)) < 0)
+ return NULL;
+
+ if (size == 0) {
+ PyErr_Format(PyExc_LookupError,
+ "Need non-empty dictionary to pages attribute");
+ return NULL;
+ }
+
+ if (VIR_ALLOC_N(pageSizes, size) < 0 ||
+ VIR_ALLOC_N(pageCounts, size) < 0) {
+ PyErr_NoMemory();
+ goto error;
+ }
+
+ while (PyDict_Next(pyobj_pages, &pos, &key, &value)) {
+ if (libvirt_uintUnwrap(key, &pageSizes[npages]) < 0 ||
+ libvirt_ulonglongUnwrap(value, &pageCounts[npages]) < 0)
+ goto error;
+ npages++;
+ }
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_retval = virNodeAllocPages(conn, npages, pageSizes,
+ pageCounts, startCell, cellCount, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+
+ VIR_FREE(pageSizes);
+ VIR_FREE(pageCounts);
+
+ return libvirt_intWrap(c_retval);
+
+ error:
+ VIR_FREE(pageSizes);
+ VIR_FREE(pageCounts);
+ return NULL;
+}
+#endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
+
/************************************************************************
* *
* The registration stuff *
@@ -8319,6 +8383,9 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virDomainListGetStats", libvirt_virDomainListGetStats, METH_VARARGS, NULL},
{(char *) "virDomainBlockCopy", libvirt_virDomainBlockCopy, METH_VARARGS, NULL},
#endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
+#if LIBVIR_CHECK_VERSION(1, 2, 9)
+ {(char *) "virNodeAllocPages", libvirt_virNodeAllocPages, METH_VARARGS, NULL},
+#endif /* LIBVIR_CHECK_VERSION(1, 2, 9) */
{NULL, NULL, 0, NULL}
};