diff options
author | Osier Yang <jyang@redhat.com> | 2012-09-05 13:34:11 +0800 |
---|---|---|
committer | Osier Yang <jyang@redhat.com> | 2012-09-17 10:41:03 +0800 |
commit | c9f08903d4bc4ebada4280781ea41fa61f5e8b2d (patch) | |
tree | a4c3868938f19835f3a567214827b9f7ffe5c943 /libvirt-override.c | |
parent | cb41d86c6c79dac1ab6440a5ce49945e09b0322d (diff) | |
download | libvirt-python-v6-c9f08903d4bc4ebada4280781ea41fa61f5e8b2d.tar.gz libvirt-python-v6-c9f08903d4bc4ebada4280781ea41fa61f5e8b2d.tar.xz libvirt-python-v6-c9f08903d4bc4ebada4280781ea41fa61f5e8b2d.zip |
list: Expose virConnectListAllNodeDevices to Python binding
The implementation is done manually as the generator does not support
wrapping lists of C pointers into Python objects.
python/libvirt-override-api.xml: Document
python/libvirt-override-virConnect.py:
* Implementation for listAllNodeDevices.
python/libvirt-override.c: Implementation for the wrapper.
Diffstat (limited to 'libvirt-override.c')
-rw-r--r-- | libvirt-override.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/libvirt-override.c b/libvirt-override.c index d07e7cb..426d57e 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -3387,6 +3387,53 @@ libvirt_virNodeListDevices(PyObject *self ATTRIBUTE_UNUSED, } static PyObject * +libvirt_virConnectListAllNodeDevices(PyObject *self ATTRIBUTE_UNUSED, + PyObject *args) +{ + PyObject *pyobj_conn; + PyObject *py_retval = NULL; + PyObject *tmp = NULL; + virConnectPtr conn; + virNodeDevicePtr *devices = NULL; + int c_retval = 0; + int i; + unsigned int flags; + + if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllNodeDevices", + &pyobj_conn, &flags)) + return NULL; + conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn); + + LIBVIRT_BEGIN_ALLOW_THREADS; + c_retval = virConnectListAllNodeDevices(conn, &devices, flags); + LIBVIRT_END_ALLOW_THREADS; + if (c_retval < 0) + return VIR_PY_NONE; + + if (!(py_retval = PyList_New(c_retval))) + goto cleanup; + + for (i = 0; i < c_retval; i++) { + if (!(tmp = libvirt_virNodeDevicePtrWrap(devices[i])) || + PyList_SetItem(py_retval, i, tmp) < 0) { + Py_XDECREF(tmp); + Py_DECREF(py_retval); + py_retval = NULL; + goto cleanup; + } + /* python steals the pointer */ + devices[i] = NULL; + } + +cleanup: + for (i = 0; i < c_retval; i++) + if (devices[i]) + virNodeDeviceFree(devices[i]); + VIR_FREE(devices); + return py_retval; +} + +static PyObject * libvirt_virNodeDeviceListCaps(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { PyObject *py_retval; @@ -6087,6 +6134,7 @@ static PyMethodDef libvirtMethods[] = { {(char *) "virEventInvokeHandleCallback", libvirt_virEventInvokeHandleCallback, METH_VARARGS, NULL}, {(char *) "virEventInvokeTimeoutCallback", libvirt_virEventInvokeTimeoutCallback, METH_VARARGS, NULL}, {(char *) "virNodeListDevices", libvirt_virNodeListDevices, METH_VARARGS, NULL}, + {(char *) "virConnectListAllNodeDevices", libvirt_virConnectListAllNodeDevices, METH_VARARGS, NULL}, {(char *) "virNodeDeviceListCaps", libvirt_virNodeDeviceListCaps, METH_VARARGS, NULL}, {(char *) "virSecretGetUUID", libvirt_virSecretGetUUID, METH_VARARGS, NULL}, {(char *) "virSecretGetUUIDString", libvirt_virSecretGetUUIDString, METH_VARARGS, NULL}, |