diff options
author | Peter Krempa <pkrempa@redhat.com> | 2023-01-12 13:26:37 +0100 |
---|---|---|
committer | Peter Krempa <pkrempa@redhat.com> | 2023-01-12 13:52:25 +0100 |
commit | c59d3232b736507ccf7162acfb723b075d6d57c6 (patch) | |
tree | 5a07994995dd5539d84d4d588be35036ed7a9259 /libvirt-override.c | |
parent | d75be368770315c04db70dda330dd9b57a871840 (diff) | |
download | libvirt-python-c59d3232b736507ccf7162acfb723b075d6d57c6.tar.gz |
override: domain: Implement override for virDomainFDAssociatev9.0.0
The bindings generator can't generate proper bindings for FD passing so
the bindings need to be implemented manually both the python wrapper and
the C backend.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Diffstat (limited to 'libvirt-override.c')
-rw-r--r-- | libvirt-override.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/libvirt-override.c b/libvirt-override.c index b28f155..6f45aa4 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -10789,6 +10789,59 @@ libvirt_virDomainRestoreParams(PyObject *self ATTRIBUTE_UNUSED, } #endif /* LIBVIR_CHECK_VERSION(8, 4, 0) */ + +#if LIBVIR_CHECK_VERSION(9, 0, 0) +static PyObject * +libvirt_virDomainFDAssociate(PyObject *self ATTRIBUTE_UNUSED, + PyObject *args) +{ + PyObject *py_retval = NULL; + int c_retval; + virDomainPtr domain; + PyObject *pyobj_domain; + PyObject *pyobj_files; + const char *name = NULL; + unsigned int flags; + unsigned int nfiles; + int *files = NULL; + ssize_t i; + + if (!PyArg_ParseTuple(args, (char *)"OsOI:virDomainFDAssociate", + &pyobj_domain, &name, &pyobj_files, &flags)) + return NULL; + domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain); + + nfiles = PyList_Size(pyobj_files); + + if (VIR_ALLOC_N(files, nfiles) < 0) + return PyErr_NoMemory(); + + for (i = 0; i < nfiles; i++) { + PyObject *pyfd; + int fd; + + pyfd = PyList_GetItem(pyobj_files, i); + + if (libvirt_intUnwrap(pyfd, &fd) < 0) + goto cleanup; + + files[i] = fd; + } + + LIBVIRT_BEGIN_ALLOW_THREADS; + c_retval = virDomainFDAssociate(domain, name, nfiles, files, flags); + LIBVIRT_END_ALLOW_THREADS; + + py_retval = libvirt_intWrap((int) c_retval); + + cleanup: + VIR_FREE(files); + return py_retval; +} +#endif /* LIBVIR_CHECK_VERSION(9, 0, 0) */ + + + /************************************************************************ * * * The registration stuff * @@ -11070,6 +11123,9 @@ static PyMethodDef libvirtMethods[] = { {(char *) "virDomainSaveParams", libvirt_virDomainSaveParams, METH_VARARGS, NULL}, {(char *) "virDomainRestoreParams", libvirt_virDomainRestoreParams, METH_VARARGS, NULL}, #endif /* LIBVIR_CHECK_VERSION(8, 4, 0) */ +#if LIBVIR_CHECK_VERSION(9, 0, 0) + {(char *) "virDomainFDAssociate", libvirt_virDomainFDAssociate, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(9, 0, 0) */ {NULL, NULL, 0, NULL} }; |