[Libguestfs] [PATCH nbdkit 4/5] python: Implement get_ready method.

Richard W.M. Jones rjones at redhat.com
Tue Feb 25 10:30:55 UTC 2020


---
 plugins/python/nbdkit-python-plugin.pod |  6 ++++++
 plugins/python/python.c                 | 21 +++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/plugins/python/nbdkit-python-plugin.pod b/plugins/python/nbdkit-python-plugin.pod
index 4065ec75..454a17ca 100644
--- a/plugins/python/nbdkit-python-plugin.pod
+++ b/plugins/python/nbdkit-python-plugin.pod
@@ -152,6 +152,12 @@ There are no arguments or return value.
 
 There are no arguments or return value.
 
+=item C<get_ready>
+
+(Optional)
+
+There are no arguments or return value.
+
 =item C<open>
 
 (Required)
diff --git a/plugins/python/python.c b/plugins/python/python.c
index 5e2e5269..72f37dd7 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -436,6 +436,25 @@ py_config_complete (void)
   return 0;
 }
 
+static int
+py_get_ready (void)
+{
+  PyObject *fn;
+  PyObject *r;
+
+  if (callback_defined ("get_ready", &fn)) {
+    PyErr_Clear ();
+
+    r = PyObject_CallObject (fn, NULL);
+    Py_DECREF (fn);
+    if (check_python_failure ("get_ready") == -1)
+      return -1;
+    Py_DECREF (r);
+  }
+
+  return 0;
+}
+
 static void *
 py_open (int readonly)
 {
@@ -889,6 +908,8 @@ static struct nbdkit_plugin plugin = {
   .config_complete   = py_config_complete,
   .config_help       = py_config_help,
 
+  .get_ready         = py_get_ready,
+
   .open              = py_open,
   .close             = py_close,
 
-- 
2.25.0




More information about the Libguestfs mailing list