Re: [PATCH] python: Expose memoryPeek to Python binding

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

 



On 2011年12月14日 02:38, Eric Blake wrote:
On 12/13/2011 06:43 AM, Osier Yang wrote:
---
  python/libvirt-override-api.xml |    8 ++++++++
  python/libvirt-override.c       |   33 +++++++++++++++++++++++++++++++++
  2 files changed, 41 insertions(+), 0 deletions(-)


+    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;

Same problems as for blockPeek.  I don't know if
PyString_FromStringAndSize will do what you want, but that's my guess,
based on its use for VIR_UUID_BUFLEN arrays.


Actually I found the problem after the patch was posted,
I got the empty output with a testing script. And yes,
PyString_fromStringAndSize worked well. Though with using
it the output is one byte different with using C API
directly, I'm still looking.

Osier

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