From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O2jV4-0002jl-Uk for qemu-devel@nongnu.org; Fri, 16 Apr 2010 07:14:19 -0400 Received: from [140.186.70.92] (port=34463 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O2jV3-0002iw-Ns for qemu-devel@nongnu.org; Fri, 16 Apr 2010 07:14:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O2jV1-0006d6-Vi for qemu-devel@nongnu.org; Fri, 16 Apr 2010 07:14:17 -0400 Received: from mail-ew0-f227.google.com ([209.85.219.227]:49602) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O2jV1-0006cx-NS for qemu-devel@nongnu.org; Fri, 16 Apr 2010 07:14:15 -0400 Received: by ewy27 with SMTP id 27so779860ewy.10 for ; Fri, 16 Apr 2010 04:14:14 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4BC84683.7050003@redhat.com> Date: Fri, 16 Apr 2010 13:14:11 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <4B190919.9040602@siemens.com> <20100416110044.GC5048@redhat.com> In-Reply-To: <20100416110044.GC5048@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [FOR 0.12][PATCH] monitor: Accept input only byte-wise List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: Jan Kiszka , Anthony Liguori , qemu-devel > 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: 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; - } } } Paolo