From patchwork Fri Dec 3 18:03:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 74179 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E03601007D6 for ; Sat, 4 Dec 2010 05:09:49 +1100 (EST) Received: from localhost ([127.0.0.1]:43077 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POa4o-0005DK-GG for incoming@patchwork.ozlabs.org; Fri, 03 Dec 2010 13:09:46 -0500 Received: from [140.186.70.92] (port=44333 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POZz8-0001vY-Bl for qemu-devel@nongnu.org; Fri, 03 Dec 2010 13:03:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1POZz6-0003B4-SB for qemu-devel@nongnu.org; Fri, 03 Dec 2010 13:03:54 -0500 Received: from e1.ny.us.ibm.com ([32.97.182.141]:35982) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1POZz6-0003As-Pk for qemu-devel@nongnu.org; Fri, 03 Dec 2010 13:03:52 -0500 Received: from d01dlp01.pok.ibm.com (d01dlp01.pok.ibm.com [9.56.224.56]) by e1.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id oB3HtljP014741 for ; Fri, 3 Dec 2010 12:55:47 -0500 Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 201B6728047 for ; Fri, 3 Dec 2010 13:03:51 -0500 (EST) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay05.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oB3I3oo9163394 for ; Fri, 3 Dec 2010 13:03:50 -0500 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id oB3I3nPC013074 for ; Fri, 3 Dec 2010 13:03:49 -0500 Received: from localhost.localdomain (sig-9-65-101-53.mts.ibm.com [9.65.101.53]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id oB3I3S9Z011647; Fri, 3 Dec 2010 13:03:48 -0500 From: Michael Roth To: qemu-devel@nongnu.org Date: Fri, 3 Dec 2010 12:03:03 -0600 Message-Id: <1291399402-20366-3-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1291399402-20366-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1291399402-20366-1-git-send-email-mdroth@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: agl@linux.vnet.ibm.com, stefanha@linux.vnet.ibm.com, Jes.Sorensen@redhat.com, mdroth@linux.vnet.ibm.com, aliguori@linux.vnet.ibm.com, ryanh@us.ibm.com, abeekhof@redhat.com Subject: [Qemu-devel] [RFC][PATCH v5 02/21] Add qemu_set_fd_handler() wrappers to qemu-tools.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This adds state information for managing fd handlers to qemu-tools.c so that tools that build against it can implement an I/O loop for interacting with objects that use qemu_set_fd_handler() Signed-off-by: Michael Roth --- qemu-tool.c | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletions(-) diff --git a/qemu-tool.c b/qemu-tool.c index 392e1c9..78d3532 100644 --- a/qemu-tool.c +++ b/qemu-tool.c @@ -22,6 +22,8 @@ QEMUClock *rt_clock; FILE *logfile; +static QLIST_HEAD(, IOHandlerRecord) io_handlers = + QLIST_HEAD_INITIALIZER(io_handlers); struct QEMUBH { @@ -103,11 +105,32 @@ void qemu_bh_delete(QEMUBH *bh) qemu_free(bh); } +/* definitions to implement i/o loop for fd handlers in tools */ int qemu_set_fd_handler2(int fd, IOCanReadHandler *fd_read_poll, IOHandler *fd_read, IOHandler *fd_write, void *opaque) { - return 0; + return qemu_set_fd_handler3(&io_handlers, fd, fd_read_poll, fd_read, + fd_write, opaque); +} + +int qemu_set_fd_handler(int fd, + IOHandler *fd_read, + IOHandler *fd_write, + void *opaque) +{ + return qemu_set_fd_handler2(fd, NULL, fd_read, fd_write, opaque); +} + +void qemu_get_fdset(int *nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds) +{ + return qemu_get_fdset2(&io_handlers, nfds, rfds, wfds, xfds); +} + +void qemu_process_fd_handlers(const fd_set *rfds, const fd_set *wfds, + const fd_set *xfds) +{ + return qemu_process_fd_handlers2(&io_handlers, rfds, wfds, xfds); }