Displaying 20 results from an estimated 21 matches for "py_get_size".
2020 Sep 01
0
[nbdkit PATCH 1/2] python: Implement .list_exports and friends
...lure ("export_description") == -1)
+ return NULL;
+
+ desc = python_to_string (r);
+ Py_DECREF (r);
+ if (!desc) {
+ nbdkit_error ("export_description method did not return a string");
+ return NULL;
+ }
+
+ return nbdkit_strdup_intern (desc);
+}
+
static int64_t
py_get_size (void *handle)
{
@@ -1120,42 +1242,45 @@ py_extents (void *handle, uint32_t count, uint64_t offset,
#define THREAD_MODEL NBDKIT_THREAD_MODEL_PARALLEL
static struct nbdkit_plugin plugin = {
- .name = "python",
- .version = PACKAGE_VERSION,
+ .name...
2018 Apr 06
0
[nbdkit PATCH 2/2] python: Simplify calling into plugin
...mented 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);
check_python_failure ("close");
Py_XDECREF (r);
}
@@ -356,7 +338,6 @@ py_get_size (void *handle)
{
PyObject *obj = handle;
PyObject *fn;
- PyObject *args;
PyObject *r;
int64_t ret;
@@ -367,12 +348,8 @@ py_get_size (void *handle)
PyErr_Clear ();
- args = PyTuple_New (1);
- Py_INCREF (obj); /* decremented by Py_DECREF (args) */
- PyTuple_SetItem (args, 0, ob...
2018 Apr 11
0
[nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...ear ();
- r = PyObject_CallFunctionObjArgs (fn, obj, NULL);
+ r = PyObject_CallFunctionObjArgs (fn, h->obj, NULL);
Py_DECREF (fn);
check_python_failure ("close");
Py_XDECREF (r);
}
- Py_DECREF (obj);
+ Py_DECREF (h->obj);
+ free (h);
}
static int64_t
py_get_size (void *handle)
{
- PyObject *obj = handle;
+ ConnHandle *h = handle;
PyObject *fn;
PyObject *r;
int64_t ret;
@@ -445,7 +460,7 @@ py_get_size (void *handle)
PyErr_Clear ();
- r = PyObject_CallFunctionObjArgs (fn, obj, NULL);
+ r = PyObject_CallFunctionObjArgs (fn, h->obj, NULL)...
2018 Apr 19
1
Re: [nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...gt; + r = PyObject_CallFunctionObjArgs (fn, h->obj, NULL);
> Py_DECREF (fn);
> check_python_failure ("close");
> Py_XDECREF (r);
> }
>
> - Py_DECREF (obj);
> + Py_DECREF (h->obj);
> + free (h);
> }
>
> static int64_t
> py_get_size (void *handle)
> {
> - PyObject *obj = handle;
> + ConnHandle *h = handle;
> PyObject *fn;
> PyObject *r;
> int64_t ret;
> @@ -445,7 +460,7 @@ py_get_size (void *handle)
>
> PyErr_Clear ();
>
> - r = PyObject_CallFunctionObjArgs (fn, obj, NULL);
&g...
2018 Apr 11
0
[nbdkit PATCH v2 3/5] python: Update internals to plugin API level 2
...85 100644
--- a/plugins/python/python.c
+++ 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", &a...
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
2020 Sep 01
4
[nbdkit PATCH 0/2] More language bindings for .list_exports
This picks up python and ocaml. Some of our languages are lacking a
number of bindings (for example, lua and perl lack .extents, so I
didn't have anything to copy from), and I felt less comfortable with
golang and rust. But for python and ocaml, I was able to test a
working implementation.
Eric Blake (2):
python: Implement .list_exports and friends
ocaml: Implement .list_exports and
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
1
Re: [PATCH nbdkit v2 05/10] python: Share common code in boolean callbacks.
...ion in lines of code (it may get trickier with
can_FOO that return tristate, but for this patch you really did simplify
true bool/error return functions).
> @@ -812,9 +758,9 @@ static struct nbdkit_plugin plugin = {
> .close = py_close,
>
> .get_size = py_get_size,
> + .is_rotational = py_is_rotational,
> .can_write = py_can_write,
> .can_flush = py_can_flush,
> - .is_rotational = py_is_rotational,
> .can_trim = py_can_trim,
>
> .pread = py_pread,
>
--
Eric Blake, Pr...
2019 Nov 22
0
[PATCH nbdkit v2 05/10] python: Share common code in boolean callbacks.
..._defined ("trim", NULL))
- return 1;
- else
- return 0;
+ return boolean_callback (handle, "can_trim", "trim");
}
#define py_config_help \
@@ -812,9 +758,9 @@ static struct nbdkit_plugin plugin = {
.close = py_close,
.get_size = py_get_size,
+ .is_rotational = py_is_rotational,
.can_write = py_can_write,
.can_flush = py_can_flush,
- .is_rotational = py_is_rotational,
.can_trim = py_can_trim,
.pread = py_pread,
--
2.23.0
2018 Apr 19
1
Re: [nbdkit PATCH v2 3/5] python: Update internals to plugin API level 2
.../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 (!...
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.
2020 Mar 19
5
[nbdkit PATCH 0/2] More caching of initial setup
When I added .can_FOO caching in 1.16, I missed the case that the sh
plugin itself was calling .can_flush twice in some situations (in
order to default .can_fua). Then right after, I regressed it to call
.can_zero twice (in order to default .can_fast_zero). I also missed
that .thread_model could use better caching, because at the time, I
did not add testsuite coverage. Fix that now.
Eric Blake
2019 Nov 22
0
[PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...API versions between 1 and %d.",
+ 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,...
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.
2019 Nov 23
0
[PATCH nbdkit v3 2/7] python: Implement nbdkit API version 2.
...rn -1;
}
+
+ /* Get the API version. */
+ 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,...
2020 Aug 05
5
[PATCH nbdkit 3/4] python: Allow thread model to be set from Python plugins.
This is working for me now, although possibly only on Python 3.9.
Dan suggested PyEval_InitThreads but that was deprecated in
Python 3.7.
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 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