Displaying 20 results from an estimated 25 matches for "py_can_trim".
2019 Nov 21
0
[PATCH nbdkit 6/8] python: Implement cache, can_cache.
...uot;cache") == -1)
+ return -1;
+ Py_DECREF (r);
+ }
+ else {
+ nbdkit_error ("%s not implemented", "cache");
+ return -1;
+ }
+
+ return 0;
+}
+
static int
boolean_callback (void *handle, const char *can_fn, const char *plain_fn)
{
@@ -736,6 +769,12 @@ py_can_trim (void *handle)
return boolean_callback (handle, "can_trim", "trim");
}
+static int
+py_can_cache (void *handle)
+{
+ return boolean_callback (handle, "can_cache", "cache");
+}
+
#define py_config_help \
"script=<FILENAME> (required)...
2018 Apr 11
0
[nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...Err_Clear ();
- r = PyObject_CallFunctionObjArgs (fn, obj, NULL);
+ r = PyObject_CallFunctionObjArgs (fn, h->obj, NULL);
Py_DECREF (fn);
if (check_python_failure ("is_rotational") == -1)
return -1;
@@ -787,7 +802,7 @@ py_is_rotational (void *handle)
static int
py_can_trim (void *handle)
{
- PyObject *obj = handle;
+ ConnHandle *h = handle;
PyObject *fn;
PyObject *r;
int ret;
@@ -795,7 +810,7 @@ py_can_trim (void *handle)
if (callback_defined ("can_trim", &fn)) {
PyErr_Clear ();
- r = PyObject_CallFunctionObjArgs (fn, obj, NULL);...
2018 Apr 11
0
[nbdkit PATCH v2 2/5] python: Expose can_zero callback
...modules, nbdkit would do this).
- */
- else if (callback_defined ("flush", NULL))
- return 1;
- else
- return 0;
+ /* No Python can_flush callback, so check for Python flush callback. */
+ return callback_defined ("flush", NULL);
}
static int
@@ -708,13 +698,31 @@ py_can_trim (void *handle)
Py_DECREF (r);
return ret;
}
- /* No Python can_trim callback, but there's a Python trim callback
- * defined, so return 1. (In C modules, nbdkit would do this).
- */
- else if (callback_defined ("trim", NULL))
- return 1;
- else
- return 0;
+...
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
0
[PATCH nbdkit v2 05/10] python: Share common code in boolean callbacks.
..._python_failure ("is_rotational") == -1)
- return -1;
- ret = r == Py_True;
- Py_DECREF (r);
- return ret;
- }
- else
- return 0;
+static int
+py_can_flush (void *handle)
+{
+ return boolean_callback (handle, "can_flush", "flush");
}
static int
py_can_trim (void *handle)
{
- PyObject *obj = handle;
- PyObject *fn;
- PyObject *r;
- int ret;
-
- if (callback_defined ("can_trim", &fn)) {
- PyErr_Clear ();
-
- r = PyObject_CallFunctionObjArgs (fn, obj, NULL);
- Py_DECREF (fn);
- if (check_python_failure ("can_trim&quo...
2018 Apr 19
1
Re: [nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...llFunctionObjArgs (fn, obj, NULL);
> + r = PyObject_CallFunctionObjArgs (fn, h->obj, NULL);
> Py_DECREF (fn);
> if (check_python_failure ("is_rotational") == -1)
> return -1;
> @@ -787,7 +802,7 @@ py_is_rotational (void *handle)
> static int
> py_can_trim (void *handle)
> {
> - PyObject *obj = handle;
> + ConnHandle *h = handle;
> PyObject *fn;
> PyObject *r;
> int ret;
> @@ -795,7 +810,7 @@ py_can_trim (void *handle)
> if (callback_defined ("can_trim", &fn)) {
> PyErr_Clear ();
>
>...
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
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
2020 Sep 01
0
[nbdkit PATCH 1/2] python: Implement .list_exports and friends
..._close,
+ .open = py_open,
+ .close = py_close,
- .get_size = py_get_size,
- .is_rotational = py_is_rotational,
- .can_multi_conn = py_can_multi_conn,
- .can_write = py_can_write,
- .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,
+ .export_description = py_export_description,
+ .get_size = py_get_size,
+ .is_rotational...
2019 Nov 22
1
Re: [PATCH nbdkit v2 05/10] python: Share common code in boolean callbacks.
...; .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, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
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
2018 Apr 06
0
[nbdkit PATCH 2/2] python: Simplify calling into plugin
...Tuple_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 ("is_rotational") == -1)
return -1;
ret = r == Py_True;
@@ -662,19 +600,14 @@ py_can_trim (void *handle)
{
PyObject *obj = handle;
PyObject *fn;
- PyObject *args;
PyObject *r;
int ret;
if (callback_defined ("can_trim", &fn)) {
PyErr_Clear ();
- args = PyTuple_New (1);
- Py_INCREF (obj); /* decremented by Py_DECREF (args) */
- PyTuple_SetIte...
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 11
0
[nbdkit PATCH v2 4/5] python: Expose FUA support
...py_config_help \
"script=<FILENAME> (required) The Python plugin to run.\n" \
"[other arguments may be used by the plugin that you load]"
@@ -759,6 +891,7 @@ static struct nbdkit_plugin plugin = {
.is_rotational = py_is_rotational,
.can_trim = py_can_trim,
.can_zero = py_can_zero,
+ .can_fua = py_can_fua,
.pread = py_pread,
.pwrite = py_pwrite,
diff --git a/plugins/python/example.py b/plugins/python/example.py
index 9205f10..ca7c266 100644
--- a/plugins/python/example.py
+++ b/plugins/python/examp...
2017 Feb 06
0
[PATCH 1/2] Define .errno_is_preserved constant instead of a .errno_is_reliable callback.
...<name>, C<version>, C<longname>, C<description>, C<config_help>
These are not yet supported.
diff --git a/plugins/python/python.c b/plugins/python/python.c
index 895a361..c4ac92d 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -612,16 +612,6 @@ py_can_trim (void *handle)
return 0;
}
-/* We can't guarantee that errno is stable across language binding
- * glue code, so this callback is implemented in C only, and not
- * exposed in Python.
- */
-static int
-py_errno_is_reliable (void *handle)
-{
- return 0;
-}
-
#define py_config_help \...
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
2020 Mar 19
2
Re: [nbdkit PATCH 1/2] sh, eval: Cache .can_zero and .can_flush
On 3/18/20 8:21 PM, Eric Blake wrote:
> In commit c306fa93ab and neighbors (v1.15.1), a concerted effort went
> into caching the results of .can_FOO callbacks, with commit messages
> demonstrating that a plugin with a slow callback should not have that
> delay magnified multiple times. But nothing was added to the
> testsuite at the time, and with the sh and eval plugins, we still
2017 Jan 27
0
[nbdkit PATCH v3 1/4] plugins: Don't use bogus errno from non-C plugins
...C<name>, C<version>, C<longname>, C<description>, C<config_help>
These are not yet supported.
diff --git a/plugins/python/python.c b/plugins/python/python.c
index 0504715..7e9fc1e 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -549,6 +549,16 @@ py_can_trim (void *handle)
return 0;
}
+/* We can't guarantee that errno is stable across language binding
+ * glue code, so this callback is implemented in C only, and not
+ * exposed in Python.
+ */
+static int
+py_errno_is_reliable (void *handle)
+{
+ return 0;
+}
+
#define py_config_help \...