python: Implement nbdkit API version 2.
commita9b2637cf4f00fb8a25ffaf31ee83be5fe019ae2
authorRichard W.M. Jones <rjones@redhat.com>
Thu, 21 Nov 2019 15:44:39 +0000 (21 15:44 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Mon, 9 Dec 2019 15:56:20 +0000 (9 15:56 +0000)
treeb71f898548fd72312ab486c63d32f7fa0f0ca382
parent14b7fe2e0de881e3dfc8803484ade29a61e323c9
python: Implement nbdkit API version 2.

To avoid breaking existing plugins, Python plugins wishing to use
version 2 of the API must opt in by declaring:

  API_VERSION = 2

(Plugins which do not do this are assumed to want API version 1).

For v2 API, we also avoid a copy by passing a buffer into pread.

It's more efficient if we pass the C buffer directly to Python code.
In some cases the Python code will be able to write directly into the
C buffer using functions like file.readinto and socket.recv_into.
This avoids an extra copy.

Thanks: Nir Soffer
https://www.redhat.com/archives/libguestfs/2019-November/thread.html#00220
plugins/python/example.py
plugins/python/nbdkit-python-plugin.pod
plugins/python/python.c
tests/python-exception.py
tests/shebang.py
tests/test.py