From patchwork Wed Jun 27 13:23:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 167649 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A5D10B6EEC for ; Wed, 27 Jun 2012 23:28:03 +1000 (EST) Received: from localhost ([::1]:57365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SjsHp-000530-AI for incoming@patchwork.ozlabs.org; Wed, 27 Jun 2012 09:28:01 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SjsHf-0004v7-Vo for qemu-devel@nongnu.org; Wed, 27 Jun 2012 09:27:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SjsHW-0001aB-1X for qemu-devel@nongnu.org; Wed, 27 Jun 2012 09:27:51 -0400 Received: from e4.ny.us.ibm.com ([32.97.182.144]:52589) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SjsHV-0001ZB-TH for qemu-devel@nongnu.org; Wed, 27 Jun 2012 09:27:41 -0400 Received: from /spool/local by e4.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Jun 2012 09:27:36 -0400 Received: from d01dlp01.pok.ibm.com (9.56.224.56) by e4.ny.us.ibm.com (192.168.1.104) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 27 Jun 2012 09:24:49 -0400 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id E4FE338C8187 for ; Wed, 27 Jun 2012 09:23:31 -0400 (EDT) Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q5RDNVn3064634 for ; Wed, 27 Jun 2012 09:23:31 -0400 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q5RDNHkc030281 for ; Wed, 27 Jun 2012 07:23:17 -0600 Received: from titi.austin.rr.com (sig-9-65-133-147.mts.ibm.com [9.65.133.147]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q5RDNGUS030265; Wed, 27 Jun 2012 07:23:16 -0600 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Wed, 27 Jun 2012 08:23:16 -0500 Message-Id: <1340803396-7211-1-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.7.5.4 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12062713-3534-0000-0000-000009D83B4D X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.182.144 Cc: Anthony Liguori , Markus Armbruster Subject: [Qemu-devel] [PATCH] qtest: fix infinite loop when QEMU aborts abruptly X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Signed-off-by: Anthony Liguori Tested-by: Markus Armbruster --- tests/libqtest.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 1d73fd1..071b6be 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -291,6 +291,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++;