From: Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= Subject: Re: [PATCH v3 1/3] python: Add binding for xs_fileno() Date: Fri, 22 Sep 2017 19:50:04 +0200 Message-ID: <20170922175004.GU1116@mail-itl> References: <1506097274-130806-1-git-send-email-euan.harris@citrix.com> <1506097274-130806-2-git-send-email-euan.harris@citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8211194875747753882==" 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 1dvS5a-0004Wd-RN for xen-devel@lists.xenproject.org; Fri, 22 Sep 2017 17:50:10 +0000 In-Reply-To: <1506097274-130806-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 --===============8211194875747753882== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="TuLZpJsoCmPfu6RO" Content-Disposition: inline --TuLZpJsoCmPfu6RO Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 22, 2017 at 05:21:12PM +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 Acked-by: Marek Marczykowski-G=C3=B3recki > --- > Changed since v2: > * Use PyLong_FromLong instead of PyInt_FromLong > --- > 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..3a827b0 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 PyLong_FromLong(fd); > +} > + > + > #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? --TuLZpJsoCmPfu6RO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJZxU1KAAoJENuP0xzK19csKpEIAJPBdVM+lqCA0eipfPzOTf4t QbM2AszPFRpiAP/pljaZgqwTqnh+7Df71BgZ9JVwXv43cHjtdey+kZFnciLiqI5W XdldE5/4d0HaBUh26FfJLarW86TaSrjRDJ2X/06LKo3bUzMEM9Fo/lELXyQSstO4 UwB+fcE581D+Aa79asomzylGKoTqgc7hEsAeOrLm2YO1CNx8fRTRHV5EVL5xHDj4 cA/+wZ2gr/qI7JTmkZmJJXR2p8FaEQDY+F6NluOfEkp715gcewgpXA+LE+prDPOL 6qMLAO851yxly/bTBI8FLRErCvdqePK0yhDc+QplPRlw8J5HIo4JHo2T/UYmsrQ= =HxHZ -----END PGP SIGNATURE----- --TuLZpJsoCmPfu6RO-- --===============8211194875747753882== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --===============8211194875747753882==--