From nobody Sun May 5 09:30:14 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 Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522044802061721.4531364492451; Sun, 25 Mar 2018 23:13:22 -0700 (PDT) Received: from localhost ([::1]:54808 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0LNU-00054T-Cu for importer@patchew.org; Mon, 26 Mar 2018 02:13:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34701) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0LMa-0004jG-1p for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:12:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0LMW-00052m-2G for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:12:12 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59870 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 1f0LMV-00052X-V0 for qemu-devel@nongnu.org; Mon, 26 Mar 2018 02:12:08 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E60A6401DE65 for ; Mon, 26 Mar 2018 06:12:04 +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 08231111DCF3; Mon, 26 Mar 2018 06:11:58 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Mon, 26 Mar 2018 14:11:57 +0800 Message-Id: <20180326061157.24865-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 26 Mar 2018 06:12:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 26 Mar 2018 06:12:04 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.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] 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, 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 by removing the boolean and make sure we return the correct event. Signed-off-by: Peter Xu --- tests/qemu-iotests/iotests.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index b5d7945af8..11704e6583 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -470,18 +470,14 @@ 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: - 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 + 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']['l= en']) + 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