From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVDmQ-0004bg-Ow for qemu-devel@nongnu.org; Thu, 04 Aug 2016 04:13:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVDmN-0002Uw-MW for qemu-devel@nongnu.org; Thu, 04 Aug 2016 04:13:25 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:46749) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVDmN-0002UR-DU for qemu-devel@nongnu.org; Thu, 04 Aug 2016 04:13:23 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u7489bmH030427 for ; Thu, 4 Aug 2016 04:13:23 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 24kkagy7bq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 04 Aug 2016 04:13:21 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 4 Aug 2016 09:13:17 +0100 Date: Thu, 4 Aug 2016 10:13:13 +0200 From: Cornelia Huck In-Reply-To: <1470241360-3574-4-git-send-email-berrange@redhat.com> References: <1470241360-3574-1-git-send-email-berrange@redhat.com> <1470241360-3574-4-git-send-email-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: <20160804101313.3ed44f42.cornelia.huck@de.ibm.com> Subject: Re: [Qemu-devel] [PATCH 3/5] sclpconsole: remove bogus check for -EAGAIN List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Paolo Bonzini , Amit Shah , Gerd Hoffmann On Wed, 3 Aug 2016 17:22:38 +0100 "Daniel P. Berrange" wrote: s/sclpconsole/sclpconsolelm/ in the subject, as there are two sclp consoles :) > The write_console_data() method in sclpconsole-lm.c checks > whether the return value of qemu_chr_fe_write() has the > value of -EAGAIN and if so then increments the buffer offset > by the value of EAGAIN. Fortunately qemu_chr_fe_write() will > never return EAGAIN directly, rather it returns -1 with > errno set to EAGAIN, so this broken code path was not > reachable. The behaviour on EAGAIN was stil bad though, > causing the write_console_data() to busy_wait repeatedly > calling qemu_chr_fe_write() with no sleep between iters. > > Just remove all this loop logic and replace with a call > to qemu_chr_fe_write_all(). > > Signed-off-by: Daniel P. Berrange > --- > hw/char/sclpconsole-lm.c | 18 +++--------------- > 1 file changed, 3 insertions(+), 15 deletions(-) > > diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c > index a22ad8d..8cb0026 100644 > --- a/hw/char/sclpconsole-lm.c > +++ b/hw/char/sclpconsole-lm.c > @@ -201,21 +201,9 @@ static int write_console_data(SCLPEvent *event, const uint8_t *buf, int len) > return len; > } > > - buf_offset = buf; > - while (len > 0) { > - ret = qemu_chr_fe_write(scon->chr, buf, len); > - if (ret == 0) { > - /* a pty doesn't seem to be connected - no error */ > - len = 0; > - } else if (ret == -EAGAIN || (ret > 0 && ret < len)) { > - len -= ret; > - buf_offset += ret; > - } else { > - len = 0; > - } > - } > - > - return ret; > + /* XXX this blocks entire thread. Rewrite to use > + * qemu_chr_fe_write and background I/O callbacks */ > + return qemu_chr_fe_write_all(scon->chr, buf, len); This is basically the same change that had been done for the sclp vt220 console already in 2e14211 ("s390/sclpconsole: handle char layer busy conditions"), so this looks fine. > } > > static int process_mdb(SCLPEvent *event, MDBO *mdbo) Acked-by: Cornelia Huck