[libvirt] [PATCH python] Custom impl for virConnectSetIdentity which can't be generated
Daniel P. Berrangé
berrange at redhat.com
Fri Sep 20 09:54:35 UTC 2019
ping, this would fix our broken CI...
On Mon, Sep 16, 2019 at 05:37:43PM +0100, Daniel P. Berrangé wrote:
> Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
> ---
> generator.py | 1 +
> libvirt-override.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 67 insertions(+)
>
> diff --git a/generator.py b/generator.py
> index 433c1f2..913dab8 100755
> --- a/generator.py
> +++ b/generator.py
> @@ -489,6 +489,7 @@ skip_impl = (
> 'virDomainGetDiskErrors',
> 'virNodeGetMemoryParameters',
> 'virNodeSetMemoryParameters',
> + 'virConnectSetIdentity',
> 'virNodeGetCPUMap',
> 'virDomainMigrate3',
> 'virDomainMigrateToURI3',
> diff --git a/libvirt-override.c b/libvirt-override.c
> index ff2cfdf..33f20d1 100644
> --- a/libvirt-override.c
> +++ b/libvirt-override.c
> @@ -10209,6 +10209,69 @@ libvirt_virDomainGetGuestInfo(PyObject *self ATTRIBUTE_UNUSED,
> }
> #endif /* LIBVIR_CHECK_VERSION(5, 7, 0) */
>
> +
> +#if LIBVIR_CHECK_VERSION(5, 8, 0)
> +static virPyTypedParamsHint virPyConnectSetIdentityParams[] = {
> + { VIR_CONNECT_IDENTITY_USER_NAME, VIR_TYPED_PARAM_STRING },
> + { VIR_CONNECT_IDENTITY_UNIX_USER_ID, VIR_TYPED_PARAM_ULLONG },
> + { VIR_CONNECT_IDENTITY_GROUP_NAME, VIR_TYPED_PARAM_STRING },
> + { VIR_CONNECT_IDENTITY_UNIX_GROUP_ID, VIR_TYPED_PARAM_ULLONG },
> + { VIR_CONNECT_IDENTITY_PROCESS_ID, VIR_TYPED_PARAM_LLONG },
> + { VIR_CONNECT_IDENTITY_PROCESS_TIME, VIR_TYPED_PARAM_ULLONG },
> + { VIR_CONNECT_IDENTITY_SASL_USER_NAME, VIR_TYPED_PARAM_STRING },
> + { VIR_CONNECT_IDENTITY_X509_DISTINGUISHED_NAME, VIR_TYPED_PARAM_STRING },
> + { VIR_CONNECT_IDENTITY_SELINUX_CONTEXT, VIR_TYPED_PARAM_STRING },
> +};
> +
> +static PyObject *
> +libvirt_virConnectSetIdentity(PyObject *self ATTRIBUTE_UNUSED,
> + PyObject *args)
> +{
> + virConnectPtr conn;
> + PyObject *pyobj_conn, *dict;
> + PyObject *ret = NULL;
> + int i_retval;
> + int nparams = 0;
> + Py_ssize_t size = 0;
> + unsigned int flags;
> + virTypedParameterPtr params = NULL, new_params = NULL;
> +
> + if (!PyArg_ParseTuple(args,
> + (char *)"OOI:virConnectSetIdentity",
> + &pyobj_conn, &dict, &flags))
> + return NULL;
> + conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
> +
> + if (!PyDict_Check(dict)) {
> + PyErr_Format(PyExc_TypeError, "migration params must be a dictionary");
> + return NULL;
> + }
> +
> + if (virPyDictToTypedParams(dict, ¶ms, &nparams,
> + virPyConnectSetIdentityParams,
> + VIR_N_ELEMENTS(virPyConnectSetIdentityParams)) < 0) {
> + return NULL;
> + }
> +
> + LIBVIRT_BEGIN_ALLOW_THREADS;
> + i_retval = virConnectSetIdentity(conn, new_params, size, flags);
> + LIBVIRT_END_ALLOW_THREADS;
> +
> + if (i_retval < 0) {
> + ret = VIR_PY_INT_FAIL;
> + goto cleanup;
> + }
> +
> + ret = VIR_PY_INT_SUCCESS;
> +
> + cleanup:
> + virTypedParamsFree(params, nparams);
> + virTypedParamsFree(new_params, size);
> + return ret;
> +}
> +#endif /* LIBVIR_CHECK_VERSION(5, 8, 0) */
> +
> +
> /************************************************************************
> * *
> * The registration stuff *
> @@ -10467,6 +10530,9 @@ static PyMethodDef libvirtMethods[] = {
> #if LIBVIR_CHECK_VERSION(5, 7, 0)
> {(char *) "virDomainGetGuestInfo", libvirt_virDomainGetGuestInfo, METH_VARARGS, NULL},
> #endif /* LIBVIR_CHECK_VERSION(5, 7, 0) */
> +#if LIBVIR_CHECK_VERSION(5, 8, 0)
> + {(char *) "virConnectSetIdentity", libvirt_virConnectSetIdentity, METH_VARARGS, NULL},
> +#endif /* LIBVIR_CHECK_VERSION(5, 8, 0) */
> {NULL, NULL, 0, NULL}
> };
>
> --
> 2.21.0
>
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
More information about the libvir-list
mailing list