Displaying 16 results from an estimated 16 matches for "py_api_version".
Did you mean:
_api_version
2019 Nov 22
0
[PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...hon.c
+++ b/plugins/python/python.c
@@ -46,6 +46,8 @@
#define PY_SSIZE_T_CLEAN 1
#include <Python.h>
+#define NBDKIT_API_VERSION 2
+
#include <nbdkit-plugin.h>
#include "cleanup.h"
@@ -60,6 +62,7 @@
*/
static const char *script;
static PyObject *module;
+static int py_api_version = 1;
static int last_error;
@@ -356,6 +359,26 @@ py_config (const char *key, const char *value)
"nbdkit requires these callbacks.", script);
return -1;
}
+
+ /* Get the API version. */
+ if (callback_defined ("api_version", &fn)) {...
2019 Nov 23
0
[PATCH nbdkit v3 2/7] python: Implement nbdkit API version 2.
...hon.c
+++ b/plugins/python/python.c
@@ -46,6 +46,8 @@
#define PY_SSIZE_T_CLEAN 1
#include <Python.h>
+#define NBDKIT_API_VERSION 2
+
#include <nbdkit-plugin.h>
#include "cleanup.h"
@@ -60,6 +62,7 @@
*/
static const char *script;
static PyObject *module;
+static int py_api_version = 1;
static int last_error;
@@ -285,9 +288,14 @@ py_dump_plugin (void)
PyObject *fn;
PyObject *r;
+ /* Python version and ABI. */
printf ("python_version=%s\n", PY_VERSION);
printf ("python_pep_384_abi_version=%d\n", PYTHON_ABI_VERSION);
+ /* Maximum nbdki...
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 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 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
1
Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...quot;, &fn)) {
>>> PyErr_Clear ();
>>> - r = PyObject_CallFunction (fn, "ONL", obj,
>>> - PyByteArray_FromStringAndSize (buf, count),
>>> - offset, NULL);
>>> + switch (py_api_version) {
>>> + case 1:
>>> + r = PyObject_CallFunction (fn, "ONL", obj,
>>> + PyByteArray_FromStringAndSize (buf, count),
>>> + offset, NULL);
>>
>> Here, we could assert (fla...
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
8
Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...(callback_defined ("pwrite", &fn)) {
> PyErr_Clear ();
>
> - r = PyObject_CallFunction (fn, "ONL", obj,
> - PyByteArray_FromStringAndSize (buf, count),
> - offset, NULL);
> + switch (py_api_version) {
> + case 1:
> + r = PyObject_CallFunction (fn, "ONL", obj,
> + PyByteArray_FromStringAndSize (buf, count),
> + offset, NULL);
Here, we could assert (flags == 0) (the FUA flag should not be set if
the...
2019 Nov 22
0
[PATCH nbdkit v2 06/10] python: Implement cache.
...unt, 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)) {
+ PyErr_Clear ();
+
+ switch (py_api_version) {
+ case 1:
+ nbdkit_error ("%s can only be called when using api_version >= 2",
+ "cache");
+ return -1;
+ case 2:
+ r = PyObject_CallFunction (fn, "OiLI", obj, count, offset, flags, NULL);
+ break;
+ default: abort...
2019 Nov 21
0
[PATCH nbdkit 6/8] python: Implement cache, can_cache.
...unt, 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)) {
+ PyErr_Clear ();
+
+ switch (py_api_version) {
+ case 1:
+ nbdkit_error ("%s can only be called when using api_version >= 2",
+ "cache");
+ return -1;
+ case 2:
+ r = PyObject_CallFunction (fn, "OiLI", obj, count, offset, flags, NULL);
+ break;
+ default: abort...
2019 Nov 22
0
Re: [PATCH nbdkit v2 03/10] python: Implement nbdkit API version 2.
...fined ("pwrite", &fn)) {
> > PyErr_Clear ();
> >- r = PyObject_CallFunction (fn, "ONL", obj,
> >- PyByteArray_FromStringAndSize (buf, count),
> >- offset, NULL);
> >+ switch (py_api_version) {
> >+ case 1:
> >+ r = PyObject_CallFunction (fn, "ONL", obj,
> >+ PyByteArray_FromStringAndSize (buf, count),
> >+ offset, NULL);
>
> Here, we could assert (flags == 0) (the FUA flag...
2019 Nov 25
0
[PATCH nbdkit 1/2] python: For v2 API, avoid copy by passing a buffer to pread.
...ure ("pread") == -1)
return ret;
- if (PyObject_GetBuffer (r, &view, PyBUF_SIMPLE) == -1) {
- nbdkit_error ("%s: value returned from pread does not support the "
- "buffer protocol",
- script);
- goto out;
- }
+ if (py_api_version == 1) {
+ /* In API v1 the Python pread function had to return a buffer
+ * protocol compatible function. In API v2+ it writes directly to
+ * the C buffer so this code is not used.
+ */
+ if (PyObject_GetBuffer (r, &view, PyBUF_SIMPLE) == -1) {
+ nbdkit_error ("%s:...
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
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.
2020 Aug 05
5
[PATCH NOT WORKING nbdkit 0/3] python: Allow thread model to be set from Python plugins.
Patch 2 certainly allows you to set the thread model. However patch 3
shows that if you set it to nbdkit.THREAD_MODEL_PARALLEL it will
crash.
If you look closely at the stack trace (attached below) you can see
that ignoring threads which are in parts of nbdkit unrelated to
Python:
Thread 4: In pread, waiting in time.sleep(). This thread has released
the GIL.
Thread 2: Started to