Fairly straightforward, as the code in plugins.c already takes
care of necessary .pwrite fallbacks.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
plugins/python/nbdkit-python-plugin.pod | 8 +++++++-
plugins/python/python.c | 7 +++++++
tests/test.py | 4 ++++
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/plugins/python/nbdkit-python-plugin.pod
b/plugins/python/nbdkit-python-plugin.pod
index f504cf7a..ec126f5a 100644
--- a/plugins/python/nbdkit-python-plugin.pod
+++ b/plugins/python/nbdkit-python-plugin.pod
@@ -208,6 +208,13 @@ contents will be garbage collected.
def can_trim(h):
# return a boolean
+=item C<can_zero>
+
+(Optional)
+
+ def can_zero(h):
+ # return a boolean
+
=item C<pread>
(Required)
@@ -317,7 +324,6 @@ C<config_help>,
C<magic_config_key>,
C<can_fua>,
C<can_cache>,
-C<can_zero>,
C<can_fast_zero>,
C<can_extents>,
C<can_multi_conn>,
diff --git a/plugins/python/python.c b/plugins/python/python.c
index d18bcb5e..aa09dce7 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -718,6 +718,12 @@ py_can_trim (void *handle)
return boolean_callback (handle, "can_trim", "trim");
}
+static int
+py_can_zero (void *handle)
+{
+ return boolean_callback (handle, "can_zero", "zero");
+}
+
#define py_config_help \
"script=<FILENAME> (required) The Python plugin to run.\n" \
"[other arguments may be used by the plugin that you load]"
@@ -744,6 +750,7 @@ static struct nbdkit_plugin plugin = {
.can_write = py_can_write,
.can_flush = py_can_flush,
.can_trim = py_can_trim,
+ .can_zero = py_can_zero,
.pread = py_pread,
.pwrite = py_pwrite,
diff --git a/tests/test.py b/tests/test.py
index a83f1181..1b7d3e0e 100644
--- a/tests/test.py
+++ b/tests/test.py
@@ -32,6 +32,10 @@ def can_trim(h):
return True
+def can_zero(h):
+ return True
+
+
def pread(h, count, offset):
global disk
return disk[offset:offset+count]
--
2.21.0