[Libguestfs] [PATCH nbdkit] plugins/python: Fix extents() count format string

Nir Soffer nsoffer at redhat.com
Sun Dec 19 07:09:39 UTC 2021


The plugin used "i" (int32) instead of "I" (uint32) for the count, so
when the client asks for 4294966784 bytes, the python plugin got -512.

    nbdkit: python.0: debug: python: extents count=4294966784 offset=0 req_one=0
    ...
    nbdkit: python.0: debug: extents: count=-512 offset=0 flags=0

With this fix I can get extents from rhv-upload-plugin using nbdinfo.
---
 plugins/python/plugin.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/python/plugin.c b/plugins/python/plugin.c
index f85512b4..366619f9 100644
--- a/plugins/python/plugin.c
+++ b/plugins/python/plugin.c
@@ -957,21 +957,21 @@ py_extents (void *handle, uint32_t count, uint64_t offset,
   ACQUIRE_PYTHON_GIL_FOR_CURRENT_SCOPE;
   struct handle *h = handle;
   PyObject *fn;
   PyObject *r;
   PyObject *iter, *t;
   size_t size;
 
   if (callback_defined ("extents", &fn)) {
     PyErr_Clear ();
 
-    r = PyObject_CallFunction (fn, "OiLI", h->py_h, count, offset, flags);
+    r = PyObject_CallFunction (fn, "OILI", h->py_h, count, offset, flags);
     Py_DECREF (fn);
     if (check_python_failure ("extents") == -1)
       return -1;
 
     iter = PyObject_GetIter (r);
     if (iter == NULL) {
       nbdkit_error ("extents method did not return "
                     "something which is iterable");
       Py_DECREF (r);
       return -1;
-- 
2.33.1




More information about the Libguestfs mailing list