From: Euan Harris Date: Fri, 22 Sep 2017 16:21:12 +0000 (+0100) Subject: python: Add binding for xs_fileno() X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~1338 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=43fd62ce1615ffe78a93eb0fe41653daf356847c;p=xen.git python: Add binding for xs_fileno() 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 Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Wei Liu Acked-by: Marek Marczykowski-Górecki --- diff --git a/tools/python/xen/lowlevel/xs/xs.c b/tools/python/xen/lowlevel/xs/xs.c index aba5a20930..3a827b0228 100644 --- a/tools/python/xen/lowlevel/xs/xs.c +++ b/tools/python/xen/lowlevel/xs/xs.c @@ -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. */ }, };