[Libguestfs] [nbdkit PATCH v2 1/5] python: Let zero's may_trim parameter be optional

Richard W.M. Jones rjones at redhat.com
Thu Apr 19 14:01:21 UTC 2018


On Wed, Apr 11, 2018 at 12:03:38AM -0500, Eric Blake wrote:
> 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 positional argument.  This requires the plugin to
> give the parameter a specific name, and works whether or not
> the plugin provides a default for the parameter (although we do
> now recommend that plugins provide a default value, as it makes
> plugins built against newer nbdkit more likely to run even on
> older nbdkit, although that's not the direction we typically
> guarantee).  We can't see through a plugin that used '**kwargs',
> but that is less likely.
> 
> If we are super-worried about back-compatibility to older
> plugins which hard-coded 4 required parameters, we could also
> tweak the introspection to assume that a 'zero' with 4
> parameters and no defaults, where we do not recognize the
> fourth parameter name, is an old-style plugin, and call it
> with may_trim passed via a positional rather than a keyword
> argument.  However, I suspect most plugins just copied from
> our examples, which means they used the right parameter naming
> to just keep working; furthermore, while we have been clear
> that backwards API compatibility is essential for C, we have
> not made the same guarantee for language plugins.
> 
> The introspection framework here will also make it easy to
> probe for future flag additions (support for 'fua' being the
> obvious candidate in the short term).
> 
> This patch also fixes failure to check for (unlikely) errors
> during creation of 'args' within py_zero().
> 
> Signed-off-by: Eric Blake <eblake at redhat.com>
> ---
>  plugins/python/nbdkit-python-plugin.pod |  35 ++++++++---
>  plugins/python/python.c                 | 108 +++++++++++++++++++++++++++++---
>  plugins/python/example.py               |   2 +-
>  tests/test.py                           |   2 +-
>  4 files changed, 129 insertions(+), 18 deletions(-)
> 

This patch looked fine to me so ACK.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html




More information about the Libguestfs mailing list