From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=39712 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJ2IO-0008KK-EM for qemu-devel@nongnu.org; Thu, 18 Nov 2010 06:04:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PJ2IM-0002ve-VX for qemu-devel@nongnu.org; Thu, 18 Nov 2010 06:04:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40209) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PJ2IM-0002vM-Nf for qemu-devel@nongnu.org; Thu, 18 Nov 2010 06:04:50 -0500 Message-ID: <4CE50849.5090302@redhat.com> Date: Thu, 18 Nov 2010 12:04:41 +0100 From: Jes Sorensen MIME-Version: 1.0 Subject: Re: [Qemu-devel] [RFC][PATCH v3 02/21] virtproxy: qemu-vp, standalone daemon skeleton References: <1289870175-14880-1-git-send-email-mdroth@linux.vnet.ibm.com> <1289870175-14880-3-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1289870175-14880-3-git-send-email-mdroth@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Roth Cc: agl@linux.vnet.ibm.com, abeekhof@redhat.com, qemu-devel@nongnu.org, aliguori@linux.vnet.ibm.com, ryanh@us.ibm.com, amit.shah@redhat.com On 11/16/10 02:15, Michael Roth wrote: > Daemon to be run in guest, or on host in standalone mode. > (re-)implements some qemu utility functions used by core virtproxy.c > code via wrapper functions. For built-in virtproxy code we will define > these wrapper functions in terms of qemu's built-in implementations. > > Main logic will come in a later patch. > > Signed-off-by: Michael Roth Hi Michael, A couple of comments: > +/* mirror qemu I/O-related code for standalone daemon */ > +typedef struct IOHandlerRecord { > + int fd; > + IOCanReadHandler *fd_read_poll; > + IOHandler *fd_read; > + IOHandler *fd_write; > + int deleted; > + void *opaque; > + /* temporary data */ > + struct pollfd *ufd; > + QLIST_ENTRY(IOHandlerRecord) next; > +} IOHandlerRecord; Please move this to a header file. Any chance you could avoid some of all those ugly typedefs too? I know we have way too many of the already, but if it doesn't need to be a typedef, it's better not to make it one. > +static QLIST_HEAD(, IOHandlerRecord) io_handlers = > + QLIST_HEAD_INITIALIZER(io_handlers); > + > +int vp_set_fd_handler2(int fd, > + IOCanReadHandler *fd_read_poll, > + IOHandler *fd_read, > + IOHandler *fd_write, > + void *opaque) The formatting here is really odd, please make sure to align all arguments, and maybe compress the lines a bit so it doesn't take up as much realestate when you read the code. > +int vp_send_all(int fd, const void *buf, int len1) > +{ > + int ret, len; > + > + len = len1; > + while (len > 0) { > + ret = write(fd, buf, len); > + if (ret < 0) { > + if (errno != EINTR && errno != EAGAIN) { > + warn("write() failed"); > + return -1; Is -1 really an ideal error value to return here? > +static void main_loop_wait(int nonblocking) > +{ > + IOHandlerRecord *ioh; > + fd_set rfds, wfds, xfds; > + int ret, nfds; > + struct timeval tv; No good, please use qemu_timeval and friends for compatibility. > + int timeout = 1000; > + > + if (nonblocking) { > + timeout = 0; > + } > + > + /* poll any events */ > + nfds = -1; > + FD_ZERO(&rfds); > + FD_ZERO(&wfds); > + FD_ZERO(&xfds); > + QLIST_FOREACH(ioh, &io_handlers, next) { > + if (ioh->deleted) > + continue; Missing braces. > + if (ioh->fd_read && > + (!ioh->fd_read_poll || > + ioh->fd_read_poll(ioh->opaque) != 0)) { Put the || arguments on the same line so it is easier to read. > + FD_SET(ioh->fd, &rfds); > + if (ioh->fd > nfds) > + nfds = ioh->fd; Missing braces. > + } > + if (ioh->fd_write) { > + FD_SET(ioh->fd, &wfds); > + if (ioh->fd > nfds) > + nfds = ioh->fd; and again. Cheers, Jes