From nobody Wed Nov 27 14:25:13 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 1542733994226445.04714252007614; Tue, 20 Nov 2018 09:13:14 -0800 (PST) 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 C3BD43DBC2; Tue, 20 Nov 2018 17:13:11 +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 4E4F8A63D7; Tue, 20 Nov 2018 17:13:11 +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 EA57D3F605; Tue, 20 Nov 2018 17:13:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAKHDAcb020973 for ; Tue, 20 Nov 2018 12:13:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6A74818F02; Tue, 20 Nov 2018 17:13:09 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-117-6.phx2.redhat.com [10.3.117.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 522AD18B5E for ; Tue, 20 Nov 2018 17:13:07 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 20 Nov 2018 12:13:03 -0500 Message-Id: <20181120171304.16697-2-jferlan@redhat.com> In-Reply-To: <20181120171304.16697-1-jferlan@redhat.com> References: <20181120171304.16697-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/2] Add check for params, nparams being a dictionary 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.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.30]); Tue, 20 Nov 2018 17:13:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" If PyDict_Check fails, we should force an error rather than blindly continuing on. Signed-off-by: John Ferlan Reviewed-by: Pavel Hrdina --- libvirt-override.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index 0353306..8748101 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -7861,6 +7861,11 @@ libvirt_virDomainMigrate3(PyObject *self ATTRIBUTE_U= NUSED, domain =3D (virDomainPtr) PyvirDomain_Get(pyobj_domain); dconn =3D (virConnectPtr) PyvirConnect_Get(pyobj_dconn); =20 + if (!PyDict_Check(dict)) { + PyErr_Format(PyExc_TypeError, "migration params must be a dictiona= ry"); + return NULL; + } + if (virPyDictToTypedParams(dict, ¶ms, &nparams, virPyDomainMigrate3Params, VIR_N_ELEMENTS(virPyDomainMigrate3Params)) = < 0) { @@ -7894,6 +7899,11 @@ libvirt_virDomainMigrateToURI3(PyObject *self ATTRIB= UTE_UNUSED, =20 domain =3D (virDomainPtr) PyvirDomain_Get(pyobj_domain); =20 + if (!PyDict_Check(dict)) { + PyErr_Format(PyExc_TypeError, "migration params must be a dictiona= ry"); + return NULL; + } + if (virPyDictToTypedParams(dict, ¶ms, &nparams, virPyDomainMigrate3Params, VIR_N_ELEMENTS(virPyDomainMigrate3Params)) = < 0) { @@ -8776,6 +8786,9 @@ libvirt_virDomainBlockCopy(PyObject *self ATTRIBUTE_U= NUSED, VIR_N_ELEMENTS(virPyDomainBlockCopyPara= ms)) < 0) { return NULL; } + } else { + PyErr_Format(PyExc_TypeError, "block params must be a dictionary"); + return NULL; } =20 dom =3D (virDomainPtr) PyvirDomain_Get(pyobj_dom); --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed Nov 27 14:25:13 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 1542733997729704.8399957328749; Tue, 20 Nov 2018 09:13:17 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3226A539D8; Tue, 20 Nov 2018 17:13:15 +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 E46AD272CA; Tue, 20 Nov 2018 17:13:14 +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 8C2E63F607; Tue, 20 Nov 2018 17:13:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAKHDBWa020981 for ; Tue, 20 Nov 2018 12:13:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id CCE3F83893; Tue, 20 Nov 2018 17:13:09 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-117-6.phx2.redhat.com [10.3.117.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BF916012B for ; Tue, 20 Nov 2018 17:13:09 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 20 Nov 2018 12:13:04 -0500 Message-Id: <20181120171304.16697-3-jferlan@redhat.com> In-Reply-To: <20181120171304.16697-1-jferlan@redhat.com> References: <20181120171304.16697-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/2] Implement API binding for virDomainSetIOThreadParams 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 20 Nov 2018 17:13:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Similar to libvirt_virDomainBlockCopy (and migration API's). Create the code for the new API. Signed-off-by: John Ferlan Reviewed-by: Pavel Hrdina --- generator.py | 1 + libvirt-override-api.xml | 8 ++++++ libvirt-override.c | 54 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/generator.py b/generator.py index bd7ff11..6cb923f 100755 --- a/generator.py +++ b/generator.py @@ -440,6 +440,7 @@ skip_impl =3D ( 'virDomainPinEmulator', 'virDomainGetIOThreadInfo', 'virDomainPinIOThread', + 'virDomainSetIOThreadParams', 'virSecretGetValue', 'virSecretSetValue', 'virSecretGetUUID', diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml index 4e8d6c0..7f578e0 100644 --- a/libvirt-override-api.xml +++ b/libvirt-override-api.xml @@ -292,6 +292,14 @@ + + Dynamically allow changing the IOThread polling related parame= ters. This function requires privileged access to the hypervisor. + + + + + + Change the scheduler parameters diff --git a/libvirt-override.c b/libvirt-override.c index 8748101..349ac63 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -1679,6 +1679,57 @@ libvirt_virDomainPinIOThread(PyObject *self ATTRIBUT= E_UNUSED, =20 #endif /* LIBVIR_CHECK_VERSION(1, 2, 14) */ =20 +#if LIBVIR_CHECK_VERSION(4, 10, 4) + +static virPyTypedParamsHint virPyDomainSetIOThreadParams[] =3D { + { VIR_DOMAIN_IOTHREAD_POLL_MAX_NS, VIR_TYPED_PARAM_ULLONG }, + { VIR_DOMAIN_IOTHREAD_POLL_GROW, VIR_TYPED_PARAM_UINT }, + { VIR_DOMAIN_IOTHREAD_POLL_SHRINK, VIR_TYPED_PARAM_ULLONG }, +}; + +static PyObject * +libvirt_virDomainSetIOThreadParams(PyObject *self ATTRIBUTE_UNUSED, + PyObject *args) +{ + PyObject *pyobj_dom =3D NULL; + PyObject *pyobj_dict =3D NULL; + + virDomainPtr dom; + int iothread_val; + virTypedParameterPtr params =3D NULL; + int nparams =3D 0; + unsigned int flags; + int c_retval; + + if (!PyArg_ParseTuple(args, (char *)"OiOI:virDomainSetIOThreadParams", + &pyobj_dom, &iothread_val, &pyobj_dict, &flags)) + return NULL; + + if (PyDict_Check(pyobj_dict)) { + if (virPyDictToTypedParams(pyobj_dict, ¶ms, &nparams, + virPyDomainSetIOThreadParams, + VIR_N_ELEMENTS(virPyDomainSetIOThreadPa= rams)) < 0) { + return NULL; + } + } else { + PyErr_Format(PyExc_TypeError, "IOThread polling params must be " + "a dictionary"); + return NULL; + } + + dom =3D (virDomainPtr) PyvirDomain_Get(pyobj_dom); + + LIBVIRT_BEGIN_ALLOW_THREADS; + c_retval =3D virDomainSetIOThreadParams(dom, iothread_val, + params, nparams, flags); + LIBVIRT_END_ALLOW_THREADS; + + virTypedParamsFree(params, nparams); + + return libvirt_intWrap(c_retval); +} +#endif /* LIBVIR_CHECK_VERSION(4, 10, 0) */ + /************************************************************************ * * * Global error handler at the Python level * @@ -9988,6 +10039,9 @@ static PyMethodDef libvirtMethods[] =3D { {(char *) "virDomainGetIOThreadInfo", libvirt_virDomainGetIOThreadInfo= , METH_VARARGS, NULL}, {(char *) "virDomainPinIOThread", libvirt_virDomainPinIOThread, METH_V= ARARGS, NULL}, #endif /* LIBVIR_CHECK_VERSION(1, 2, 14) */ +#if LIBVIR_CHECK_VERSION(4, 10, 4) + {(char *) "virDomainSetIOThreadParams", libvirt_virDomainSetIOThreadPa= rams, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(4, 10, 0) */ {(char *) "virConnectListStoragePools", libvirt_virConnectListStorageP= ools, METH_VARARGS, NULL}, {(char *) "virConnectListDefinedStoragePools", libvirt_virConnectListD= efinedStoragePools, METH_VARARGS, NULL}, #if LIBVIR_CHECK_VERSION(0, 10, 2) --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list