Patchwork [2/2] qtest: use synchronous I/O for char device

login
register
mail settings
Submitter Anthony Liguori
Date March 26, 2013, 3:11 p.m.
Message ID <1364310706-10851-2-git-send-email-aliguori@us.ibm.com>
Download mbox | patch
Permalink /patch/231254/
State New
Headers show

Comments

Anthony Liguori - March 26, 2013, 3:11 p.m.
Peter reported that rtc-test would periodically hang.  It turns out
this was due to an EAGAIN occurring on qemu_chr_fe_write.

Instead of heavily refactoring qtest, just use a synchronous version
of the write operation for qemu_chr_fe_write to address this problem.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 qtest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Wayne Xia - March 27, 2013, 7:22 a.m.
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>

> Peter reported that rtc-test would periodically hang.  It turns out
> this was due to an EAGAIN occurring on qemu_chr_fe_write.
> 
> Instead of heavily refactoring qtest, just use a synchronous version
> of the write operation for qemu_chr_fe_write to address this problem.
> 
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
>   qtest.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/qtest.c b/qtest.c
> index 5e0e9ec..b03b68a 100644
> --- a/qtest.c
> +++ b/qtest.c
> @@ -191,7 +191,7 @@ static void GCC_FMT_ATTR(2, 3) qtest_send(CharDriverState *chr,
>       len = vsnprintf(buffer, sizeof(buffer), fmt, ap);
>       va_end(ap);
> 
> -    qemu_chr_fe_write(chr, (uint8_t *)buffer, len);
> +    qemu_chr_fe_write_all(chr, (uint8_t *)buffer, len);
>       if (qtest_log_fp && qtest_opened) {
>           fprintf(qtest_log_fp, "%s", buffer);
>       }
>

Patch

diff --git a/qtest.c b/qtest.c
index 5e0e9ec..b03b68a 100644
--- a/qtest.c
+++ b/qtest.c
@@ -191,7 +191,7 @@  static void GCC_FMT_ATTR(2, 3) qtest_send(CharDriverState *chr,
     len = vsnprintf(buffer, sizeof(buffer), fmt, ap);
     va_end(ap);
 
-    qemu_chr_fe_write(chr, (uint8_t *)buffer, len);
+    qemu_chr_fe_write_all(chr, (uint8_t *)buffer, len);
     if (qtest_log_fp && qtest_opened) {
         fprintf(qtest_log_fp, "%s", buffer);
     }