From nobody Sun May 5 15:26:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523156826200401.0064492229668; Sat, 7 Apr 2018 20:07:06 -0700 (PDT) Received: from localhost ([::1]:45035 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f50fR-0003rs-OO for importer@patchew.org; Sat, 07 Apr 2018 23:06:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56120) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f50eQ-0003Us-TS for qemu-devel@nongnu.org; Sat, 07 Apr 2018 23:05:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f50eN-00057X-O6 for qemu-devel@nongnu.org; Sat, 07 Apr 2018 23:05:54 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57006 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f50eN-00057B-JU for qemu-devel@nongnu.org; Sat, 07 Apr 2018 23:05:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 37AB37C6DC for ; Sun, 8 Apr 2018 03:05:51 +0000 (UTC) Received: from xz-mi.nay.redhat.com (dhcp-14-151.nay.redhat.com [10.66.14.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4AC7D7E1A; Sun, 8 Apr 2018 03:05:44 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Sun, 8 Apr 2018 11:05:42 +0800 Message-Id: <20180408030542.17855-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Sun, 08 Apr 2018 03:05:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Sun, 08 Apr 2018 03:05:51 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'peterx@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2] iotests: fix wait_until_completed() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , peterx@redhat.com, Stefan Hajnoczi , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If there are more than one events, wait_until_completed() might return the 2nd event even if the 1st event is JOB_COMPLETED, since the for loop will continue to run even if completed is set to True. It never happened before, but it can be triggered when OOB is enabled due to the RESUME startup message. Fix that up. Signed-off-by: Peter Xu Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi --- tests/qemu-iotests/iotests.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index b5d7945af8..119c8e270a 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -470,18 +470,15 @@ class QMPTestCase(unittest.TestCase): =20 def wait_until_completed(self, drive=3D'drive0', check_offset=3DTrue): '''Wait for a block job to finish, returning the event''' - completed =3D False - while not completed: + while True: for event in self.vm.get_qmp_events(wait=3DTrue): if event['event'] =3D=3D 'BLOCK_JOB_COMPLETED': self.assert_qmp(event, 'data/device', drive) self.assert_qmp_absent(event, 'data/error') if check_offset: self.assert_qmp(event, 'data/offset', event['data'= ]['len']) - completed =3D True - - self.assert_no_active_block_jobs() - return event + self.assert_no_active_block_jobs() + return event =20 def wait_ready(self, drive=3D'drive0'): '''Wait until a block job BLOCK_JOB_READY event''' --=20 2.14.3