From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=59791 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPypy-0003Mw-9I for qemu-devel@nongnu.org; Tue, 07 Dec 2010 09:48:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PPypx-0007Zb-2Z for qemu-devel@nongnu.org; Tue, 07 Dec 2010 09:48:14 -0500 Received: from e6.ny.us.ibm.com ([32.97.182.146]:37885) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PPypw-0007ZV-Qr for qemu-devel@nongnu.org; Tue, 07 Dec 2010 09:48:13 -0500 Received: from d01dlp01.pok.ibm.com (d01dlp01.pok.ibm.com [9.56.224.56]) by e6.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id oB7EnA2j012375 for ; Tue, 7 Dec 2010 09:49:31 -0500 Received: from d01relay06.pok.ibm.com (d01relay06.pok.ibm.com [9.56.227.116]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 4E837728051 for ; Tue, 7 Dec 2010 09:48:11 -0500 (EST) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay06.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oB7EmAdc2367538 for ; Tue, 7 Dec 2010 09:48:10 -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 oB7Em9ft006346 for ; Tue, 7 Dec 2010 09:48:10 -0500 Message-ID: <4CFE4928.5000409@linux.vnet.ibm.com> Date: Tue, 07 Dec 2010 08:48:08 -0600 From: Michael Roth MIME-Version: 1.0 Subject: Re: [Qemu-devel] Re: [RFC][PATCH v5 01/21] Move code related to fd handlers into utility functions References: <1291399402-20366-1-git-send-email-mdroth@linux.vnet.ibm.com> <1291399402-20366-2-git-send-email-mdroth@linux.vnet.ibm.com> <4CFE3738.4010506@redhat.com> In-Reply-To: <4CFE3738.4010506@redhat.com> 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: Jes Sorensen Cc: agl@linux.vnet.ibm.com, stefanha@linux.vnet.ibm.com, abeekhof@redhat.com, qemu-devel@nongnu.org, aliguori@linux.vnet.ibm.com, ryanh@us.ibm.com On 12/07/2010 07:31 AM, Jes Sorensen wrote: > On 12/03/10 19:03, Michael Roth wrote: >> This allows us to implement an i/o loop outside of vl.c that can >> interact with objects that use qemu_set_fd_handler() >> >> Signed-off-by: Michael Roth > > This commit message really tells us nothing. Please be more specific > about what is in the commit. > Currently, in qemu, the virtagent client/server functionality is driven by vl.c:main_loop_wait(), which implements a select() loop that kicks off handlers registered for various FDs/events via qemu_set_fd_handler(). To share the code with the agent, qemu-va.c, I re-implemented this i/o loop to do same thing, along with vl.c:qemu_set_fd_handler*() and friends. It was big nasty copy/paste job and I think most of the reviewers agreed that the i/o loop code should be shared. This commit moves the shared code into back-end utility functions that get called by vl.c:qemu_set_fd_handler()/qemu_process_fd_handlers() and friends for qemu, and by qemu-tools.c:qemu_set_fd_handler()/qemu_process_fd_handlers() for tools. So now to interact with code that uses qemu_set_fd_handler() you can built a select() loop around these utility functions. >> diff --git a/qemu-ioh.c b/qemu-ioh.c >> new file mode 100644 >> index 0000000..cc71470 >> --- /dev/null >> +++ b/qemu-ioh.c >> @@ -0,0 +1,115 @@ >> +/* >> + * QEMU System Emulator >> + * >> + * Copyright (c) 2003-2008 Fabrice Bellard >> + * >> + * Permission is hereby granted, free of charge, to any person obtaining a copy >> + * of this software and associated documentation files (the "Software"), to deal >> + * in the Software without restriction, including without limitation the rights >> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell >> + * copies of the Software, and to permit persons to whom the Software is >> + * furnished to do so, subject to the following conditions: > > Is this moved or new code? If the former, fine, but if it is new code, > you might want to leave your own name on the (c). I presume at least > some of the changes are (c) 2010? > It's moved out from vl.c, nearly verbatim... >> +/* XXX: fd_read_poll should be suppressed, but an API change is >> + necessary in the character devices to suppress fd_can_read(). */ > > XXX in the comment isn't really of much use. Please make it more > explicit, or put your name in if it is a statement you wish to make. > Even down to the comments :) >> +int qemu_set_fd_handler3(void *ioh_record_list, >> + int fd, >> + IOCanReadHandler *fd_read_poll, >> + IOHandler *fd_read, >> + IOHandler *fd_write, >> + void *opaque) > > I am not happy with this addition of numbers to these functions, it > doesn't tell us why we have a 3 and how it differs from 2. If 3 is > really the backend for implementing 2, maybe it would be better to name > it __qemu_set_fd_handler2() and then have macros/wrappers calling into it. > That was the initial plan, but qemu_set_fd_handler2() is a back-end of sorts for qemu_set_fd_handler(), so I was just trying to be consistent with the naming. Personally I don't have any objections one way or the other. > Cheers, > Jes >