Re: [libvirt] [PATCH v4 6/7] add python module support Add virDomainQemuAgentCommand() support function to python module.

2012-08-23 Thread Daniel Veillard
On Thu, Aug 23, 2012 at 12:29:26PM +0900, MATSUDA Daiki wrote:
 
 Signed-off-by: MATSUDA Daiki matsuda...@intellilink.co.jp
 ---
  python/libvirt-qemu-override-api.xml |8 
  python/libvirt-qemu-override.c   |   29 +
  2 files changed, 37 insertions(+), 0 deletions(-)
 
 diff --git a/python/libvirt-qemu-override-api.xml 
 b/python/libvirt-qemu-override-api.xml
 index d69acea..ca0dae9 100644
 --- a/python/libvirt-qemu-override-api.xml
 +++ b/python/libvirt-qemu-override-api.xml
 @@ -8,5 +8,13 @@
  arg name='cmd' type='const char *' info='the command which will be 
 passed to QEMU monitor'/
  arg name='flags' type='unsigned int' info='an ORapos;ed set of 
 virDomainQemuMonitorCommandFlags'/
/function
 +  function name='virDomainQemuAgentCommand' file='python-qemu'
 +infoSend a Guest Agent command to domain/info
 +return type='str *' info='the command output'/
 +arg name='domain' type='virDomainPtr' info='pointer to the domain'/
 +arg name='cmd' type='const char *' info='guest agent command on 
 domain'/
 +arg name='timeout' type='int' info='timeout seconds'/
 +arg name='flags' type='unsigned int' info='execution flags'/
 +  /function
/symbols
  /api
 diff --git a/python/libvirt-qemu-override.c b/python/libvirt-qemu-override.c
 index e532416..243692a 100644
 --- a/python/libvirt-qemu-override.c
 +++ b/python/libvirt-qemu-override.c
 @@ -82,6 +82,34 @@ libvirt_qemu_virDomainQemuMonitorCommand(PyObject *self 
 ATTRIBUTE_UNUSED,
  return py_retval;
  }
  
 +static PyObject *
 +libvirt_qemu_virDomainQemuAgentCommand(PyObject *self ATTRIBUTE_UNUSED, 
 PyObject *args)
 +{
 +PyObject *py_retval;
 +char *result = NULL;
 +virDomainPtr domain;
 +PyObject *pyobj_domain;
 +int timeout;
 +unsigned int flags;
 +char *cmd;
 +
 +if (!PyArg_ParseTuple(args, (char *)Ozii:virDomainQemuAgentCommand,
 +  pyobj_domain, cmd, timeout, flags))
 +return NULL;
 +domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
 +
 +if (domain == NULL)
 +return VIR_PY_NONE;
 +LIBVIRT_BEGIN_ALLOW_THREADS;
 +result = virDomainQemuAgentCommand(domain, cmd, timeout, flags);
 +LIBVIRT_END_ALLOW_THREADS;
 +
 +if (!result)
 +return VIR_PY_NONE;
 +
 +py_retval = PyString_FromString(result);
 +return py_retval;
 +}


  i agree to have a simple string returned back at the condition that
we add error support by raising an exception from the C code (I don't
remember how to do this) otherwise we have no way to report an error
with the python API as-is,

   *   *
   *   The registration stuff  *
 @@ -90,6 +118,7 @@ libvirt_qemu_virDomainQemuMonitorCommand(PyObject *self 
 ATTRIBUTE_UNUSED,
  static PyMethodDef libvirtQemuMethods[] = {
  #include libvirt-qemu-export.c
  {(char *) virDomainQemuMonitorCommand, 
 libvirt_qemu_virDomainQemuMonitorCommand, METH_VARARGS, NULL},
 +{(char *) virDomainQemuAgentCommand, 
 libvirt_qemu_virDomainQemuAgentCommand, METH_VARARGS, NULL},
  {NULL, NULL, 0, NULL}
  };
  

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


[libvirt] [PATCH v4 6/7] add python module support Add virDomainQemuAgentCommand() support function to python module.

2012-08-22 Thread MATSUDA Daiki

Signed-off-by: MATSUDA Daiki matsuda...@intellilink.co.jp
---
 python/libvirt-qemu-override-api.xml |8 
 python/libvirt-qemu-override.c   |   29 +
 2 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/python/libvirt-qemu-override-api.xml 
b/python/libvirt-qemu-override-api.xml
index d69acea..ca0dae9 100644
--- a/python/libvirt-qemu-override-api.xml
+++ b/python/libvirt-qemu-override-api.xml
@@ -8,5 +8,13 @@
 arg name='cmd' type='const char *' info='the command which will be 
passed to QEMU monitor'/
 arg name='flags' type='unsigned int' info='an ORapos;ed set of 
virDomainQemuMonitorCommandFlags'/
   /function
+  function name='virDomainQemuAgentCommand' file='python-qemu'
+infoSend a Guest Agent command to domain/info
+return type='str *' info='the command output'/
+arg name='domain' type='virDomainPtr' info='pointer to the domain'/
+arg name='cmd' type='const char *' info='guest agent command on 
domain'/
+arg name='timeout' type='int' info='timeout seconds'/
+arg name='flags' type='unsigned int' info='execution flags'/
+  /function
   /symbols
 /api
diff --git a/python/libvirt-qemu-override.c b/python/libvirt-qemu-override.c
index e532416..243692a 100644
--- a/python/libvirt-qemu-override.c
+++ b/python/libvirt-qemu-override.c
@@ -82,6 +82,34 @@ libvirt_qemu_virDomainQemuMonitorCommand(PyObject *self 
ATTRIBUTE_UNUSED,
 return py_retval;
 }
 
+static PyObject *
+libvirt_qemu_virDomainQemuAgentCommand(PyObject *self ATTRIBUTE_UNUSED, 
PyObject *args)
+{
+PyObject *py_retval;
+char *result = NULL;
+virDomainPtr domain;
+PyObject *pyobj_domain;
+int timeout;
+unsigned int flags;
+char *cmd;
+
+if (!PyArg_ParseTuple(args, (char *)Ozii:virDomainQemuAgentCommand,
+  pyobj_domain, cmd, timeout, flags))
+return NULL;
+domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+if (domain == NULL)
+return VIR_PY_NONE;
+LIBVIRT_BEGIN_ALLOW_THREADS;
+result = virDomainQemuAgentCommand(domain, cmd, timeout, flags);
+LIBVIRT_END_ALLOW_THREADS;
+
+if (!result)
+return VIR_PY_NONE;
+
+py_retval = PyString_FromString(result);
+return py_retval;
+}
 /
  * *
  * The registration stuff  *
@@ -90,6 +118,7 @@ libvirt_qemu_virDomainQemuMonitorCommand(PyObject *self 
ATTRIBUTE_UNUSED,
 static PyMethodDef libvirtQemuMethods[] = {
 #include libvirt-qemu-export.c
 {(char *) virDomainQemuMonitorCommand, 
libvirt_qemu_virDomainQemuMonitorCommand, METH_VARARGS, NULL},
+{(char *) virDomainQemuAgentCommand, 
libvirt_qemu_virDomainQemuAgentCommand, METH_VARARGS, NULL},
 {NULL, NULL, 0, NULL}
 };
 
-- 
1.7.1

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