]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
python: Add binding for xs_fileno()
authorEuan Harris <euan.harris@citrix.com>
Fri, 22 Sep 2017 16:21:12 +0000 (17:21 +0100)
committerWei Liu <wei.liu2@citrix.com>
Mon, 25 Sep 2017 13:35:45 +0000 (14:35 +0100)
xs_fileno() returns a file descriptor which receives events when Xenstore
watches fire.   Exposing this in the Python bindings is a prerequisite
for writing event-driven clients in Python.

Signed-off-by: Euan Harris <euan.harris@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
tools/python/xen/lowlevel/xs/xs.c

index aba5a20930ac98a0a7d26ab30e8b7edfc858fe9c..3a827b02286e9f35d5b39f95ce7d04eaa08b8a49 100644 (file)
@@ -453,6 +453,25 @@ static PyObject *xspy_watch(XsHandle *self, PyObject *args)
 }
 
 
+#define xspy_fileno_doc "\n"                              \
+       "Return the FD to poll for notifications when watches fire.\n"   \
+       "Returns: [int] file descriptor.\n"                \
+       "\n"
+
+static PyObject *xspy_fileno(XsHandle *self)
+{
+    struct xs_handle *xh = xshandle(self);
+    int fd;
+
+    if (!xh)
+        return NULL;
+
+    fd = xs_fileno(xh);
+
+    return PyLong_FromLong(fd);
+}
+
+
 #define xspy_read_watch_doc "\n"                               \
        "Read a watch notification.\n"                          \
        "\n"                                                    \
@@ -887,6 +906,7 @@ static PyMethodDef xshandle_methods[] = {
     XSPY_METH(release_domain,    METH_VARARGS),
     XSPY_METH(close,             METH_NOARGS),
     XSPY_METH(get_domain_path,   METH_VARARGS),
+    XSPY_METH(fileno,            METH_NOARGS),
     { NULL /* Sentinel. */ },
 };