On 09/25/2014 05:07 PM, Michal Privoznik wrote:
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
generator.py | 1 +
libvirt-override-api.xml | 9 ++++++
libvirt-override.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 81 insertions(+)
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'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..29cc8a9 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -8129,6 +8129,74 @@ 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;
+#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 4
+ int pos = 0;
+#else
+ Py_ssize_t pos = 0;
+#endif
This is not necessary, see typewrappers.h:26, you can use just the
Py_ssize_t as you are using for "size".
+ 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 +8387,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}
};
ACK with the change mentioned above.
Pavel