From nobody Sun Feb 8 13:48:17 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554713012999520.5896741311866; Mon, 8 Apr 2019 01:43:32 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 70D14308622F; Mon, 8 Apr 2019 08:43:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 419FE5D969; Mon, 8 Apr 2019 08:43:31 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F307741F3C; Mon, 8 Apr 2019 08:43:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gxKJ009175 for ; Mon, 8 Apr 2019 04:42:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 48D0F5D9C9; Mon, 8 Apr 2019 08:42:59 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DEDF5DA2C for ; Mon, 8 Apr 2019 08:42:59 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 339B2103827; Mon, 8 Apr 2019 10:42:51 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:33 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 29/36] cputest: Prepare cpu-cpuid.py for MSR features X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 08 Apr 2019 08:43:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Let's make sure the current CPUID specific code is only applied to CPUID features. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- tests/cputestdata/cpu-cpuid.py | 36 +++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/tests/cputestdata/cpu-cpuid.py b/tests/cputestdata/cpu-cpuid.py index cba5fc165a..ac69c5a012 100755 --- a/tests/cputestdata/cpu-cpuid.py +++ b/tests/cputestdata/cpu-cpuid.py @@ -5,7 +5,7 @@ import sys import json import xmltodict =20 -def checkFeature(cpuid, feature): +def checkCPUIDFeature(cpuData, feature): eax_in =3D feature["eax_in"] ecx_in =3D feature["ecx_in"] eax =3D feature["eax"] @@ -13,6 +13,10 @@ def checkFeature(cpuid, feature): ecx =3D feature["ecx"] edx =3D feature["edx"] =20 + if "cpuid" not in cpuData: + return False + + cpuid =3D cpuData["cpuid"] if eax_in not in cpuid or ecx_in not in cpuid[eax_in]: return False =20 @@ -23,7 +27,18 @@ def checkFeature(cpuid, feature): (edx > 0 and leaf["edx"] & edx =3D=3D edx)) =20 =20 -def addFeature(cpuid, feature): +def checkFeature(cpuData, feature): + if feature["type"] =3D=3D "cpuid": + return checkCPUIDFeature(cpuData, feature) + + return False + + +def addCPUIDFeature(cpuData, feature): + if "cpuid" not in cpuData: + cpuData["cpuid"] =3D {} + cpuid =3D cpuData["cpuid"] + if feature["eax_in"] not in cpuid: cpuid[feature["eax_in"]] =3D {} leaf =3D cpuid[feature["eax_in"]] @@ -36,6 +51,11 @@ def addFeature(cpuid, feature): leaf[reg] |=3D feature[reg] =20 =20 +def addFeature(cpuData, feature): + if feature["type"] =3D=3D "cpuid": + addCPUIDFeature(cpuData, feature) + + def parseQemu(path, features): cpuData =3D {} with open(path, "r") as f: @@ -54,7 +74,7 @@ def parseCPUData(path): data =3D xmltodict.parse(f) =20 for leaf in data["cpudata"]["cpuid"]: - feature =3D {} + feature =3D {"type": "cpuid"} feature["eax_in"] =3D int(leaf["@eax_in"], 0) feature["ecx_in"] =3D int(leaf["@ecx_in"], 0) for reg in ["eax", "ebx", "ecx", "edx"]: @@ -66,7 +86,7 @@ def parseCPUData(path): =20 =20 def parseMapFeature(data): - cpuid =3D {} + cpuid =3D {"type": "cpuid"} for reg in ["eax_in", "ecx_in", "eax", "ebx", "ecx", "edx"]: attr =3D "@%s" % reg =20 @@ -92,11 +112,13 @@ def parseMap(): return cpuMap =20 =20 -def formatCPUData(cpuid, path, comment): +def formatCPUData(cpuData, path, comment): print(path) with open(path, "w") as f: f.write("\n") f.write("\n") + + cpuid =3D cpuData["cpuid"] for eax_in in sorted(cpuid.keys()): for ecx_in in sorted(cpuid[eax_in].keys()): leaf =3D cpuid[eax_in][ecx_in] @@ -119,8 +141,8 @@ def diff(cpuMap, path): cpuData =3D parseCPUData(cpuDataFile) qemu =3D parseQemu(jsonFile, cpuMap) =20 - enabled =3D {} - disabled =3D {} + enabled =3D {"cpuid": {}} + disabled =3D {"cpuid": {}} for feature in cpuMap.values(): if checkFeature(qemu, feature): addFeature(enabled, feature) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list