From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= Subject: Re: [PATCH v2 1/3] python: Add binding for xs_fileno() Date: Thu, 21 Sep 2017 20:04:18 +0200 Message-ID: <20170921180418.GF1116@mail-itl> References: <1506012428-59769-1-git-send-email-euan.harris@citrix.com> <1506012428-59769-2-git-send-email-euan.harris@citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5095911321389945258==" Return-path: Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv5pr-0007j5-Kv for xen-devel@lists.xenproject.org; Thu, 21 Sep 2017 18:04:27 +0000 In-Reply-To: <1506012428-59769-2-git-send-email-euan.harris@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: Euan Harris Cc: xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org --===============5095911321389945258== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="leQ0ainWKcxhm+Q3" Content-Disposition: inline --leQ0ainWKcxhm+Q3 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 21, 2017 at 05:47:06PM +0100, Euan Harris wrote: > 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. >=20 > Signed-off-by: Euan Harris > Reviewed-by: Konrad Rzeszutek Wilk > Reviewed-by: Wei Liu > --- > tools/python/xen/lowlevel/xs/xs.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) >=20 > diff --git a/tools/python/xen/lowlevel/xs/xs.c b/tools/python/xen/lowleve= l/xs/xs.c > index aba5a20..9f1b916 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) > } > =20 > =20 > +#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 =3D xshandle(self); > + int fd; > + > + if (!xh) > + return NULL; > + > + fd =3D xs_fileno(xh); > + > + return PyInt_FromLong(fd); Use PyLong_FromLong. There is no PyInt_* in py3k. But for convenience we have #define PyLong_FromLong -> PyInt_FromLong for python 2. > +} > + > + > #define xspy_read_watch_doc "\n" \ > "Read a watch notification.\n" \ > "\n" \ > @@ -887,6 +906,7 @@ static PyMethodDef xshandle_methods[] =3D { > 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. */ }, > }; > =20 --=20 Best Regards, Marek Marczykowski-G=C3=B3recki Invisible Things Lab A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? --leQ0ainWKcxhm+Q3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJZw/8lAAoJENuP0xzK19cs4gsH/36sv267VZVMl/kJRJiDOYlO JvDiJ5OpcggHaRrOM75rrtal9RwmNyLid/FJHBwlH859J2iYUV/cTRL5CoyOl1Wm ceejnaCSlcyodlm9VhIEUf2h9ujpScRtgekwBHLeuWam7tJ6s9yRInK6JuxGOrut u1R+xmn2bZ7QPf2CgOtg8/VhTbD+KvRSB6PBZ5sd5ZRBd9a6r3JRDE8PNxc8BNZ+ S0idfdKduaeqDj1Uo3dWt3jFfBTUsHLS+7g3VYud64KdddEKyI5XiWJb4ldj+bYx pADJgt9G60+8IsEDVZ+c6ihdTKrlWNVktt3NBG5sIYlryL8GQZYReIlldHv9c9c= =uea8 -----END PGP SIGNATURE----- --leQ0ainWKcxhm+Q3-- --===============5095911321389945258== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --===============5095911321389945258==--