Skip to content

Commit

Permalink
Custom impl for virConnectSetIdentity which can't be generated
Browse files Browse the repository at this point in the history
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
  • Loading branch information
berrange committed Sep 20, 2019
1 parent d76c27e commit 873e0ca
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
1 change: 1 addition & 0 deletions generator.py
Expand Up @@ -489,6 +489,7 @@ def qemu_enum(type, name, value):
'virDomainGetDiskErrors',
'virNodeGetMemoryParameters',
'virNodeSetMemoryParameters',
'virConnectSetIdentity',
'virNodeGetCPUMap',
'virDomainMigrate3',
'virDomainMigrateToURI3',
Expand Down
7 changes: 7 additions & 0 deletions libvirt-override-api.xml
Expand Up @@ -796,5 +796,12 @@
<arg name='types' type='int' info='optional binary-OR of virDomainGuestInfoTypes'/>
<arg name='flags' type='int' info='unused, always pass 0'/>
</function>
<function name='virConnectSetIdentity' file='libvirt-host' module='libvirt-host'>
<info>Override the default identity information associated with the connection.</info>
<return type='int' info='0 if the identity change was accepted, -1 on error'/>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
<arg name='params' type='virTypedParameterPtr' info='parameters containing the identity attributes'/>
<arg name='flags' type='unsigned int' info='currently unused, pass 0'/>
</function>
</symbols>
</api>
64 changes: 64 additions & 0 deletions libvirt-override.c
Expand Up @@ -10222,6 +10222,67 @@ 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;
unsigned int flags;
virTypedParameterPtr 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, params, nparams, 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);
return ret;
}
#endif /* LIBVIR_CHECK_VERSION(5, 8, 0) */


/************************************************************************
* *
* The registration stuff *
Expand Down Expand Up @@ -10480,6 +10541,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}
};

Expand Down

0 comments on commit 873e0ca

Please sign in to comment.