search for: zero_may_trim

Displaying 6 results from an estimated 6 matches for "zero_may_trim".

2018 Apr 06
1
[nbdkit PATCH] python: Let zero's may_trim parameter be optional
...write the whole region (perhaps requiring a loop). If the write diff --git a/plugins/python/python.c b/plugins/python/python.c index 35e8df2..d944905 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -64,6 +64,8 @@ static PyObject *module; static int last_error; +static int zero_may_trim = -1; + static PyObject * set_error (PyObject *self, PyObject *args) { @@ -108,6 +110,68 @@ callback_defined (const char *name, PyObject **obj_rtn) return 1; } +/* Checks whether a list of strings contains the given name */ +static int +check_list (PyObject *list, const char *name) +{ + ss...
2018 Apr 11
0
[nbdkit PATCH v2 1/5] python: Let zero's may_trim parameter be optional
...* python_to_string (PyObject *str) @@ -481,21 +548,48 @@ py_zero (void *handle, uint32_t count, uint64_t offset, int may_trim) PyObject *obj = handle; PyObject *fn; PyObject *args; + PyObject *kwargs; PyObject *r; if (callback_defined ("zero", &fn)) { + static int zero_may_trim = -1; + + if (zero_may_trim < 0) + zero_may_trim = callback_has_parameter (fn, "may_trim"); + if (zero_may_trim < 0) { + check_python_failure ("zero"); + return -1; + } + PyErr_Clear (); last_error = 0; - args = PyTuple_New (4); - P...
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
...uint32_t flags) { PyObject *obj = handle; PyObject *fn; PyObject *args; PyObject *kwargs; PyObject *r; + int may_trim = (flags & NBDKIT_FLAG_MAY_TRIM) != 0; + assert (!(flags & ~NBDKIT_FLAG_MAY_TRIM)); if (callback_defined ("zero", &fn)) { static int zero_may_trim = -1; -- 2.14.3
2018 Apr 11
0
[nbdkit PATCH v2 4/5] python: Expose FUA support
...M) != 0; + int fua = (flags & NBDKIT_FLAG_FUA) != 0; + int need_flush = fua && !zero_has_fua; - assert (!(flags & ~NBDKIT_FLAG_MAY_TRIM)); + assert (!(flags & ~(NBDKIT_FLAG_MAY_TRIM | NBDKIT_FLAG_FUA))); if (callback_defined ("zero", &fn)) { static int zero_may_trim = -1; @@ -593,6 +682,15 @@ py_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) Py_DECREF (fn); return -1; } + if (zero_has_fua && + PyDict_SetItemString (kwargs, "fua", + fua ? Py_True : Py_False) == -1...