[PATCH libvirt-python v2] Implement virDomainGetStateParams API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Marc Hartmayer <mhartmay@xxxxxxxxxxxxx>

This patch adds the Python binding for the virDomainGetStateParams API.
The Python side can be generated automatically, the C side cannot.

Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>
Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxx>
Signed-off-by: Bjoern Walk <bwalk@xxxxxxxxxxxxx>
---
Patch series for libvirt is here:

    https://www.redhat.com/archives/libvir-list/2019-March/msg01648.html

 generator.py             |  1 +
 libvirt-override-api.xml |  6 +++++
 libvirt-override.c       | 48 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+)

diff --git a/generator.py b/generator.py
index ffa3ce56..005be502 100755
--- a/generator.py
+++ b/generator.py
@@ -496,6 +496,7 @@ skip_impl = (
     'virConnectBaselineHypervisorCPU',
     'virDomainGetLaunchSecurityInfo',
     'virNodeGetSEVInfo',
+    'virDomainGetStateParams',
 )
 
 lxc_skip_impl = (
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index 7f578e01..fab62447 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -754,5 +754,11 @@
       <arg name='conn' type='virConnectPtr' info='pointer to hypervisor connection'/>
       <arg name='flags' type='int' info='unused, always pass 0'/>
     </function>
+    <function name='virDomainGetStateParams' file='python'>
+      <info>Extract domain state and additional information (if available).</info>
+      <arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
+      <arg name='flags' type='unsigned int' info='extra flags; not used yet, so callers should always pass 0'/>
+      <return type='char *' info="dictionary of state data"/>
+    </function>
   </symbols>
 </api>
diff --git a/libvirt-override.c b/libvirt-override.c
index c5e2908c..7ae10874 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -9946,6 +9946,51 @@ libvirt_virNodeGetSEVInfo(PyObject *self ATTRIBUTE_UNUSED,
 #endif /* LIBVIR_CHECK_VERSION(4, 5, 0) */
 
 
+#if LIBVIR_CHECK_VERSION(5, 2, 0)
+static PyObject *
+libvirt_virDomainGetStateParams(PyObject *self ATTRIBUTE_UNUSED,
+                                PyObject *args)
+{
+    PyObject *py_retval = VIR_PY_NONE;
+    PyObject *pyobj_domain;
+    virDomainPtr domain;
+    int state;
+    int reason;
+    virTypedParameterPtr params = NULL;
+    int nparams = 0;
+    unsigned int flags;
+    int c_retval;
+
+    if (!PyArg_ParseTuple(args, (char *)"OI:virDomainGetStateParams",
+                          &pyobj_domain, &flags))
+        return NULL;
+    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+    LIBVIRT_BEGIN_ALLOW_THREADS;
+    c_retval = virDomainGetStateParams(domain, &state, &reason, &params,
+				       &nparams, flags);
+    LIBVIRT_END_ALLOW_THREADS;
+
+    if (c_retval < 0)
+        goto error;
+
+    if ((py_retval = PyTuple_New(3)) == NULL)
+	goto error;
+
+    VIR_PY_TUPLE_SET_GOTO(py_retval, 0, libvirt_intWrap(state), error);
+    VIR_PY_TUPLE_SET_GOTO(py_retval, 1, libvirt_intWrap(reason), error);
+    VIR_PY_TUPLE_SET_GOTO(py_retval, 2, getPyVirTypedParameter(params, nparams), error);
+
+    return py_retval;
+
+error:
+    Py_XDECREF(py_retval);
+    virTypedParamsFree(params, nparams);
+    return VIR_PY_NONE;
+}
+#endif /* LIBVIR_CHECK_VERSION(5, 2, 0) */
+
+
 /************************************************************************
  *									*
  *			The registration stuff				*
@@ -10192,6 +10237,9 @@ static PyMethodDef libvirtMethods[] = {
     {(char *) "virDomainGetLaunchSecurityInfo", libvirt_virDomainGetLaunchSecurityInfo, METH_VARARGS, NULL},
     {(char *) "virNodeGetSEVInfo", libvirt_virNodeGetSEVInfo, METH_VARARGS, NULL},
 #endif /* LIBVIR_CHECK_VERSION(4, 5, 0) */
+#if LIBVIR_CHECK_VERSION(5, 2, 0)
+    {(char *) "virDomainGetStateParams", libvirt_virDomainGetStateParams, METH_VARARGS, NULL},
+#endif /* LIBVIR_CHECK_VERSION(5, 2, 0) */
     {NULL, NULL, 0, NULL}
 };
 
-- 
2.17.0

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux