From patchwork Fri Sep 22 16:21:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Euan Harris X-Patchwork-Id: 9966515 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 691B660381 for ; Fri, 22 Sep 2017 16:23:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FC8A29915 for ; Fri, 22 Sep 2017 16:23:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54B3F29919; Fri, 22 Sep 2017 16:23:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 975A329918 for ; Fri, 22 Sep 2017 16:23:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dvQhj-000523-PC; Fri, 22 Sep 2017 16:21:27 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dvQhj-00051x-8q for xen-devel@lists.xenproject.org; Fri, 22 Sep 2017 16:21:27 +0000 Received: from [85.158.143.35] by server-11.bemta-6.messagelabs.com id EB/95-03616-68835C95; Fri, 22 Sep 2017 16:21:26 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKIsWRWlGSWpSXmKPExsXitHSDvW6rxdF IgzvrjS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1ox5izoYCw7xVEw/eISxgfE7ZxcjJ4eEgL/E wRXrWEBsNgEtid0fFrJ3MXJwiAioSNzeawASZhbwllg5/TgriC0sYC1x6fdjJhCbRUBV4s62E 6wg5bwC7hLfepIgJipITHn4nhnE5hTwkJjx9TkbiC0EVPKy5xILhK0s8eHKGnYQm1dAUOLkzC csEKskJA6+eME8gZF3FpLULCSpBYxMqxg1ilOLylKLdI3M9JKKMtMzSnITM3N0DQ3M9HJTi4s T01NzEpOK9ZLzczcxAgOHAQh2MJ5ZEHiIUZKDSUmUd4rp0UghvqT8lMqMxOKM+KLSnNTiQ4wy HBxKErzG5kA5waLU9NSKtMwcYAjDpCU4eJREeC1A0rzFBYm5xZnpEKlTjMYcxzZd/sPE0XHz7 h8mIZa8/LxUKXHeE2ZApQIgpRmleXCDYLF1iVFWSpiXEeg0IZ6C1KLczBJU+VeM4hyMSsK8lS ALeTLzSuD2vQI6hQnolPLVR0BOKUlESEk1MO6a5TpRfUqcepubs1neBI/P/vF3bn0yCnusn9U Tf/rOLK1VIcdzVk88fTb0wy2xPiO/UNO9+QteXVvllyiVvfretxW3V7nvchPZHGTteWqhx4c+ vtUfUlIUW4q3tp/T9IkK5nrvuuze2c91nlt25/xorlyeaF7gx+Kyk0+0+3Pl8tV5mhE6m5RYi jMSDbWYi4oTAXKcabioAgAA X-Env-Sender: prvs=43158390b=euan.harris@citrix.com X-Msg-Ref: server-14.tower-21.messagelabs.com!1506097284!77524432!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 18883 invoked from network); 22 Sep 2017 16:21:25 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-14.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 22 Sep 2017 16:21:25 -0000 X-IronPort-AV: E=Sophos;i="5.42,427,1500940800"; d="scan'208";a="448881121" From: Euan Harris To: Date: Fri, 22 Sep 2017 17:21:12 +0100 Message-ID: <1506097274-130806-2-git-send-email-euan.harris@citrix.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1506097274-130806-1-git-send-email-euan.harris@citrix.com> References: <1506097274-130806-1-git-send-email-euan.harris@citrix.com> MIME-Version: 1.0 Cc: Euan Harris , marmarek@invisiblethingslab.com Subject: [Xen-devel] [PATCH v3 1/3] python: Add binding for xs_fileno() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- Changed since v2: * Use PyLong_FromLong instead of PyInt_FromLong --- tools/python/xen/lowlevel/xs/xs.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/python/xen/lowlevel/xs/xs.c b/tools/python/xen/lowlevel/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) } +#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. */ }, };