Displaying 20 results from an estimated 34 matches for "py_pwrite".
2019 Nov 22
0
Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...and that guarantee is
> already in the C plugin docs?
I think it would be better if we simply referred back to the C
documentation to avoid duplication. Also an advantage of using
bitmasks. That does require a rather larger change to the
documentation though.
> > static int
> >-py_pwrite (void *handle, const void *buf,
> >- uint32_t count, uint64_t offset)
> >+py_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset,
> >+ uint32_t flags)
> > {
> > PyObject *obj = handle;
> > PyObject *fn;
> >@@ -5...
2019 Nov 23
3
[PATCH nbdkit] python: Pass memoryview to pwrite()
...ng nbdkit
$ ./nbdkit -f -v python zero.py
plugins/python/python.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/python/python.c b/plugins/python/python.c
index 214fffb..2b4361a 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -496,8 +496,8 @@ py_pwrite (void *handle, const void *buf,
PyErr_Clear ();
r = PyObject_CallFunction (fn, "ONL", obj,
- PyByteArray_FromStringAndSize (buf, count),
- offset, NULL);
+ PyMemoryView_FromMemory ((char *)buf, count, PyBUF...
2019 Nov 22
1
Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...C
> documentation to avoid duplication. Also an advantage of using
> bitmasks. That does require a rather larger change to the
> documentation though.
Pointing to the C docs, and focusing on just the bindings-induced
differences, is fine.
>
>>> static int
>>> -py_pwrite (void *handle, const void *buf,
>>> - uint32_t count, uint64_t offset)
>>> +py_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset,
>>> + uint32_t flags)
>>> {
>>> PyObject *obj = handle;
>>> PyOb...
2019 Nov 22
8
Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
.... C<flags> is
> +a bitmask which may include C<nbdkit.FLAG_MAY_TRIM>,
> +C<nbdkit.FLAG_FUA>, C<nbdkit.FLAG_FAST_ZERO>.
Well, technically FAST_ZERO can't be set until later in the series when
you plumb in the can_fast_zero callback... :)
> static int
> -py_pwrite (void *handle, const void *buf,
> - uint32_t count, uint64_t offset)
> +py_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset,
> + uint32_t flags)
> {
> PyObject *obj = handle;
> PyObject *fn;
> @@ -515,9 +546,19 @@ py_pwrite (v...
2018 Apr 11
0
[nbdkit PATCH v2 3/5] python: Update internals to plugin API level 2
...t *obj = handle;
PyObject *fn;
PyObject *r;
+ assert (!flags);
if (!callback_defined ("pread", &fn)) {
nbdkit_error ("%s: missing callback: %s", script, "pread");
return -1;
@@ -469,12 +471,13 @@ py_pread (void *handle, void *buf,
static int
py_pwrite (void *handle, const 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 ("pwrite", &fn)) {
PyErr_Clear ();...
2018 Apr 11
0
[nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...yErr_Clear ();
- r = PyObject_CallFunction (fn, "OiL", obj, count, offset, NULL);
+ r = PyObject_CallFunction (fn, "OiL", h->obj, count, offset, NULL);
Py_DECREF (fn);
if (check_python_failure ("pread") == -1)
return -1;
@@ -504,7 +519,7 @@ static int
py_pwrite (void *handle, const void *buf,
uint32_t count, uint64_t offset, uint32_t flags)
{
- PyObject *obj = handle;
+ ConnHandle *h = handle;
PyObject *fn;
PyObject *args;
PyObject *kwargs;
@@ -516,7 +531,7 @@ py_pwrite (void *handle, const void *buf,
if (callback_defined ("...
2019 Nov 22
0
[PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...case 2:
+ r = PyObject_CallFunction (fn, "OiLI", obj, count, offset, flags, NULL);
+ break;
+ default: abort ();
+ }
Py_DECREF (fn);
if (check_python_failure ("pread") == -1)
return -1;
@@ -505,8 +536,8 @@ py_pread (void *handle, void *buf,
}
static int
-py_pwrite (void *handle, const void *buf,
- uint32_t count, uint64_t offset)
+py_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset,
+ uint32_t flags)
{
PyObject *obj = handle;
PyObject *fn;
@@ -515,9 +546,19 @@ py_pwrite (void *handle, const void *buf,
if (c...
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 23
0
[PATCH nbdkit v3 2/7] python: Implement nbdkit API version 2.
...offset, NULL);
+ break;
+ case 2:
+ r = PyObject_CallFunction (fn, "OiLI", obj, count, offset, flags, NULL);
+ break;
+ default: abort ();
+ }
Py_DECREF (fn);
if (check_python_failure ("pread") == -1)
return ret;
@@ -515,8 +560,8 @@ out:
}
static int
-py_pwrite (void *handle, const void *buf,
- uint32_t count, uint64_t offset)
+py_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset,
+ uint32_t flags)
{
PyObject *obj = handle;
PyObject *fn;
@@ -525,9 +570,19 @@ py_pwrite (void *handle, const void *buf,
if (c...
2018 Apr 19
1
Re: [nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...t_CallFunction (fn, "OiL", obj, count, offset, NULL);
> + r = PyObject_CallFunction (fn, "OiL", h->obj, count, offset, NULL);
> Py_DECREF (fn);
> if (check_python_failure ("pread") == -1)
> return -1;
> @@ -504,7 +519,7 @@ static int
> py_pwrite (void *handle, const void *buf,
> uint32_t count, uint64_t offset, uint32_t flags)
> {
> - PyObject *obj = handle;
> + ConnHandle *h = handle;
> PyObject *fn;
> PyObject *args;
> PyObject *kwargs;
> @@ -516,7 +531,7 @@ py_pwrite (void *handle, const v...
2018 Apr 11
0
[nbdkit PATCH v2 4/5] python: Expose FUA support
...-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;
PyObject *r;
+ int fua = (flags & NBDKIT_FLAG_FUA) != 0;
+ int need_flush = fua && !pwrite_has_fua;
-...
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
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.
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 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
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.
2020 Sep 01
0
[nbdkit PATCH 1/2] python: Implement .list_exports and friends
...ush,
+ .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 = py_flush,
+ .trim...
2019 Nov 21
0
[PATCH nbdkit 6/8] python: Implement cache, can_cache.
...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
2018 Apr 11
0
[nbdkit PATCH v2 2/5] python: Expose can_zero callback
...#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
return disk[offset:offset+count]
--
2....
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