From patchwork Fri Apr 16 11:14:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 50316 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 BE760B7D55 for ; Fri, 16 Apr 2010 21:24:37 +1000 (EST) Received: from localhost ([127.0.0.1]:33550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O2ja1-0003qi-TL for incoming@patchwork.ozlabs.org; Fri, 16 Apr 2010 07:19:25 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O2jVF-0002qs-Lo for qemu-devel@nongnu.org; Fri, 16 Apr 2010 07:14:29 -0400 Received: from [140.186.70.92] (port=34502 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O2jVE-0002pu-H1 for qemu-devel@nongnu.org; Fri, 16 Apr 2010 07:14:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O2jVC-0006eo-KA for qemu-devel@nongnu.org; Fri, 16 Apr 2010 07:14:28 -0400 Received: from lo.gmane.org ([80.91.229.12]:52430) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2jVC-0006eC-6j for qemu-devel@nongnu.org; Fri, 16 Apr 2010 07:14:26 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1O2jV6-0007Gx-9M for qemu-devel@nongnu.org; Fri, 16 Apr 2010 13:14:20 +0200 Received: from nat-pool-brq-t.redhat.com ([209.132.186.34]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 16 Apr 2010 13:14:20 +0200 Received: from pbonzini by nat-pool-brq-t.redhat.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 16 Apr 2010 13:14:20 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: qemu-devel@nongnu.org connect(): No such file or directory From: Paolo Bonzini Date: Fri, 16 Apr 2010 13:14:11 +0200 Lines: 56 Message-ID: <4BC84683.7050003@redhat.com> References: <4B190919.9040602@siemens.com> <20100416110044.GC5048@redhat.com> Mime-Version: 1.0 X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: nat-pool-brq-t.redhat.com User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8) Gecko/20100301 Fedora/3.0.3-1.fc12 Lightning/1.0b2pre Thunderbird/3.0.3 In-Reply-To: <20100416110044.GC5048@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Jan Kiszka , Anthony Liguori , qemu-devel Subject: [Qemu-devel] Re: [FOR 0.12][PATCH] monitor: Accept input only byte-wise 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 > The QEMU code appears to be written to assume that it will recvmsg() a > complete monitor command in one go + process that, because it closes the > FD the moment the data from any recvmsg() is dealt with. This is buggy anyway. This should fix it too: Paolo diff --git a/monitor.c b/monitor.c index 5659991..225a922 100644 --- a/monitor.c +++ b/monitor.c @@ -2408,15 +2408,6 @@ return -1; } - fd = dup(fd); - if (fd == -1) { - if (errno == EMFILE) - qerror_report(QERR_TOO_MANY_FILES); - else - qerror_report(QERR_UNDEFINED_ERROR); - return -1; - } - QLIST_FOREACH(monfd, &mon->fds, next) { if (strcmp(monfd->name, fdname) != 0) { continue; diff --git a/qemu-char.c b/qemu-char.c index 05df971..ac65a1c 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2000,8 +2000,9 @@ static int tcp_get_msgfd(CharDriverState *chr) { TCPCharDriver *s = chr->opaque; - - return s->msgfd; + int fd = s->msgfd; + s->msgfd = -1; + return fd; } #ifndef _WIN32 @@ -2089,10 +2090,6 @@ static void tcp_chr_read(void *opaque) tcp_chr_process_IAC_bytes(chr, s, buf, &size); if (size > 0) qemu_chr_read(chr, buf, size); - if (s->msgfd != -1) { - close(s->msgfd); - s->msgfd = -1; - } } }