From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=53744 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Petqu-0002Cg-7b for qemu-devel@nongnu.org; Mon, 17 Jan 2011 13:30:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Petqr-0001xS-Ew for qemu-devel@nongnu.org; Mon, 17 Jan 2011 13:30:52 -0500 Received: from e35.co.us.ibm.com ([32.97.110.153]:35335) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Petqr-0001xO-6o for qemu-devel@nongnu.org; Mon, 17 Jan 2011 13:30:49 -0500 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e35.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p0HIH25G015728 for ; Mon, 17 Jan 2011 11:17:02 -0700 Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id p0HIUVE8170502 for ; Mon, 17 Jan 2011 11:30:32 -0700 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p0HIUVSg009839 for ; Mon, 17 Jan 2011 11:30:31 -0700 Message-ID: <4D348AC2.1050902@linux.vnet.ibm.com> Date: Mon, 17 Jan 2011 12:30:26 -0600 From: Michael Roth MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [PATCH v2 0/5] iohandlers: Add support for enabling/disabling individual handlers References: <4D2F4FC2.1060408@codemonkey.ws> <20110117101806.GA14607@amit-x200.redhat.com> <4D3458CC.1070004@codemonkey.ws> In-Reply-To: <4D3458CC.1070004@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah Cc: Gerd Hoffmann , Paul Brook , qemu list On 01/17/2011 08:57 AM, Anthony Liguori wrote: > On 01/17/2011 04:18 AM, Amit Shah wrote: >> On (Thu) Jan 13 2011 [13:17:22], Anthony Liguori wrote: >>> On 01/13/2011 09:00 AM, Amit Shah wrote: >>>> Hi, >>>> >>>> This patchset adds new interfaces to work with iohandlers. It adds: >>>> >>>> int assign_fd_handlers(int fd, IOHandlerOps *ops, void *opaque) >>>> -- Specify io handlers for an fd >>>> int remove_fd_handlers(int fd) >>>> -- Remove fd handlers for fd (mark ioh for deletion) >>>> int set_read_poll_fd_action(int fd, bool enable) >>>> -- Enable or disable the fd_read_poll fd handler >>>> int set_read_fd_action(int fd, bool enable) >>>> -- Enable or disable the fd_read fd handler >>>> int set_write_fd_action(int fd, bool enable) >>>> -- Enable or disable the fd_read fd handler >>>> >>>> A new struct, IOHandlerOps, is added, to collect all the ops together >>>> instead of passing individual ones to functions. >>> Instead of inventing new interfaces, I think we should steal^Wlearn >>> from established interfaces. >> Agreed. >> >> I do also think it'll be worthwhile pulling in one of the libraries to >> reduce the amount of qemu-specific code we have in the other cases as >> well. >> >>> Both libevent and glib have interfaces >>> that essentially boil down to: >>> >>> handle add_fd_event(loop, fd, ConditionMask, callback, opaque) >>> remove_event(loop, handle) >> This is quite similar to the Linux polling API. >> >> I don't know what the 'loop' parameter would do, though. > > It's to allow for multiple I/O threads. There's one loop context per > thread and you can register events specifically to a thread. > In case you're interested, to make the fd handler stuff accessible to qemu tools I have some code that moves these interfaces into backend functions in another file, qemu-ioh.c, where the IOHandlerRecord list is supplied by the caller to track state. This would extend naturally to threads by just having them maintain their own IOHandlerRecord lists as well, and stuff that is meant to interact with vl.c:io_handlers can be done via wrapper functions for backward-compatibility. If that seems like a reasonable approach maybe you could leverage these patches remove some of the scope for your proposed changes: http://repo.or.cz/w/qemu/mdroth.git/patch/56a391e85124382ddcbdb64dcc05aadfc965f000 http://repo.or.cz/w/qemu/mdroth.git/patch/f4428e2cdf5da231bb30ce1ed9eb5ce567a9dc55