From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xhayi-00073w-1O for qemu-devel@nongnu.org; Fri, 24 Oct 2014 05:16:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XhayX-0002RD-F9 for qemu-devel@nongnu.org; Fri, 24 Oct 2014 05:16:11 -0400 Received: from mail-wi0-x22d.google.com ([2a00:1450:400c:c05::22d]:37153) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XhayX-0002QQ-8n for qemu-devel@nongnu.org; Fri, 24 Oct 2014 05:16:01 -0400 Received: by mail-wi0-f173.google.com with SMTP id ex7so712622wid.12 for ; Fri, 24 Oct 2014 02:16:00 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <544A18C4.5080405@redhat.com> Date: Fri, 24 Oct 2014 11:15:48 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1414138427-60643-1-git-send-email-graalfs@linux.vnet.ibm.com> In-Reply-To: <1414138427-60643-1-git-send-email-graalfs@linux.vnet.ibm.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC 0/3] qemu-char: Add poll timeouts for character backends List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Heinz Graalfs , qemu-devel@nongnu.org Cc: cornelia.huck@de.ibm.com, borntraeger@de.ibm.com On 10/24/2014 10:13 AM, Heinz Graalfs wrote: > On s390 one can observe system hang situations wrt console input when > using 'dataplane=on'. > > dataplane processing causes an inactive main thread and an active > dataplane thread. > > When a character backend descriptor disappears from the main thread's > poll() descriptor array (when can_read() returns 0) it happens that it > will never reappear in the poll() array due to missing poll() interrupts. > > The following patches fix observed hangs on s390 and provide a means > to avoid potential hangs in other backends/frontends. I think all you need is a simple qemu_notify_event(); call when can_read can go from 0 to 1, for example just before get_console_data returns (for hw/char/sclpconsole-lm.c). By the way, for hw/char/sclpconsole-lm.c I'm not sure what happens if scon->length == SIZE_CONSOLE_BUFFER. You cannot read, so you cannot generate an event, and you cannot reset scon->length because you cannot generate an event. I think something like this is needed: diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c index 80dd0a9..c61b77b 100644 --- a/hw/char/sclpconsole-lm.c +++ b/hw/char/sclpconsole-lm.c @@ -61,10 +61,9 @@ static int chr_can_read(void *opaque) if (scon->event.event_pending) { return 0; - } else if (SIZE_CONSOLE_BUFFER - scon->length) { + } else { return 1; } - return 0; } static void chr_read(void *opaque, const uint8_t *buf, int size) @@ -78,6 +77,10 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) sclp_service_interrupt(0); return; } + if (scon->length == SIZE_CONSOLE_BUFFER) { + /* Eat the character, but still process CR and LF. */ + return; + } scon->buf[scon->length] = *buf; scon->length += 1; if (scon->echo) { Paolo