From nobody Sun Apr 28 06:23:50 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152587894237165.55763900002489; Wed, 9 May 2018 08:15:42 -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 97E3667EDE; Wed, 9 May 2018 15:15:40 +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 DA1B861D03; Wed, 9 May 2018 15:15:39 +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 8CB0A4CAA1; Wed, 9 May 2018 15:15:38 +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 w49FFaKp007322 for ; Wed, 9 May 2018 11:15:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7873D1001645; Wed, 9 May 2018 15:15:36 +0000 (UTC) Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 709F810016C6 for ; Wed, 9 May 2018 15:15:34 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4C04E300441A for ; Wed, 9 May 2018 15:15:33 +0000 (UTC) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w49F0lB4105284 for ; Wed, 9 May 2018 11:15:32 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hv14cr683-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 09 May 2018 11:15:32 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 9 May 2018 16:15:25 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 9 May 2018 16:15:24 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w49FF0oC52559940 for ; Wed, 9 May 2018 15:15:23 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8AAB7DB29C for ; Wed, 9 May 2018 14:59:06 +0100 (BST) Received: from marc-ibm.boeblingen.de.ibm.com (unknown [9.152.224.71]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id D34AB5752C for ; Wed, 9 May 2018 14:48:31 +0100 (BST) From: Marc Hartmayer To: Date: Wed, 9 May 2018 16:57:31 +0200 X-TM-AS-GCONF: 00 x-cbid: 18050915-0044-0000-0000-00000550C5E6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18050915-0045-0000-0000-000028920E95 Message-Id: <20180509145731.23311-1-mhartmay@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-05-09_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805090139 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 09 May 2018 15:15:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 09 May 2018 15:15:33 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'mhartmay@linux.vnet.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.44 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH python] Implement virDomainCreateWithParams API 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 09 May 2018 15:15:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch adds the Python binding for virDomainCreateWithParams API. The Python side can be generated automatically, the C side not. Signed-off-by: Marc Hartmayer Reviewed-by: Boris Fiuczynski --- generator.py | 1 + libvirt-override-api.xml | 19 ++++++++++++++++ libvirt-override.c | 57 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 77 insertions(+) diff --git a/generator.py b/generator.py index 74150b72388f..9d12218a0aef 100755 --- a/generator.py +++ b/generator.py @@ -488,6 +488,7 @@ skip_impl =3D ( 'virDomainGetPerfEvents', 'virDomainSetPerfEvents', 'virDomainGetGuestVcpus', + 'virDomainCreateWithParams', ) =20 lxc_skip_impl =3D ( diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml index b63a40378437..34af14df0a62 100644 --- a/libvirt-override-api.xml +++ b/libvirt-override-api.xml @@ -717,5 +717,24 @@ + + Launch a defined domain. If the call succeeds the domain moves +from the defined to the running domains pools. + +@params provides a dictionary. This dictionary will be used to +configure the domain to be temporary started from the device +specified by the value of the key 'bootdevice'. With the values +of the keys 'kernel', 'initrd', and 'cmdline' it's possible to +temporarily override the corresponding values. The dictionary +and all dictionary items are optional. + +For more control over @flags, see createWithFlags(). + +Returns 0 in case of success, -1 in case of error + + + + + diff --git a/libvirt-override.c b/libvirt-override.c index b4c1529f621d..2a4e91d640df 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -9708,6 +9708,60 @@ libvirt_virStreamRecvFlags(PyObject *self ATTRIBUTE_= UNUSED, #endif /* LIBVIR_CHECK_VERSION(3, 4, 0) */ =20 =20 +#if LIBVIR_CHECK_VERSION(4, 4, 0) +static virPyTypedParamsHint virPyDomainCreateWithParams[] =3D { + { VIR_DOMAIN_CREATE_PARM_KERNEL, VIR_TYPED_PARAM_STRING }, + { VIR_DOMAIN_CREATE_PARM_CMDLINE, VIR_TYPED_PARAM_STRING }, + { VIR_DOMAIN_CREATE_PARM_INITRD, VIR_TYPED_PARAM_STRING }, + { VIR_DOMAIN_CREATE_PARM_DEVICE_IDENTIFIER, VIR_TYPED_PARAM_STRING }, +}; + + +static PyObject * +libvirt_virDomainCreateWithParams(PyObject *self ATTRIBUTE_UNUSED, + PyObject *args) +{ + PyObject *pyobj_domain; + PyObject *pyobj_dict; + virDomainPtr domain; + int nparams; + virTypedParameterPtr params; + unsigned int flags; + int c_retval; + + if (!PyArg_ParseTuple(args, (char *)"OOI:virDomainCreateWithParams", + &pyobj_domain, &pyobj_dict, &flags)) + return NULL; + domain =3D (virDomainPtr) PyvirDomain_Get(pyobj_domain); + + if (PyDict_Check(pyobj_dict)) { + if (virPyDictToTypedParams(pyobj_dict, ¶ms, &nparams, + virPyDomainCreateWithParams, + VIR_N_ELEMENTS(virPyDomainCreateWithPar= ams)) < 0) { + return NULL; + } + } else if (pyobj_dict =3D=3D Py_None) { + /* Since 'None' is a Singleton, testing for object identity is + * sufficient */ + params =3D NULL; + nparams =3D 0; + } else { + PyErr_SetString(PyExc_ValueError, + "Only dictionaries or None arguments" + " are allowed for the parameter 'params'"); + return NULL; + } + + LIBVIRT_BEGIN_ALLOW_THREADS; + c_retval =3D virDomainCreateWithParams(domain, params, nparams, flags); + LIBVIRT_END_ALLOW_THREADS; + + virTypedParamsFree(params, nparams); + return libvirt_intWrap(c_retval); +} +#endif /* LIBVIR_CHECK_VERSION(4, 4, 0) */ + + /************************************************************************ * * * The registration stuff * @@ -9941,6 +9995,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 *) "virDomainCreateWithParams", libvirt_virDomainCreateWithPara= ms, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(4, 4, 0) */ {NULL, NULL, 0, NULL} }; =20 --=20 2.13.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list