From nobody Wed Feb 11 10:04:37 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1489768632927612.1122242379365; Fri, 17 Mar 2017 09:37:12 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C1C682EF16A; Fri, 17 Mar 2017 16:37:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 420B8BFA6E; Fri, 17 Mar 2017 16:37:10 +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 CF1475EC64; Fri, 17 Mar 2017 16:37:09 +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 v2HGb1e0007131 for ; Fri, 17 Mar 2017 12:37:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3F7CF53; Fri, 17 Mar 2017 16:37:01 +0000 (UTC) Received: from mamuti.net (ovpn-204-109.brq.redhat.com [10.40.204.109]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F8115DC1D for ; Fri, 17 Mar 2017 16:37:01 +0000 (UTC) Received: by mamuti.net (Postfix, from userid 500) id 3C5AF1061CB; Fri, 17 Mar 2017 17:36:55 +0100 (CET) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C1C682EF16A Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C1C682EF16A From: Jiri Denemark To: libvir-list@redhat.com Date: Fri, 17 Mar 2017 17:36:46 +0100 Message-Id: <671c98be36383b6e556bd068cb8544cc1bbc117e.1489768416.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/14] cputest: Add cpuidIsSet helper to cpu-cpuid.py 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: , MIME-Version: 1.0 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 17 Mar 2017 16:37:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark --- tests/cputestdata/cpu-cpuid.py | 41 +++++++++++++++++++++-----------------= --- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/tests/cputestdata/cpu-cpuid.py b/tests/cputestdata/cpu-cpuid.py index a4dc23378..9ea858d98 100755 --- a/tests/cputestdata/cpu-cpuid.py +++ b/tests/cputestdata/cpu-cpuid.py @@ -171,6 +171,24 @@ cpuidMap =3D [ ] =20 =20 +def cpuidIsSet(cpuid, feature): + in_eax =3D feature["in_eax"] + in_ecx =3D feature["in_ecx"] + eax =3D feature["eax"] + ebx =3D feature["ebx"] + ecx =3D feature["ecx"] + edx =3D feature["edx"] + + if in_eax not in cpuid or in_ecx not in cpuid[in_eax]: + return False + else: + leaf =3D cpuid[in_eax][in_ecx] + return ((eax > 0 and leaf["eax"] & eax > 0) or + (ebx > 0 and leaf["ebx"] & ebx > 0) or + (ecx > 0 and leaf["ecx"] & ecx > 0) or + (edx > 0 and leaf["edx"] & edx > 0)) + + def parseFeatureWords(path): features =3D None =20 @@ -217,30 +235,13 @@ def parseFeatureWords(path): return props, cpuid =20 =20 -def propAdd(props, feature, value): - for name in feature["names"]: - props[name] =3D value - - def convert(path): props, cpuid =3D parseFeatureWords(path) =20 for feature in cpuidMap: - in_eax =3D feature["in_eax"] - in_ecx =3D feature["in_ecx"] - eax =3D feature["eax"] - ebx =3D feature["ebx"] - ecx =3D feature["ecx"] - edx =3D feature["edx"] - - if in_eax not in cpuid or in_ecx not in cpuid[in_eax]: - propAdd(props, feature, False) - else: - leaf =3D cpuid[in_eax][in_ecx] - propAdd(props, feature, ((eax > 0 and leaf["eax"] & eax > 0) or - (ebx > 0 and leaf["ebx"] & ebx > 0) or - (ecx > 0 and leaf["ecx"] & ecx > 0) or - (edx > 0 and leaf["edx"] & edx > 0))) + value =3D cpuidIsSet(cpuid, feature) + for name in feature["names"]: + props[name] =3D value =20 with open(path, "w") as f: json.dump({"return": {"model": {"name": "base", "props": props}}, --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list