|
|
efa7a1 |
From b646050b8da51c39cf21f95fa847c12784a1169c Mon Sep 17 00:00:00 2001
|
|
|
efa7a1 |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
efa7a1 |
Date: Thu, 21 Nov 2019 15:02:44 +0000
|
|
|
60545c |
Subject: [PATCH 04/19] python: Add various constants to the API.
|
|
|
efa7a1 |
|
|
|
efa7a1 |
These are accessible from the plugin by:
|
|
|
efa7a1 |
|
|
|
efa7a1 |
import nbdkit
|
|
|
efa7a1 |
|
|
|
efa7a1 |
if flags & nbdkit.FLAG_MAY_TRIM:
|
|
|
efa7a1 |
&c.
|
|
|
efa7a1 |
|
|
|
efa7a1 |
Many (all?) of these are not yet useful for plugins, some will never
|
|
|
efa7a1 |
be useful, but they only consume a tiny bit of memory and it's nice to
|
|
|
efa7a1 |
have the complete set available for future use.
|
|
|
efa7a1 |
|
|
|
efa7a1 |
(cherry picked from commit 14b7fe2e0de881e3dfc8803484ade29a61e323c9)
|
|
|
efa7a1 |
---
|
|
|
efa7a1 |
plugins/python/python.c | 30 ++++++++++++++++++++++++++++++
|
|
|
efa7a1 |
1 file changed, 30 insertions(+)
|
|
|
efa7a1 |
|
|
|
efa7a1 |
diff --git a/plugins/python/python.c b/plugins/python/python.c
|
|
|
60545c |
index 7052aac0..47da0838 100644
|
|
|
efa7a1 |
--- a/plugins/python/python.c
|
|
|
efa7a1 |
+++ b/plugins/python/python.c
|
|
|
efa7a1 |
@@ -231,6 +231,36 @@ create_nbdkit_module (void)
|
|
|
efa7a1 |
nbdkit_error ("could not create the nbdkit API module");
|
|
|
efa7a1 |
exit (EXIT_FAILURE);
|
|
|
efa7a1 |
}
|
|
|
efa7a1 |
+
|
|
|
efa7a1 |
+ /* Constants corresponding to various flags. */
|
|
|
efa7a1 |
+#define ADD_INT_CONSTANT(name) \
|
|
|
efa7a1 |
+ if (PyModule_AddIntConstant (m, #name, NBDKIT_##name) == -1) { \
|
|
|
efa7a1 |
+ nbdkit_error ("could not add constant %s to nbdkit API module", \
|
|
|
efa7a1 |
+ #name); \
|
|
|
efa7a1 |
+ exit (EXIT_FAILURE); \
|
|
|
efa7a1 |
+ }
|
|
|
efa7a1 |
+ ADD_INT_CONSTANT (THREAD_MODEL_SERIALIZE_CONNECTIONS);
|
|
|
efa7a1 |
+ ADD_INT_CONSTANT (THREAD_MODEL_SERIALIZE_ALL_REQUESTS);
|
|
|
efa7a1 |
+ ADD_INT_CONSTANT (THREAD_MODEL_SERIALIZE_REQUESTS);
|
|
|
efa7a1 |
+ ADD_INT_CONSTANT (THREAD_MODEL_PARALLEL);
|
|
|
efa7a1 |
+
|
|
|
efa7a1 |
+ ADD_INT_CONSTANT (FLAG_MAY_TRIM);
|
|
|
efa7a1 |
+ ADD_INT_CONSTANT (FLAG_FUA);
|
|
|
efa7a1 |
+ ADD_INT_CONSTANT (FLAG_REQ_ONE);
|
|
|
efa7a1 |
+ ADD_INT_CONSTANT (FLAG_FAST_ZERO);
|
|
|
efa7a1 |
+
|
|
|
efa7a1 |
+ ADD_INT_CONSTANT (FUA_NONE);
|
|
|
efa7a1 |
+ ADD_INT_CONSTANT (FUA_EMULATE);
|
|
|
efa7a1 |
+ ADD_INT_CONSTANT (FUA_NATIVE);
|
|
|
efa7a1 |
+
|
|
|
efa7a1 |
+ ADD_INT_CONSTANT (CACHE_NONE);
|
|
|
efa7a1 |
+ ADD_INT_CONSTANT (CACHE_EMULATE);
|
|
|
efa7a1 |
+ ADD_INT_CONSTANT (CACHE_NATIVE);
|
|
|
efa7a1 |
+
|
|
|
efa7a1 |
+ ADD_INT_CONSTANT (EXTENT_HOLE);
|
|
|
efa7a1 |
+ ADD_INT_CONSTANT (EXTENT_ZERO);
|
|
|
efa7a1 |
+#undef ADD_INT_CONSTANT
|
|
|
efa7a1 |
+
|
|
|
efa7a1 |
return m;
|
|
|
efa7a1 |
}
|
|
|
efa7a1 |
|
|
|
efa7a1 |
--
|
|
|
efa7a1 |
2.18.2
|
|
|
efa7a1 |
|