[Libguestfs] [libnbd PATCH 3/2] python: Slice pread_structured buffer from original

Richard W.M. Jones rjones at redhat.com
Wed Jun 1 08:47:02 UTC 2022


On Tue, May 31, 2022 at 10:52:35AM -0500, Eric Blake wrote:
> And I really wish python didn't make it so hard to grab a slice of
> another object using C code.  Having to create 3 temporary PyObjects
> instead of having a utility C function that takes normal integers was
> annoying.

You can add hand-written utility functions to python/utils.c if that
makes things easier.  Note you will need to add a prototype for the
new function(s) to the generated code in python/methods.h.

See nbd_internal_py_get_string_list for an example of this.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org


More information about the Libguestfs mailing list