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 <mhart...@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiu...@linux.ibm.com>
---
 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 = (
     'virDomainGetPerfEvents',
     'virDomainSetPerfEvents',
     'virDomainGetGuestVcpus',
+    'virDomainCreateWithParams',
 )
 
 lxc_skip_impl = (
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 @@
       <arg name='flags' type='unsigned int' info='extra flags; not used yet, 
so callers should always pass 0'/>
       <return type='int' info="dictionary of vcpu data returned by the guest 
agent"/>
     </function>
+    <function name='virDomainCreateWithParams' file='python'>
+      <info>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</info>
+      <arg name='domain' type='virDomainPtr' info='a domain object'/>
+      <arg name='params' type='char *' info='dictionary with parameters'/>
+      <arg name='flags' type='unsigned int' info='an OR&apos;ed set of 
virDomainCreateFlags'/>
+      <return type='int' info='0 on success, -1 on error'/>
+    </function>
   </symbols>
 </api>
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) */
 
 
+#if LIBVIR_CHECK_VERSION(4, 4, 0)
+static virPyTypedParamsHint virPyDomainCreateWithParams[] = {
+    { 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 = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+    if (PyDict_Check(pyobj_dict)) {
+        if (virPyDictToTypedParams(pyobj_dict, &params, &nparams,
+                                   virPyDomainCreateWithParams,
+                                   
VIR_N_ELEMENTS(virPyDomainCreateWithParams)) < 0) {
+            return NULL;
+        }
+    } else if (pyobj_dict == Py_None) {
+        /* Since 'None' is a Singleton, testing for object identity is
+         * sufficient */
+        params = NULL;
+        nparams = 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 = 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[] = {
     {(char *) "virStreamSendHole", libvirt_virStreamSendHole, METH_VARARGS, 
NULL},
     {(char *) "virStreamRecvFlags", libvirt_virStreamRecvFlags, METH_VARARGS, 
NULL},
 #endif /* LIBVIR_CHECK_VERSION(3, 4, 0) */
+#if LIBVIR_CHECK_VERSION(4, 4, 0)
+    {(char *) "virDomainCreateWithParams", libvirt_virDomainCreateWithParams, 
METH_VARARGS, NULL},
+#endif /* LIBVIR_CHECK_VERSION(4, 4, 0) */
     {NULL, NULL, 0, NULL}
 };
 
-- 
2.13.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to