From nobody Tue Apr 15 06:11:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.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 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549040761847506.9358571241204; Fri, 1 Feb 2019 09:06:01 -0800 (PST) Received: from localhost ([127.0.0.1]:58195 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpcGM-0005r1-Mu for importer@patchew.org; Fri, 01 Feb 2019 12:05:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpbo5-0007nH-Rw for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:36:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpbo3-0008WI-Lk for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:36:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44064) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gpbns-0008DJ-Qq; Fri, 01 Feb 2019 11:36:33 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2C75089AE8; Fri, 1 Feb 2019 16:36:06 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-95.ams2.redhat.com [10.36.117.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5CFF608C6; Fri, 1 Feb 2019 16:36:04 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 1 Feb 2019 17:35:14 +0100 Message-Id: <20190201163518.31157-24-kwolf@redhat.com> In-Reply-To: <20190201163518.31157-1-kwolf@redhat.com> References: <20190201163518.31157-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 01 Feb 2019 16:36:06 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 23/27] iotests/236: fix transaction kwarg order 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: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: John Snow It's not enough to order the kwargs for consistent QMP log output, we must also sort any sub-dictionaries in lists that appear as values. Reported-by: Kevin Wolf Signed-off-by: John Snow Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Kevin Wolf --- tests/qemu-iotests/236.out | 56 +++++++++++++++++------------------ tests/qemu-iotests/iotests.py | 21 ++++++------- 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/tests/qemu-iotests/236.out b/tests/qemu-iotests/236.out index 1dad24db0d..bb2d71ea5e 100644 --- a/tests/qemu-iotests/236.out +++ b/tests/qemu-iotests/236.out @@ -45,23 +45,23 @@ write -P0xcd 0x3ff0000 64k "actions": [ { "data": { - "node": "drive0", - "name": "bitmapB" + "name": "bitmapB", + "node": "drive0" }, "type": "block-dirty-bitmap-disable" }, { "data": { - "node": "drive0", + "granularity": 65536, "name": "bitmapC", - "granularity": 65536 + "node": "drive0" }, "type": "block-dirty-bitmap-add" }, { "data": { - "node": "drive0", - "name": "bitmapA" + "name": "bitmapA", + "node": "drive0" }, "type": "block-dirty-bitmap-clear" }, @@ -105,30 +105,30 @@ write -P0xcd 0x3ff0000 64k "actions": [ { "data": { - "node": "drive0", - "name": "bitmapB" + "name": "bitmapB", + "node": "drive0" }, "type": "block-dirty-bitmap-disable" }, { "data": { - "node": "drive0", + "granularity": 65536, "name": "bitmapC", - "granularity": 65536 + "node": "drive0" }, "type": "block-dirty-bitmap-add" }, { "data": { - "node": "drive0", - "name": "bitmapC" + "name": "bitmapC", + "node": "drive0" }, "type": "block-dirty-bitmap-disable" }, { "data": { - "node": "drive0", - "name": "bitmapC" + "name": "bitmapC", + "node": "drive0" }, "type": "block-dirty-bitmap-enable" } @@ -158,15 +158,15 @@ write -P0xea 0x3fe0000 64k "actions": [ { "data": { - "node": "drive0", - "name": "bitmapA" + "name": "bitmapA", + "node": "drive0" }, "type": "block-dirty-bitmap-disable" }, { "data": { - "node": "drive0", - "name": "bitmapC" + "name": "bitmapC", + "node": "drive0" }, "type": "block-dirty-bitmap-disable" } @@ -209,21 +209,21 @@ write -P0xea 0x3fe0000 64k "actions": [ { "data": { - "node": "drive0", "disabled": true, + "granularity": 65536, "name": "bitmapD", - "granularity": 65536 + "node": "drive0" }, "type": "block-dirty-bitmap-add" }, { "data": { - "node": "drive0", - "target": "bitmapD", "bitmaps": [ "bitmapB", "bitmapC" - ] + ], + "node": "drive0", + "target": "bitmapD" }, "type": "block-dirty-bitmap-merge" }, @@ -273,21 +273,21 @@ write -P0xea 0x3fe0000 64k "actions": [ { "data": { - "node": "drive0", "disabled": true, + "granularity": 65536, "name": "bitmapD", - "granularity": 65536 + "node": "drive0" }, "type": "block-dirty-bitmap-add" }, { "data": { - "node": "drive0", - "target": "bitmapD", "bitmaps": [ "bitmapB", "bitmapC" - ] + ], + "node": "drive0", + "target": "bitmapD" }, "type": "block-dirty-bitmap-merge" } diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 71214d46b5..b461f53abf 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -76,15 +76,16 @@ def qemu_img(*args): sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode,= ' '.join(qemu_img_args + list(args)))) return exitcode =20 -def ordered_kwargs(kwargs): - # kwargs prior to 3.6 are not ordered, so: - od =3D OrderedDict() - for k, v in sorted(kwargs.items()): - if isinstance(v, dict): - od[k] =3D ordered_kwargs(v) - else: - od[k] =3D v - return od +def ordered_qmp(qmsg): + # Dictionaries are not ordered prior to 3.6, therefore: + if isinstance(qmsg, list): + return [ordered_qmp(atom) for atom in qmsg] + if isinstance(qmsg, dict): + od =3D OrderedDict() + for k, v in sorted(qmsg.items()): + od[k] =3D ordered_qmp(v) + return od + return qmsg =20 def qemu_img_create(*args): args =3D list(args) @@ -506,7 +507,7 @@ class VM(qtest.QEMUQtestMachine): def qmp_log(self, cmd, filters=3D[], indent=3DNone, **kwargs): full_cmd =3D OrderedDict(( ("execute", cmd), - ("arguments", ordered_kwargs(kwargs)) + ("arguments", ordered_qmp(kwargs)) )) log(full_cmd, filters, indent=3Dindent) result =3D self.qmp(cmd, **kwargs) --=20 2.20.1