From nobody Thu May 9 01:20:35 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) 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 1548901682236897.8298105138191; Wed, 30 Jan 2019 18:28:02 -0800 (PST) Received: from localhost ([127.0.0.1]:47637 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gp252-0008Hr-3L for importer@patchew.org; Wed, 30 Jan 2019 21:27:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gp248-0007rE-S2 for qemu-devel@nongnu.org; Wed, 30 Jan 2019 21:26:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gp247-0005pA-Qm for qemu-devel@nongnu.org; Wed, 30 Jan 2019 21:26:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35324) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gp245-0005nd-87; Wed, 30 Jan 2019 21:26:53 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 117D2D7917; Thu, 31 Jan 2019 02:26:52 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-68.bos.redhat.com [10.18.17.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1804F19743; Thu, 31 Jan 2019 02:26:49 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Wed, 30 Jan 2019 21:26:48 -0500 Message-Id: <20190131022648.14264-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 31 Jan 2019 02:26:52 +0000 (UTC) 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] [PATCH] 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: Kevin Wolf , John Snow , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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 cbedfaf1df..76ad52b358 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) @@ -491,7 +492,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.17.2