From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org, qemu-ppc@nongnu.org,
Paolo Bonzini <pbonzini@redhat.com>,
Amit Shah <amit.shah@redhat.com>,
Cornelia Huck <cornelia.huck@de.ibm.com>,
Gerd Hoffmann <kraxel@redhat.com>,
"Daniel P. Berrange" <berrange@redhat.com>
Subject: [Qemu-devel] [PATCH 3/5] sclpconsole: remove bogus check for -EAGAIN
Date: Wed, 3 Aug 2016 17:22:38 +0100 [thread overview]
Message-ID: <1470241360-3574-4-git-send-email-berrange@redhat.com> (raw)
In-Reply-To: <1470241360-3574-1-git-send-email-berrange@redhat.com>
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 <berrange@redhat.com>
---
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);
}
static int process_mdb(SCLPEvent *event, MDBO *mdbo)
--
2.7.4
next prev parent reply other threads:[~2016-08-03 16:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-03 16:22 [Qemu-devel] [PATCH 0/5] Global fix / workaround usage of qemu_chr_fe_write Daniel P. Berrange
2016-08-03 16:22 ` [Qemu-devel] [PATCH 1/5] virtio-console: set frontend open permanently for console devs Daniel P. Berrange
2016-08-03 16:37 ` Paolo Bonzini
2016-08-03 17:37 ` Cornelia Huck
2016-08-03 16:22 ` [Qemu-devel] [PATCH 2/5] impi: check return of qemu_chr_fe_write() for errors Daniel P. Berrange
2016-08-03 16:22 ` Daniel P. Berrange [this message]
2016-08-04 8:13 ` [Qemu-devel] [PATCH 3/5] sclpconsole: remove bogus check for -EAGAIN Cornelia Huck
2016-08-03 16:22 ` [Qemu-devel] [PATCH 4/5] hw: replace most use of qemu_chr_fe_write with qemu_chr_fe_write_all Daniel P. Berrange
2016-08-04 8:23 ` Cornelia Huck
2016-08-03 16:22 ` [Qemu-devel] [PATCH 5/5] char: convert qemu_chr_fe_write to qemu_chr_fe_write_all Daniel P. Berrange
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1470241360-3574-4-git-send-email-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=amit.shah@redhat.com \
--cc=cornelia.huck@de.ibm.com \
--cc=kraxel@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).