From nobody Tue May 7 22:51:06 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1527779826728901.4221994251917; Thu, 31 May 2018 08:17:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B2DFB30BC132; Thu, 31 May 2018 15:17:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2C672309128B; Thu, 31 May 2018 15:17:04 +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 D7C944CA81; Thu, 31 May 2018 15:17:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4VFH02F008815 for ; Thu, 31 May 2018 11:17:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3DBCD210C6CE; Thu, 31 May 2018 15:17:00 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F41BC2023580 for ; Thu, 31 May 2018 15:16:59 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id F1F95103861; Thu, 31 May 2018 17:16:58 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 31 May 2018 17:16:51 +0200 Message-Id: <1c158208db2d833db6f65f2879bd13e1f17e4f28.1527779811.git.jdenemar@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [python PATCH] Add support for virConnectBaselineHypervisorCPU 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 31 May 2018 15:17:05 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The python bindings for this API cannot be generated because are generator is not capable of handling string arrays (char **) parameters. https://bugzilla.redhat.com/show_bug.cgi?id=3D1584676 Signed-off-by: Jiri Denemark Reviewed-by: J=EF=BF=BDn Tomko --- generator.py | 1 + libvirt-override-api.xml | 11 ++++++++ libvirt-override.c | 60 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/generator.py b/generator.py index a0fc720..b7d96a1 100755 --- a/generator.py +++ b/generator.py @@ -488,6 +488,7 @@ skip_impl =3D ( 'virDomainGetPerfEvents', 'virDomainSetPerfEvents', 'virDomainGetGuestVcpus', + 'virConnectBaselineHypervisorCPU', ) =20 lxc_skip_impl =3D ( diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml index b63a403..36d3577 100644 --- a/libvirt-override-api.xml +++ b/libvirt-override-api.xml @@ -717,5 +717,16 @@ + + Computes the most feature-rich CPU which is compatible with al= l given CPUs and can be provided by the specified hypervisor. + + + + + + + + + diff --git a/libvirt-override.c b/libvirt-override.c index b4c1529..1c95c18 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -9708,6 +9708,63 @@ libvirt_virStreamRecvFlags(PyObject *self ATTRIBUTE_= UNUSED, #endif /* LIBVIR_CHECK_VERSION(3, 4, 0) */ =20 =20 +#if LIBVIR_CHECK_VERSION(4, 4, 0) +static PyObject * +libvirt_virConnectBaselineHypervisorCPU(PyObject *self ATTRIBUTE_UNUSED, + PyObject *args) +{ + virConnectPtr conn; + PyObject *pyobj_conn; + char *emulator; + char *arch; + char *machine; + char *virttype; + PyObject *list; + unsigned int flags; + char **xmlCPUs =3D NULL; + int ncpus =3D 0; + size_t i; + char *cpu; + PyObject *ret =3D NULL; + + if (!PyArg_ParseTuple(args, (char *)"OzzzzOI:virConnectBaselineHypervi= sorCPU", + &pyobj_conn, &emulator, &arch, &machine, &virtty= pe, + &list, &flags)) + return NULL; + + conn =3D (virConnectPtr) PyvirConnect_Get(pyobj_conn); + + if (PyList_Check(list)) { + ncpus =3D PyList_Size(list); + if (VIR_ALLOC_N(xmlCPUs, ncpus) < 0) + return PyErr_NoMemory(); + + for (i =3D 0; i < ncpus; i++) { + if (libvirt_charPtrUnwrap(PyList_GetItem(list, i), + &(xmlCPUs[i])) < 0 || + !xmlCPUs[i]) + goto cleanup; + } + } + + LIBVIRT_BEGIN_ALLOW_THREADS; + cpu =3D virConnectBaselineHypervisorCPU(conn, emulator, arch, machine,= virttype, + (const char **)xmlCPUs, ncpus, f= lags); + LIBVIRT_END_ALLOW_THREADS; + + ret =3D libvirt_constcharPtrWrap(cpu); + + cleanup: + for (i =3D 0; i < ncpus; i++) + VIR_FREE(xmlCPUs[i]); + VIR_FREE(xmlCPUs); + VIR_FREE(cpu); + + return ret; +} +#endif /* LIBVIR_CHECK_VERSION(4, 4, 0) */ + + /************************************************************************ * * * The registration stuff * @@ -9941,6 +9998,9 @@ static PyMethodDef libvirtMethods[] =3D { {(char *) "virStreamSendHole", libvirt_virStreamSendHole, METH_VARARGS= , NULL}, {(char *) "virStreamRecvFlags", libvirt_virStreamRecvFlags, METH_VARAR= GS, NULL}, #endif /* LIBVIR_CHECK_VERSION(3, 4, 0) */ +#if LIBVIR_CHECK_VERSION(4, 4, 0) + {(char *) "virConnectBaselineHypervisorCPU", libvirt_virConnectBaselin= eHypervisorCPU, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(4, 4, 0) */ {NULL, NULL, 0, NULL} }; =20 --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list