From nobody Tue Sep 9 13:49:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1756477526; cv=none; d=zohomail.com; s=zohoarc; b=jo80DmbNwxiWe3AxZ5TBEYSiGiuV5BKmQGPNgaPMudhXuO1+slgA9rksbIMJC9TnelqLu2s+kq8QDTsO4VPEjJ5XvEDYpgcqzIy5rOa6vCU5WvZKv02/nMqyYRdxePcgS0Ybf8VKf1/F1qWySPw2H0BqwBVKnvuhybHFNXQI9Sg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756477526; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=IyxmhnHVHoED7k0bq5+TFuVKNtAKX+gyrTaZz7RNhMQ=; b=GuxYR4Wb4ZhWzlgLRo42gaxG2TbRhGbX70+Lv+YnAAIoTJhAeGu2txZ98Cm+q0M3S1V06uccV/FrDcPn1GeeeD4N00v6jzjUexVY5/2UIVTERZE1qX8d38zWPecc67DOPy+BhowGX9dM3iuF4sIF+nLxwULCJ2AKUKoorR91mYY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1756477526445818.3673024708872; Fri, 29 Aug 2025 07:25:26 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 7F39A44218; Fri, 29 Aug 2025 10:25:25 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 876B7441B7; Fri, 29 Aug 2025 10:20:02 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id B106B440C0; Fri, 29 Aug 2025 10:19:43 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 61AC044036 for ; Fri, 29 Aug 2025 10:19:39 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-672-2_VW_IHYNymuoWOWazVvvA-1; Fri, 29 Aug 2025 10:19:37 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7F4781800561 for ; Fri, 29 Aug 2025 14:19:36 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.44.22.3]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9D38D1956095 for ; Fri, 29 Aug 2025 14:19:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756477179; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IyxmhnHVHoED7k0bq5+TFuVKNtAKX+gyrTaZz7RNhMQ=; b=aJybzFjIm++3o7md5FIyAmLhT91DjLVI2kwkO/cerGHTcYKvQ6+t6yu9i0R4w+i8aN/iGe NBnMuhQFf8p01zMXIE62Rm6GSJAeOqAkio1lI8j7XLQX+WaGDZkA5MhmGoHyPUNvV/JgQv 43gbRvo2moXch4FuzG3XWBWuD1GwOHg= X-MC-Unique: 2_VW_IHYNymuoWOWazVvvA-1 X-Mimecast-MFC-AGG-ID: 2_VW_IHYNymuoWOWazVvvA_1756477176 To: devel@lists.libvirt.org Subject: [PATCH 1/8] scripts: qemu-replies-tool: Convert the QMP conversation to list of dicts Date: Fri, 29 Aug 2025 16:19:25 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 5Wp3rM1L_5iPi-l5pcfiaWIrP2hh0fL4tL0ng0X-hTA_1756477176 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5MNPPNU4JUIWIDZKMPUGP4PBJ6KBRPZV X-Message-ID-Hash: 5MNPPNU4JUIWIDZKMPUGP4PBJ6KBRPZV X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1756477527129116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Currently the conversation was a list of tuples. Since upcoming patches will want to store some additional flags with the processed commands convert it to a list of dicts, so that we can name the individual fields. Signed-off-by: Peter Krempa --- scripts/qemu-replies-tool.py | 54 ++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/scripts/qemu-replies-tool.py b/scripts/qemu-replies-tool.py index 6d474a83f2..4ec06ee95d 100755 --- a/scripts/qemu-replies-tool.py +++ b/scripts/qemu-replies-tool.py @@ -36,13 +36,13 @@ def qemu_replies_load(filename): if command is None: command =3D json.loads(jsonstr) else: - conv.append((command, json.loads(jsonstr))) + conv.append({'cmd': command, 'rep': json.loads(jso= nstr)}) command =3D None jsonstr =3D '' if command is not None and jsonstr !=3D '': - conv.append((command, json.loads(jsonstr))) + conv.append({'cmd': command, 'rep': json.loads(jsonstr)}) command =3D None jsonstr =3D '' @@ -67,14 +67,14 @@ def qemu_replies_compare_or_replace(filename, conv, reg= enerate_on_error): seq =3D 9999 # poison the initial counter state # possibly fix mis-ordererd 'id' fields - for (cmd, rep) in conv: + for c in conv: # 'qmp_capabilities' command restarts the numbering sequence - if cmd['execute'] =3D=3D 'qmp_capabilities': + if c['cmd']['execute'] =3D=3D 'qmp_capabilities': seq =3D 1 newid =3D 'libvirt-%d' % seq - cmd['id'] =3D newid - rep['id'] =3D newid + c['cmd']['id'] =3D newid + c['rep']['id'] =3D newid seq +=3D 1 @@ -82,7 +82,7 @@ def qemu_replies_compare_or_replace(filename, conv, regen= erate_on_error): if len(actual) !=3D 0: actual +=3D '\n\n' - actual +=3D json.dumps(cmd, indent=3D2) + '\n\n' + json.dumps(rep,= indent=3D2) + actual +=3D json.dumps(c['cmd'], indent=3D2) + '\n\n' + json.dumps= (c['rep'], indent=3D2) expect =3D '' actual +=3D '\n' @@ -114,9 +114,9 @@ def modify_replies(conv): version =3D None # filled with a dictionary with 'major', 'minor', '= micro' keys # find version of current qemu for later use - for (cmd, rep) in conv: - if cmd['execute'] =3D=3D 'query-version': - version =3D rep['return']['qemu'] + for c in conv: + if c['cmd']['execute'] =3D=3D 'query-version': + version =3D c['rep']['return']['qemu'] break if version is None: @@ -126,9 +126,9 @@ def modify_replies(conv): # Find index of a command, in this case we're looking for the last # invocation of given command for i in range(len(conv)): - (cmd, rep) =3D conv[i] + c =3D conv[i] - if cmd['execute'] =3D=3D 'device-list-properties': + if c['cmd']['execute'] =3D=3D 'device-list-properties': idx =3D i if idx =3D=3D -1: @@ -161,9 +161,9 @@ def modify_replies(conv): # insert command into the QMP conversation based on version of qemu if version['major'] >=3D 8 and version['minor'] > 0: - conv.insert(idx, (cmd, reply)) + conv.insert(idx, {'cmd': cmd, 'rep': reply}) else: - conv.insert(idx, (cmd, reply_unsupp)) + conv.insert(idx, {'cmd': cmd, 'rep': reply_unsupp}) # Validates that 'entry' (an member of the QMP schema): @@ -389,9 +389,9 @@ def dump_qmp_probe_strings(schemalist): def dump_qom_list_types(conv): types =3D [] - for (cmd, rep) in conv: - if cmd['execute'] =3D=3D 'qom-list-types': - for qomtype in rep['return']: + for c in conv: + if c['cmd']['execute'] =3D=3D 'qom-list-types': + for qomtype in c['rep']['return']: # validate known fields: # 'parent' is ignored below as it causes output churn for k in qomtype: @@ -411,20 +411,20 @@ def dump_qom_list_types(conv): def dump_device_list_properties(conv): devices =3D [] - for (cmd, rep) in conv: - if cmd['execute'] =3D=3D 'device-list-properties': - if 'return' in rep: - for arg in rep['return']: + for c in conv: + if c['cmd']['execute'] =3D=3D 'device-list-properties': + if 'return' in c['rep']: + for arg in c['rep']['return']: for k in arg: if k not in ['name', 'type', 'description', 'defau= lt-value']: - raise Exception("Unhandled 'device-list-proper= ties' typename '%s' field '%s'" % (cmd['arguments']['typename'], k)) + raise Exception("Unhandled 'device-list-proper= ties' typename '%s' field '%s'" % (c['cmd']['arguments']['typename'], k)) if 'default-value' in arg: defval =3D ' (%s)' % str(arg['default-value']) else: defval =3D '' - devices.append('%s %s %s%s' % (cmd['arguments']['typen= ame'], + devices.append('%s %s %s%s' % (c['cmd']['arguments']['= typename'], arg['name'], arg['type'], defval)) @@ -441,12 +441,12 @@ def process_one(filename, args): modify_replies(conv) - for (cmd, rep) in conv: - if cmd['execute'] =3D=3D 'query-qmp-schema': - validate_qmp_schema(rep['return']) + for c in conv: + if c['cmd']['execute'] =3D=3D 'query-qmp-schema': + validate_qmp_schema(c['rep']['return']) if args.dump_all or args.dump_qmp_query_strings: - dump_qmp_probe_strings(rep['return']) + dump_qmp_probe_strings(c['rep']['return']) dumped =3D True if args.dump_all or args.dump_qom_list_types: --=20 2.51.0