search for: py_zero

Displaying 20 results from an estimated 39 matches for "py_zero".

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
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
2018 Apr 11
0
[nbdkit PATCH v2 3/5] python: Update internals to plugin API level 2
...2_t count, uint64_t offset, uint32_t flags) { PyObject *obj = handle; PyObject *fn; PyObject *r; + assert (!flags); if (callback_defined ("trim", &fn)) { PyErr_Clear (); @@ -543,14 +548,16 @@ py_trim (void *handle, uint32_t count, uint64_t offset) } static int -py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) +py_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) { PyObject *obj = handle; PyObject *fn; PyObject *args; PyObject *kwargs; PyObject *r; + int may_trim = (flags & NBDKIT_FLAG_MAY_TRIM) != 0; +...
2019 Nov 22
0
[PATCH nbdkit v2 06/10] python: Implement cache.
...ero>, C<can_extents>, C<can_multi_conn>, -C<cache>, C<extents>. These are not yet supported. diff --git a/plugins/python/python.c b/plugins/python/python.c index 9445343..6d5a0b7 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -683,6 +683,39 @@ py_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) return -1; } +static int +py_cache (void *handle, uint32_t count, uint64_t offset, uint32_t flags) +{ + PyObject *obj = handle; + PyObject *fn; + PyObject *r; + + if (callback_defined ("cache", &fn)) { + PyEr...
2019 Nov 21
0
[PATCH nbdkit 6/8] python: Implement cache, can_cache.
...ero>, C<can_extents>, C<can_multi_conn>, -C<cache>, C<extents>. These are not yet supported. diff --git a/plugins/python/python.c b/plugins/python/python.c index 9445343..33fb6e4 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -683,6 +683,39 @@ py_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) return -1; } +static int +py_cache (void *handle, uint32_t count, uint64_t offset, uint32_t flags) +{ + PyObject *obj = handle; + PyObject *fn; + PyObject *r; + + if (callback_defined ("cache", &fn)) { + PyEr...
2018 Apr 11
0
[nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...ot;OiL", obj, count, offset); + args = Py_BuildValue ("OiL", h->obj, count, offset); if (!args) { check_python_failure ("trim"); Py_DECREF (fn); @@ -637,7 +652,7 @@ py_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags) static int py_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) { - PyObject *obj = handle; + ConnHandle *h = handle; PyObject *fn; PyObject *args; PyObject *kwargs; @@ -660,7 +675,7 @@ py_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) PyErr_Clear (); la...
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.
2017 Jan 26
0
[nbdkit PATCH v2 6/6] python: Support zero callback
...@ -62,6 +64,7 @@ set_error (PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "i", &err)) return NULL; nbdkit_set_error (err); + last_error = err; Py_RETURN_NONE; } @@ -441,6 +444,48 @@ py_trim (void *handle, uint32_t count, uint64_t offset) } static int +py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) +{ + PyObject *obj = handle; + PyObject *fn; + PyObject *args; + PyObject *r; + + if (callback_defined ("zero", &fn)) { + PyErr_Clear (); + + last_error = 0; + args = PyTuple_New (4); + Py_INCREF (obj); /*...
2017 Jan 27
0
[nbdkit PATCH v3 4/4] python: Support zero callback
...@ -62,6 +64,7 @@ set_error (PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "i", &err)) return NULL; nbdkit_set_error (err); + last_error = err; Py_RETURN_NONE; } @@ -441,6 +444,48 @@ py_trim (void *handle, uint32_t count, uint64_t offset) } static int +py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) +{ + PyObject *obj = handle; + PyObject *fn; + PyObject *args; + PyObject *r; + + if (callback_defined ("zero", &fn)) { + PyErr_Clear (); + + last_error = 0; + args = PyTuple_New (4); + Py_INCREF (obj); /*...
2018 Apr 19
1
Re: [nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...> + args = Py_BuildValue ("OiL", h->obj, count, offset); > if (!args) { > check_python_failure ("trim"); > Py_DECREF (fn); > @@ -637,7 +652,7 @@ py_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags) > static int > py_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) > { > - PyObject *obj = handle; > + ConnHandle *h = handle; > PyObject *fn; > PyObject *args; > PyObject *kwargs; > @@ -660,7 +675,7 @@ py_zero (void *handle, uint32_t count, uint64_t offset, uint32_t f...
2018 Apr 11
0
[nbdkit PATCH v2 4/5] python: Expose FUA support
...(check_python_failure ("trim") == -1) return -1; Py_DECREF (r); @@ -544,7 +631,7 @@ py_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags) return -1; } - return 0; + return need_flush ? py_flush (handle, 0) : 0; } static int @@ -556,8 +643,10 @@ py_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) PyObject *kwargs; PyObject *r; int may_trim = (flags & NBDKIT_FLAG_MAY_TRIM) != 0; + int fua = (flags & NBDKIT_FLAG_FUA) != 0; + int need_flush = fua && !zero_has_fua; - assert (!(flags & ~NBDKIT_FLAG_M...
2019 Nov 22
0
[PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...Function (fn, "OiLI", obj, count, offset, flags, NULL); + break; + default: abort (); + } Py_DECREF (fn); if (check_python_failure ("trim") == -1) return -1; @@ -580,7 +637,7 @@ py_trim (void *handle, uint32_t count, uint64_t offset) } static int -py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) +py_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) { PyObject *obj = handle; PyObject *fn; @@ -590,9 +647,20 @@ py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) PyErr_Clear ();...
2019 Nov 23
0
[PATCH nbdkit v3 2/7] python: Implement nbdkit API version 2.
...Function (fn, "OiLI", obj, count, offset, flags, NULL); + break; + default: abort (); + } Py_DECREF (fn); if (check_python_failure ("trim") == -1) return -1; @@ -590,7 +661,7 @@ py_trim (void *handle, uint32_t count, uint64_t offset) } static int -py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) +py_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) { PyObject *obj = handle; PyObject *fn; @@ -600,9 +671,20 @@ py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) PyErr_Clear ();...
2018 Apr 06
6
[nbdkit PATCH 0/2] Python cleanups
I noticed these while working on adding fua support into python, these are independent enough to push now (and I'll have to rebase my 'optional may_trim' patch on top of this). Eric Blake (2): python: Use Py_XDEFREF() python: Simplify calling into plugin plugins/python/python.c | 106 ++++++++---------------------------------------- 1 file changed, 18 insertions(+), 88
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.
2018 Apr 11
0
[nbdkit PATCH v2 1/5] python: Let zero's may_trim parameter be optional
...arantee 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@redhat.com> --- plugins/python/nbdkit-python-plugin.pod | 35 ++++++++--- plugins/python/python.c | 108 +++++++++++++++++++++++++++++--- plugins/python/example.py | 2 +- tests/test.py | 2 +-...
2018 Apr 06
1
[nbdkit PATCH] python: Let zero's may_trim parameter be optional
...only available in python 3 */ + args = PyTuple_GetItem(spec, 5); + if (check_list(args, name)) + r = 1; + } + + Py_DECREF (spec); + return r; +} + /* Convert bytes/str/unicode into a string. Caller must free. */ static char * python_to_string (PyObject *str) @@ -530,21 +594,31 @@ py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) PyObject *obj = handle; PyObject *fn; PyObject *args; + PyObject *kwargs = NULL; PyObject *r; if (callback_defined ("zero", &fn)) { + if (zero_may_trim < 0) + zero_may_trim = callback_has_paramet...
2020 Sep 01
0
[nbdkit PATCH 1/2] python: Implement .list_exports and friends
...= py_can_fast_zero, + .can_fua = py_can_fua, + .can_cache = py_can_cache, + .can_extents = py_can_extents, - .pread = py_pread, - .pwrite = py_pwrite, - .flush = py_flush, - .trim = py_trim, - .zero = py_zero, - .cache = py_cache, - .extents = py_extents, + .pread = py_pread, + .pwrite = py_pwrite, + .flush = py_flush, + .trim = py_trim, + .zero = py_zero, + .cache = py_cache, + .extents...
2018 Apr 06
0
[nbdkit PATCH 1/2] python: Use Py_XDEFREF()
...DECREF (module); + Py_XDECREF (module); Py_Finalize (); } @@ -346,8 +345,7 @@ py_close (void *handle) Py_DECREF (fn); Py_DECREF (args); check_python_failure ("close"); - if (r) - Py_DECREF (r); + Py_XDECREF (r); } Py_DECREF (obj); @@ -550,8 +548,7 @@ py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) gracefully fall back, and to accomodate both a normal return and an exception. */ nbdkit_debug ("zero requested falling back to pwrite"); - if (r) - Py_DECREF (r); + Py_XDECREF (r);...
2019 Nov 22
0
[PATCH nbdkit v2 01/10] python: Use PyObject_CallFunction instead of constructing the tuple.
...erflow.com/a/21221335 --- plugins/python/python.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/plugins/python/python.c b/plugins/python/python.c index 148097f..d65ac45 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -557,26 +557,21 @@ py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) { PyObject *obj = handle; PyObject *fn; - PyObject *args; PyObject *r; if (callback_defined ("zero", &fn)) { PyErr_Clear (); last_error = 0; - args = PyTuple_New (4); - Py_INCREF (obj); /*...