From nobody Sun May 5 03:51: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=1568975341; cv=none; d=zoho.com; s=zohoarc; b=TVjdFL8x0fdvSRTUlLj4xZmCa8QYAAxPxsemmFe/b8kgzf4Z2f52AfeOTajDwy84laVSQea9r+60uoC72TAtnPH6yEtfn9CFMvF1Y0ALRct/s+Fb50j+rs5e+gwFqxYnw+S6jRe9kV11dQmewX3HXnNtcL3FD055xZzhjjkAlrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568975341; h=Content-Type:Content-Transfer-Encoding:Cc: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=046LVdQAiyvJao+IARcSp9kLbPa+YJNcRXtscdk4MEc=; b=T65O6kSxkmqpeVVvXSk9MwBEWKbr2ZZTqUz8FaAFIp2oQ0fv6b7R2o2NNzJDI98k0K/mP+YqNcNkRIXTGdzGzm6Jz9BtnCUA32WUosSwFC3eltA3b64ldOsI0DAArmg38/teZaVOd/uHEnwEbiXzbCuU5bY7zunFRlbBOBD45+c= 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 1568975341858175.93603381621153; Fri, 20 Sep 2019 03:29:01 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D5FA530A7B8A; Fri, 20 Sep 2019 10:28:59 +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 981785D6B0; Fri, 20 Sep 2019 10:28:59 +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 3FDEA1800B74; Fri, 20 Sep 2019 10:28:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8KASnWi030690 for ; Fri, 20 Sep 2019 06:28:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 834695C226; Fri, 20 Sep 2019 10:28:49 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.112.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13AC95C21E; Fri, 20 Sep 2019 10:28:44 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Fri, 20 Sep 2019 11:28:40 +0100 Message-Id: <20190920102840.24833-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Pavel Hrdina Subject: [libvirt] [PATCH python v2] 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 20 Sep 2019 10:29:00 +0000 (UTC) Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- generator.py | 1 + libvirt-override-api.xml | 7 +++++ libvirt-override.c | 64 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 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-api.xml b/libvirt-override-api.xml index b2a6259..7a0d4c5 100644 --- a/libvirt-override-api.xml +++ b/libvirt-override-api.xml @@ -796,5 +796,12 @@ + + Override the default identity information associated with the = connection. + + + + + diff --git a/libvirt-override.c b/libvirt-override.c index ff2cfdf..72edca9 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -10209,6 +10209,67 @@ 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; + unsigned int flags; + virTypedParameterPtr 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, params, nparams, 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); + return ret; +} +#endif /* LIBVIR_CHECK_VERSION(5, 8, 0) */ + + /************************************************************************ * * * The registration stuff * @@ -10467,6 +10528,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