Patchwork [01/23] qtest: fix infinite loop when QEMU aborts abruptly

login
register
mail settings
Submitter Michael Roth
Date Aug. 21, 2012, 5:05 p.m.
Message ID <1345568757-14365-2-git-send-email-mdroth@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/179106/
State New
Headers show

Comments

Michael Roth - Aug. 21, 2012, 5:05 p.m.
From: Anthony Liguori <aliguori@us.ibm.com>

From Markus:

Makes "make check" hang:

    QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 gtester -k --verbose -m=quick tests/crash-test tests/rtc-test
    TEST: tests/crash-test... (pid=972)
    qemu-system-x86_64: Device needs media, but drive is empty
[Nothing happens, wait a while, then hit ^C]
    make: *** [check-qtest-x86_64] Interrupt

This was due to the fact that we weren't checked for errors when
reading from the QMP socket.  This patch adds appropriate error
checking.

Reported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 039380a8e18f618cdacf72486449c04dc1b70eef)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 tests/libqtest.c |    5 +++++
 1 file changed, 5 insertions(+)

Patch

diff --git a/tests/libqtest.c b/tests/libqtest.c
index 6d333ef..0664323 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -290,6 +290,11 @@  void qtest_qmp(QTestState *s, const char *fmt, ...)
             continue;
         }
 
+        if (len == -1 || len == 0) {
+            fprintf(stderr, "Broken pipe\n");
+            exit(1);
+        }
+
         switch (c) {
         case '{':
             nesting++;