From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KJlyn-0004aY-Cf for qemu-devel@nongnu.org; Fri, 18 Jul 2008 05:10:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KJlyi-0004ZT-3f for qemu-devel@nongnu.org; Fri, 18 Jul 2008 05:10:20 -0400 Received: from [199.232.76.173] (port=37882 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KJlyh-0004ZF-Qt for qemu-devel@nongnu.org; Fri, 18 Jul 2008 05:10:15 -0400 Received: from mx1.redhat.com ([66.187.233.31]:58620) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KJlyh-0005uh-5D for qemu-devel@nongnu.org; Fri, 18 Jul 2008 05:10:15 -0400 Message-ID: <48805DE9.9050105@redhat.com> Date: Fri, 18 Jul 2008 11:10:01 +0200 From: Gerd Hoffmann MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 2/2] open ptys in non-blocking mode. References: <1215605958-22623-1-git-send-email-kraxel@redhat.com> <1215605958-22623-2-git-send-email-kraxel@redhat.com> <4880574C.1020703@suse.de> In-Reply-To: <4880574C.1020703@suse.de> Content-Type: multipart/mixed; boundary="------------080509070707030502070305" Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: xen-devel@lists.xensource.com, Ian Jackson , qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------080509070707030502070305 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Kevin Wolf wrote: > [Crossposting to xen-devel] > > Ian, we need something like this for qemu-xen (or ioemu-remote or > whatever it's called now). Currently you must attach to the console of a > domain, otherwise it won't boot up and keep hanging in a blocking write > because the buffer is full. > > The old ioemu had a hack in unix_write (doing a select before the write) > which you didn't merge into qemu-xen. In fact, I noticed that you even > removed that function entirely and I'm wondering why. For completeness: You also need the attached patch for unix_write, otherwise you'll end up with qemu burning cpu cycles. If you can't write to a non-blocking file handle the write will instantly return with -EAGAIN. Calling it again of course doesn't change the result, so better don't do that ... -- http://kraxel.fedorapeople.org/xenner/ --------------080509070707030502070305 Content-Type: text/x-patch; name="0002-unix_write-don-t-block-on-non-blocking-file-handles.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0002-unix_write-don-t-block-on-non-blocking-file-handles.pat"; filename*1="ch" >>From d9454802fa2105bc399518eebfa1e1415ff07143 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 9 Jul 2008 09:41:31 +0200 Subject: [PATCH 02/12] unix_write: don't block on non-blocking file handles. Signed-off-by: Gerd Hoffmann --- vl.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/vl.c b/vl.c index c8db579..2e2d883 100644 --- a/vl.c +++ b/vl.c @@ -2116,14 +2116,24 @@ void socket_set_nonblock(int fd) static int unix_write(int fd, const uint8_t *buf, int len1) { + int nonblock = fcntl(fd, F_GETFL) & O_NONBLOCK; int ret, len; len = len1; while (len > 0) { ret = write(fd, buf, len); if (ret < 0) { - if (errno != EINTR && errno != EAGAIN) + if (errno == EINTR) { + continue; + } else if (errno == EAGAIN) { + if (!nonblock) + continue; + if (len1 != len) + break; /* partial write, return written bytes */ + return -1; + } else { return -1; + } } else if (ret == 0) { break; } else { -- 1.5.4.1 --------------080509070707030502070305-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gerd Hoffmann Subject: Re: [Qemu-devel] [PATCH 2/2] open ptys in non-blocking mode. Date: Fri, 18 Jul 2008 11:10:01 +0200 Message-ID: <48805DE9.9050105@redhat.com> References: <1215605958-22623-1-git-send-email-kraxel@redhat.com> <1215605958-22623-2-git-send-email-kraxel@redhat.com> <4880574C.1020703@suse.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080509070707030502070305" Return-path: In-Reply-To: <4880574C.1020703@suse.de> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Kevin Wolf Cc: xen-devel@lists.xensource.com, Ian Jackson , qemu-devel@nongnu.org List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------080509070707030502070305 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Kevin Wolf wrote: > [Crossposting to xen-devel] > > Ian, we need something like this for qemu-xen (or ioemu-remote or > whatever it's called now). Currently you must attach to the console of a > domain, otherwise it won't boot up and keep hanging in a blocking write > because the buffer is full. > > The old ioemu had a hack in unix_write (doing a select before the write) > which you didn't merge into qemu-xen. In fact, I noticed that you even > removed that function entirely and I'm wondering why. For completeness: You also need the attached patch for unix_write, otherwise you'll end up with qemu burning cpu cycles. If you can't write to a non-blocking file handle the write will instantly return with -EAGAIN. Calling it again of course doesn't change the result, so better don't do that ... -- http://kraxel.fedorapeople.org/xenner/ --------------080509070707030502070305 Content-Type: text/x-patch; name="0002-unix_write-don-t-block-on-non-blocking-file-handles.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0002-unix_write-don-t-block-on-non-blocking-file-handles.pat"; filename*1="ch" >>From d9454802fa2105bc399518eebfa1e1415ff07143 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 9 Jul 2008 09:41:31 +0200 Subject: [PATCH 02/12] unix_write: don't block on non-blocking file handles. Signed-off-by: Gerd Hoffmann --- vl.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/vl.c b/vl.c index c8db579..2e2d883 100644 --- a/vl.c +++ b/vl.c @@ -2116,14 +2116,24 @@ void socket_set_nonblock(int fd) static int unix_write(int fd, const uint8_t *buf, int len1) { + int nonblock = fcntl(fd, F_GETFL) & O_NONBLOCK; int ret, len; len = len1; while (len > 0) { ret = write(fd, buf, len); if (ret < 0) { - if (errno != EINTR && errno != EAGAIN) + if (errno == EINTR) { + continue; + } else if (errno == EAGAIN) { + if (!nonblock) + continue; + if (len1 != len) + break; /* partial write, return written bytes */ + return -1; + } else { return -1; + } } else if (ret == 0) { break; } else { -- 1.5.4.1 --------------080509070707030502070305 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------080509070707030502070305--