similar to: Extending the nbdkit python plugin

Displaying 20 results from an estimated 10000 matches similar to: "Extending the nbdkit python plugin"

2019 Nov 25
6
[nbdkit PATCH 0/5] Counterproposal for python v2 interfaces
As mentioned in my reviews, I wonder if we should make our python callbacks look a bit more Pythonic by having kwargs added for each new flag that we want to expose. The idea was first floated here: https://www.redhat.com/archives/libguestfs/2018-April/msg00108.html Note that with my proposal, there is no need for a python script to expose a global API_VERSION variable; new flags are added
2019 Nov 22
4
Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
On 11/22/19 3:20 PM, Nir Soffer wrote: >>> +# There are several variants of the API. nbdkit will call this >>> +# function first to determine which one you want to use. This is the >>> +# latest version at the time this example was written. >>> +def api_version(): >>> + return 2 >> >> Matches the C counterpart of #define
2019 Nov 22
8
Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
On 11/22/19 1:53 PM, Richard W.M. Jones wrote: > To avoid breaking existing plugins, Python plugins wishing to use > version 2 of the API must opt in by declaring: > > def api_version(): > return 2 > > (Plugins which do not do this are assumed to want API version 1). Could we also permit the python code to declare a global variable instead of a function? But a
2018 Apr 11
10
[nbdkit PATCH v2 0/5] FUA support in Python scripts
First out of our four language bindings to add FUA support (for reference, I added 'zero' support for python, perl, and ruby back in 1.1.13, then Rich had to add it for ocaml in 1.1.20). I tested this heavily under python 2, but for now only compile tested under python 3; I plan to do further testing there and make any tweaks if necessary. I wrote patch 5 early on, but then realized I
2019 Nov 21
0
Re: Extending the nbdkit python plugin
On Thu, Nov 21, 2019 at 01:57:28PM +0000, Richard W.M. Jones wrote: > We have an nbdkit plugin that lets you write NBD servers in Python. > An example of an existing Python plugin is here: > > https://github.com/libguestfs/nbdkit/blob/master/plugins/python/example.py#L1 > > This morning I tried to modify the plugin to use the newer nbdkit API > (version 2). One of the
2019 Nov 21
1
Re: Extending the nbdkit python plugin
On Thu, Nov 21, 2019 at 02:17:43PM +0000, Daniel P. Berrangé wrote: > I would define a new 'api_version()' method for your python > plugins. > > Existing plugins don't implement that of course so when your > C code invokes that it'll get an exception, and can assume > the classic API contract for pwrite(). > > If the plugin implements
2019 Nov 22
18
[PATCH nbdkit v2 00/10] Implement nbdkit API v2 for Python plugins.
v1: https://www.redhat.com/archives/libguestfs/2019-November/msg00153.html v2: - Fix implementation of can_cache. - Add implementation of can_fua. - Add a very thorough test suite which tests every command + flag combination.
2019 Nov 25
3
[PATCH nbdkit 0/2] python: Implement pread passing buffer for v2 API.
As suggested by Nir, here: https://www.redhat.com/archives/libguestfs/2019-November/thread.html#00220
2019 Nov 21
10
[PATCH nbdkit 0/8] Implement nbdkit API v2 for Python plugins.
And fill out most of the missing bits of the API. Rich.
2019 Nov 23
8
[PATCH nbdkit v3 0/7] Implement nbdkit API v2 for Python plugins.
v2 was here: https://www.redhat.com/archives/libguestfs/2019-November/msg00163.html I pushed patch 1 (with spelling fix), patch 4 and patch 5 since those were previously ACKed on the list. Differences in v3: - Add error checking to PyModule_AddIntConstant. - Use API_VERSION constant instead of function. - Add max API version supported to --dump-plugin output. - Print API_VERSION selected by
2019 Nov 25
7
[PATCH nbdkit v2 0/7] Implement nbdkit API v2 for Python plugins.
v3 was here: https://www.redhat.com/archives/libguestfs/2019-November/msg00209.html In v4: - Rebase on top of current master. Includes various fixes and updates required because of Nir's patches that went into master. - Fix api_version() -> API_VERSION in patch 2 noted previously on the mailing list. Rich.
2019 Nov 22
1
Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
On 11/22/19 3:14 PM, Richard W.M. Jones wrote: >>> @@ -54,20 +61,20 @@ def get_size(h): >>> return len(disk) >>> -def pread(h, count, offset): >>> +def pread(h, count, offset, flags): >>> global disk >>> return disk[offset:offset+count] >> >> Do we really want to be passing 'flags' as an integer that the
2019 Nov 22
1
Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
On 11/22/19 3:46 PM, Nir Soffer wrote: >>>> and for zero (once fast zero is supported later in the series), it could >>>> look like: >>>> >>>> def zero(h, count, offset, may_trim=False, fua=False, fast=False): >>> >>> This is nicer - but not extensible. >> >> Why not? Any future flag additions would still appear as new
2018 Apr 19
1
Re: [nbdkit PATCH v2 4/5] python: Expose FUA support
On Wed, Apr 11, 2018 at 12:03:41AM -0500, Eric Blake wrote: > +=item C<can_fua> > + > +(Optional) > + > + def can_fua(h): > + # return a boolean > + > +Unlike the C counterpart, the Python callback does not need a > +tri-state return value, because Python introspection is sufficient to > +learn whether callbacks support FUA. Thus, this function only returns
2018 Apr 06
1
[nbdkit PATCH] python: Let zero's may_trim parameter be optional
In preparation for adding other optional flag arguments to the python bindings, start by making the existing 'may_trim' flag to 'zero' be optional. That is, the plugin need not define the parameter if it does not make any semantic difference (ie. if the plugin ignores the hint and never trims); while if the parameter exists, we now pass it as a keyword argument rather than as a
2019 Nov 22
3
Re: [PATCH nbdkit v2 10/10] tests: Test the Python plugin thoroughly.
On Fri, Nov 22, 2019 at 9:55 PM Richard W.M. Jones <rjones@redhat.com> wrote: > > This tests the Python plugin thoroughly by issuing client commands > through libnbd and checking we get the expected results. > --- > tests/Makefile.am | 13 +-- > tests/test-python-plugin.py | 134 ++++++++++++++++++++++++++++ > tests/test-python.py | 172
2019 Nov 21
0
Re: Extending the nbdkit python plugin
This may be confusing at first but is not that difficult once you wrap your head around it. There are two types of arguments in Python: positional(*) and keyword(**). There is a rule that all positional arguments are defined before the keyword arguments. Also once an argument has a default value it is considered keyword (not positional). There are some nuances for which is best to reach to some
2017 Jan 24
4
[nbdkit PATCH 0/2] bind .zero to more languages
Begin the language binding followups to my new .zero callback, since Rich was indeed correct that we want them. I'm more familiar with python and perl (at least to the point that I was able to modify the appropriate example files and prove to myself that the bindings worked), so I've started with those. I'm less familiar with ruby and ocaml, so I've left those for tomorrow (it
2019 Nov 22
1
Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
On Fri, Nov 22, 2019 at 11:53 PM Nir Soffer <nsoffer@redhat.com> wrote: > > On Fri, Nov 22, 2019 at 11:35 PM Eric Blake <eblake@redhat.com> wrote: > > > > On 11/22/19 3:20 PM, Nir Soffer wrote: > > > > >>> +# There are several variants of the API. nbdkit will call this > > >>> +# function first to determine which one you want to
2018 Sep 10
1
question on nbdkit sh plugin
In the just-added nbdkit-sh-plugin.pod, you documented that unlike other plugins (where introspection or struct member population) can be used to determine which functionalities are supported, the shell plugin has to implement can_write and friends to return a special status 2 to document not supported, and 3 to indicate false, in part because you can't detect if a pwrite function is