summaryrefslogtreecommitdiff
path: root/libvirt-override.c
diff options
context:
space:
mode:
Diffstat (limited to 'libvirt-override.c')
-rw-r--r--libvirt-override.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/libvirt-override.c b/libvirt-override.c
index b2271ae..2da43ab 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -7955,6 +7955,98 @@ libvirt_virNetworkGetDHCPLeases(PyObject *self ATTRIBUTE_UNUSED,
#endif /* LIBVIR_CHECK_VERSION(1, 2, 6) */
+#if LIBVIR_CHECK_VERSION(1, 2, 8)
+
+static PyObject *
+convertDomainStatsRecord(virDomainStatsRecordPtr *records,
+ int nrecords)
+{
+ PyObject *py_retval;
+ PyObject *py_record;
+ PyObject *py_record_domain;
+ PyObject *py_record_stats;
+ size_t i;
+
+ if (!(py_retval = PyList_New(nrecords)))
+ return NULL;
+
+ for (i = 0; i < nrecords; i++) {
+ if (!(py_record = PyTuple_New(2)))
+ goto error;
+
+ /* libvirt_virDomainPtrWrap steals the object */
+ virDomainRef(records[i]->dom);
+ if (!(py_record_domain = libvirt_virDomainPtrWrap(records[i]->dom))) {
+ virDomainFree(records[i]->dom);
+ goto error;
+ }
+
+ if (!(py_record_stats = getPyVirTypedParameter(records[i]->params,
+ records[i]->nparams)))
+ goto error;
+
+ if (PyTuple_SetItem(py_record, 0, py_record_domain) < 0)
+ goto error;
+
+ py_record_domain = NULL;
+
+ if (PyTuple_SetItem(py_record, 1, py_record_stats) < 0)
+ goto error;
+
+ py_record_stats = NULL;
+
+ if (PyList_SetItem(py_retval, i, py_record) < 0)
+ goto error;
+
+ py_record = NULL;
+ }
+
+ return py_retval;
+
+ error:
+ Py_XDECREF(py_retval);
+ Py_XDECREF(py_record);
+ Py_XDECREF(py_record_domain);
+ Py_XDECREF(py_record_stats);
+ return NULL;
+}
+
+
+static PyObject *
+libvirt_virConnectGetAllDomainStats(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args)
+{
+ PyObject *pyobj_conn;
+ PyObject *py_retval;
+ virConnectPtr conn;
+ virDomainStatsRecordPtr *records;
+ int nrecords;
+ unsigned int flags;
+ unsigned int stats;
+
+ if (!PyArg_ParseTuple(args, (char *)"Oii:virConnectGetAllDomainStats",
+ &pyobj_conn, &stats, &flags))
+ return NULL;
+ conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ nrecords = virConnectGetAllDomainStats(conn, stats, &records, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+
+ if (nrecords < 0)
+ return VIR_PY_NONE;
+
+ if (!(py_retval = convertDomainStatsRecord(records, nrecords)))
+ py_retval = VIR_PY_NONE;
+
+ cleanup:
+ virDomainStatsRecordListFree(records);
+
+ return py_retval;
+}
+
+#endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
+
/************************************************************************
* *
* The registration stuff *
@@ -8140,6 +8232,9 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virNodeGetFreePages", libvirt_virNodeGetFreePages, METH_VARARGS, NULL},
{(char *) "virNetworkGetDHCPLeases", libvirt_virNetworkGetDHCPLeases, METH_VARARGS, NULL},
#endif /* LIBVIR_CHECK_VERSION(1, 2, 6) */
+#if LIBVIR_CHECK_VERSION(1, 2, 8)
+ {(char *) "virConnectGetAllDomainStats", libvirt_virConnectGetAllDomainStats, METH_VARARGS, NULL},
+#endif /* LIBVIR_CHECK_VERSION(1, 2, 8) */
{NULL, NULL, 0, NULL}
};