Displaying 20 results from an estimated 31 matches for "py_pread".
2018 Apr 11
0
[nbdkit PATCH v2 3/5] python: Update internals to plugin API level 2
...++ b/plugins/python/python.c
@@ -49,6 +49,7 @@
#include <assert.h>
#include <errno.h>
+#define NBDKIT_API_VERSION 2
#include <nbdkit-plugin.h>
/* XXX Apparently global state is technically wrong in Python 3, see:
@@ -430,12 +431,13 @@ py_get_size (void *handle)
static int
py_pread (void *handle, void *buf,
- uint32_t count, uint64_t offset)
+ uint32_t count, uint64_t offset, uint32_t flags)
{
PyObject *obj = handle;
PyObject *fn;
PyObject *r;
+ assert (!flags);
if (!callback_defined ("pread", &fn)) {
nbdkit_error ("%s:...
2019 Nov 23
1
[PATCH] python: Support buffer protocol for pread() result
...et+count]
plugins/python/python.c | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git a/plugins/python/python.c b/plugins/python/python.c
index 148097f..ed299ff 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -445,10 +445,12 @@ py_pread (void *handle, void *buf,
PyObject *obj = handle;
PyObject *fn;
PyObject *r;
+ Py_buffer view = {0};
+ int ret = -1;
if (!callback_defined ("pread", &fn)) {
nbdkit_error ("%s: missing callback: %s", script, "pread");
- return -1;
+ return...
2019 Nov 22
0
[PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...script, py_api_version, NBDKIT_API_VERSION);
+ return -1;
+ }
+ }
}
else if (callback_defined ("config", &fn)) {
/* Other parameters are passed to the Python .config callback. */
@@ -466,8 +489,8 @@ py_get_size (void *handle)
}
static int
-py_pread (void *handle, void *buf,
- uint32_t count, uint64_t offset)
+py_pread (void *handle, void *buf, uint32_t count, uint64_t offset,
+ uint32_t flags)
{
PyObject *obj = handle;
PyObject *fn;
@@ -480,7 +503,15 @@ py_pread (void *handle, void *buf,
PyErr_Clear ();
- r =...
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.
2018 Apr 19
1
Re: [nbdkit PATCH v2 3/5] python: Update internals to plugin API level 2
...nclude <assert.h>
> #include <errno.h>
>
> +#define NBDKIT_API_VERSION 2
> #include <nbdkit-plugin.h>
>
> /* XXX Apparently global state is technically wrong in Python 3, see:
> @@ -430,12 +431,13 @@ py_get_size (void *handle)
>
> static int
> py_pread (void *handle, void *buf,
> - uint32_t count, uint64_t offset)
> + uint32_t count, uint64_t offset, uint32_t flags)
> {
> PyObject *obj = handle;
> PyObject *fn;
> PyObject *r;
>
> + assert (!flags);
I'm confused by the assertions here (I u...
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 25
0
[PATCH nbdkit 1/2] python: For v2 API, avoid copy by passing a buffer to pread.
...supports whole reads, so your function should try to read
the whole region (perhaps requiring a loop). If the read fails or
diff --git a/plugins/python/python.c b/plugins/python/python.c
index 252ca37..79766df 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -527,7 +527,9 @@ py_pread (void *handle, void *buf, uint32_t count, uint64_t offset,
r = PyObject_CallFunction (fn, "OiL", obj, count, offset, NULL);
break;
case 2:
- r = PyObject_CallFunction (fn, "OiLI", obj, count, offset, flags, NULL);
+ r = PyObject_CallFunction (fn, "ONLI&qu...
2019 Nov 23
0
[PATCH nbdkit v3 2/7] python: Implement nbdkit API version 2.
...*/
+ py_api_version = get_py_api_version ();
+ if (py_api_version == -1)
+ return -1;
}
else if (callback_defined ("config", &fn)) {
/* Other parameters are passed to the Python .config callback. */
@@ -469,8 +506,8 @@ py_get_size (void *handle)
}
static int
-py_pread (void *handle, void *buf,
- uint32_t count, uint64_t offset)
+py_pread (void *handle, void *buf, uint32_t count, uint64_t offset,
+ uint32_t flags)
{
PyObject *obj = handle;
PyObject *fn;
@@ -485,7 +522,15 @@ py_pread (void *handle, void *buf,
PyErr_Clear ();
- r =...
2018 Apr 06
0
[nbdkit PATCH 2/2] python: Simplify calling into plugin
.../* decremented by Py_DECREF (args) */
- PyTuple_SetItem (args, 0, obj);
- r = PyObject_CallObject (fn, args);
+ r = PyObject_CallFunctionObjArgs (fn, obj, NULL);
Py_DECREF (fn);
- Py_DECREF (args);
if (check_python_failure ("get_size") == -1)
return -1;
@@ -390,7 +367,6 @@ py_pread (void *handle, void *buf,
{
PyObject *obj = handle;
PyObject *fn;
- PyObject *args;
PyObject *r;
if (!callback_defined ("pread", &fn)) {
@@ -400,14 +376,8 @@ py_pread (void *handle, void *buf,
PyErr_Clear ();
- args = PyTuple_New (3);
- Py_INCREF (obj); /* decrem...
2018 Apr 11
0
[nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...45,7 +460,7 @@ py_get_size (void *handle)
PyErr_Clear ();
- r = PyObject_CallFunctionObjArgs (fn, obj, NULL);
+ r = PyObject_CallFunctionObjArgs (fn, h->obj, NULL);
Py_DECREF (fn);
if (check_python_failure ("get_size") == -1)
return -1;
@@ -462,7 +477,7 @@ static int
py_pread (void *handle, void *buf,
uint32_t count, uint64_t offset, uint32_t flags)
{
- PyObject *obj = handle;
+ ConnHandle *h = handle;
PyObject *fn;
PyObject *r;
@@ -474,7 +489,7 @@ py_pread (void *handle, void *buf,
PyErr_Clear ();
- r = PyObject_CallFunction (fn, "OiL&qu...
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 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 19
1
Re: [nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...t; PyErr_Clear ();
>
> - r = PyObject_CallFunctionObjArgs (fn, obj, NULL);
> + r = PyObject_CallFunctionObjArgs (fn, h->obj, NULL);
> Py_DECREF (fn);
> if (check_python_failure ("get_size") == -1)
> return -1;
> @@ -462,7 +477,7 @@ static int
> py_pread (void *handle, void *buf,
> uint32_t count, uint64_t offset, uint32_t flags)
> {
> - PyObject *obj = handle;
> + ConnHandle *h = handle;
> PyObject *fn;
> PyObject *r;
>
> @@ -474,7 +489,7 @@ py_pread (void *handle, void *buf,
>
> PyErr_Clear (...
2020 Sep 01
0
[nbdkit PATCH 1/2] python: Implement .list_exports and friends
...+ .can_flush = py_can_flush,
+ .can_trim = py_can_trim,
+ .can_zero = py_can_zero,
+ .can_fast_zero = 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...
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 21
0
[PATCH nbdkit 6/8] python: Implement cache, can_cache.
...ther arguments may be used by the plugin that you load]"
@@ -762,12 +801,14 @@ static struct nbdkit_plugin plugin = {
.can_write = py_can_write,
.can_flush = py_can_flush,
.can_trim = py_can_trim,
+ .can_cache = py_can_cache,
.pread = py_pread,
.pwrite = py_pwrite,
.flush = py_flush,
.trim = py_trim,
.zero = py_zero,
+ .cache = py_cache,
};
NBDKIT_REGISTER_PLUGIN (plugin)
--
2.23.0
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
2018 Apr 11
0
[nbdkit PATCH v2 4/5] python: Expose FUA support
...Py_DECREF (fn);
+ if (trim_has_fua < 0) {
+ check_python_failure ("config");
+ return -1;
+ }
+ }
}
else if (callback_defined ("config", &fn)) {
/* Other parameters are passed to the Python .config callback. */
@@ -469,22 +498,52 @@ py_pread (void *handle, void *buf,
return 0;
}
+static int py_flush (void *handle, uint32_t flags);
+
static int
py_pwrite (void *handle, const void *buf,
uint32_t count, uint64_t offset, uint32_t flags)
{
PyObject *obj = handle;
PyObject *fn;
+ PyObject *args;
+ PyObject *kwargs...
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 2/5] python: Expose can_zero callback
...fined ("zero", NULL);
}
#define py_config_help \
@@ -743,6 +751,7 @@ static struct nbdkit_plugin plugin = {
.can_flush = py_can_flush,
.is_rotational = py_is_rotational,
.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 518cdd4..852af55 100644
--- a/tests/test.py
+++ b/tests/test.py
@@ -30,6 +30,10 @@ def can_trim(h):
return True
+def can_zero(h):
+ return True
+
+
def pread(h, count, offset):
global disk
retu...