Re: [PATCH python] Custom impl for virConnectSetIdentity which can't be generated

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 16, 2019 at 05:37:43PM +0100, Daniel P. Berrangé wrote:
> Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
> ---
>  generator.py       |  1 +
>  libvirt-override.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 67 insertions(+)

This is missing XML description in libvirt-override-api.xml.

> 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, &params, &nparams,
> +                               virPyConnectSetIdentityParams,
> +                               VIR_N_ELEMENTS(virPyConnectSetIdentityParams)) < 0) {
> +        return NULL;
> +    }
> +
> +    LIBVIRT_BEGIN_ALLOW_THREADS;
> +    i_retval = virConnectSetIdentity(conn, new_params, size, flags);

This is strange, new_params are NULL as they are not used at all,
instead you are filling params.  It feels like new_params and size are
not required at all.

Otherwise looks good.

Pavel

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux