[PATCH] python: Expose memoryPeek to Python binding

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

 



---
 python/libvirt-override-api.xml |    8 ++++++++
 python/libvirt-override.c       |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml
index 87db67b..2e0c7cb 100644
--- a/python/libvirt-override-api.xml
+++ b/python/libvirt-override-api.xml
@@ -414,5 +414,13 @@
       <arg name='flags' type='unsigned int' info='unused, always passed 0'/>
       <return type='char *' info='the returned buffer or None in case of error'/>
     </function>
+    <function name='virDomainMemoryPeek' file='python'>
+      <info>Read the contents of domain's memory</info>
+      <arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
+      <arg name='start' type='unsigned long long' info='start of memory to peek'/>
+      <arg name='size' type='size_t' info='size of memory to peek'/>
+      <arg name='flags' type='unsigned int' info='an OR&apos;ed set of virDomainMemoryFlags'/>
+      <return type='char *' info='the returned buffer or None in case of error'/>
+    </function>
   </symbols>
 </api>
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 4839e08..032cc47 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -5051,6 +5051,38 @@ libvirt_virDomainBlockPeek(PyObject *self ATTRIBUTE_UNUSED,
     return py_retval;
 }
 
+static PyObject *
+libvirt_virDomainMemoryPeek(PyObject *self ATTRIBUTE_UNUSED,
+                            PyObject *args) {
+    PyObject *py_retval;
+    int c_retval;
+    virDomainPtr domain;
+    PyObject *pyobj_domain;
+    unsigned long long start;
+    size_t size;
+    char *buf;
+    unsigned int flags;
+
+    if (!PyArg_ParseTuple(args, (char *)"OLni:virDomainMemoryPeek", &pyobj_domain,
+                          &start, &size, &flags))
+        return(NULL);
+
+    domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+    if ((buf = malloc(size)) == NULL)
+        return VIR_PY_NONE;
+
+    LIBVIRT_BEGIN_ALLOW_THREADS;
+    c_retval = virDomainMemoryPeek(domain, start, size, buf, flags);
+    LIBVIRT_END_ALLOW_THREADS;
+
+    if (c_retval < 0)
+        return VIR_PY_NONE;
+
+    py_retval = libvirt_charPtrWrap(buf);
+    return py_retval;
+}
+
 /************************************************************************
  *									*
  *			The registration stuff				*
@@ -5147,6 +5179,7 @@ static PyMethodDef libvirtMethods[] = {
     {(char *) "virDomainSendKey", libvirt_virDomainSendKey, METH_VARARGS, NULL},
     {(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed, METH_VARARGS, NULL},
     {(char *) "virDomainBlockPeek", libvirt_virDomainBlockPeek, METH_VARARGS, NULL},
+    {(char *) "virDomainMemoryPeek", libvirt_virDomainMemoryPeek, METH_VARARGS, NULL},
     {NULL, NULL, 0, NULL}
 };
 
-- 
1.7.1

--
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]