From nobody Mon Apr 29 01:50:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568651886; cv=none; d=zoho.com; s=zohoarc; b=O3XbJhG+LwQItKkdi8vTZAXoIrXp40bx16v1qqHNQDLibs+T0w/r8hMTEdjocJLTPX6RqUnyEmYzja0eyYujlWAeSTkDHU1SdysSoVkSxbQN1ns5EeSsdQdZC0Cc+CoDccMPSLImv+KqInWOb0dFvoHzjPG9O8VMRJ471H8RekI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568651886; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=MPZMJTwiSfISyHXfTlfE4TmYTAVaBEvDQXBveOP/miI=; b=SMq7FtNICMdUoxcmz0cJfXXNdLQDDCN3vV2GxiW7qI6SkQEaFKU4zEqaYhd6ESGn+1BRVmsBvloRRLcBT98JbbFkIMPCrSt2DpMqLCoI23P42hd2xoEv5gCpkq0oGlHi+BP4efg9J2pKnLV30dyY7PHNhsErfD8UJhzq9tiLqps= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568651886809991.3695344216184; Mon, 16 Sep 2019 09:38:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DE521A26662; Mon, 16 Sep 2019 16:38:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7FE6A5C1D6; Mon, 16 Sep 2019 16:38:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A7DD61803518; Mon, 16 Sep 2019 16:37:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8GGbuJc008809 for ; Mon, 16 Sep 2019 12:37:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 76B14101E683; Mon, 16 Sep 2019 16:37:56 +0000 (UTC) Received: from dhcp-17-64.lcy.redhat.com (unknown [10.42.17.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7141101E678; Mon, 16 Sep 2019 16:37:45 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Mon, 16 Sep 2019 17:37:43 +0100 Message-Id: <20190916163743.25527-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH python] Custom impl for virConnectSetIdentity which can't be generated X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Mon, 16 Sep 2019 16:38:05 +0000 (UTC) Signed-off-by: Daniel P. Berrang=C3=A9 --- 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 =3D ( '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 ATTRI= BUTE_UNUSED, } #endif /* LIBVIR_CHECK_VERSION(5, 7, 0) */ =20 + +#if LIBVIR_CHECK_VERSION(5, 8, 0) +static virPyTypedParamsHint virPyConnectSetIdentityParams[] =3D { + { 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 =3D NULL; + int i_retval; + int nparams =3D 0; + Py_ssize_t size =3D 0; + unsigned int flags; + virTypedParameterPtr params =3D NULL, new_params =3D NULL; + + if (!PyArg_ParseTuple(args, + (char *)"OOI:virConnectSetIdentity", + &pyobj_conn, &dict, &flags)) + return NULL; + conn =3D (virConnectPtr) PyvirConnect_Get(pyobj_conn); + + if (!PyDict_Check(dict)) { + PyErr_Format(PyExc_TypeError, "migration params must be a dictiona= ry"); + return NULL; + } + + if (virPyDictToTypedParams(dict, ¶ms, &nparams, + virPyConnectSetIdentityParams, + VIR_N_ELEMENTS(virPyConnectSetIdentityParam= s)) < 0) { + return NULL; + } + + LIBVIRT_BEGIN_ALLOW_THREADS; + i_retval =3D virConnectSetIdentity(conn, new_params, size, flags); + LIBVIRT_END_ALLOW_THREADS; + + if (i_retval < 0) { + ret =3D VIR_PY_INT_FAIL; + goto cleanup; + } + + ret =3D 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[] =3D { #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} }; =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list