From nobody Thu May 15 13:44:52 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 150791895001452.807703370468516; Fri, 13 Oct 2017 11:22:30 -0700 (PDT) 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 C38363680C; Fri, 13 Oct 2017 18:22:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A42986BF60; Fri, 13 Oct 2017 18:22:26 +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 6869F18355DD; Fri, 13 Oct 2017 18:22:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9DIF4NH014103 for ; Fri, 13 Oct 2017 14:15:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 72C9060176; Fri, 13 Oct 2017 18:15:04 +0000 (UTC) Received: from mamuti.net (ovpn-116-29.ams2.redhat.com [10.36.116.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 090BC6047F for ; Fri, 13 Oct 2017 18:15:03 +0000 (UTC) Received: by mamuti.net (Postfix, from userid 500) id 366C71006F4; Fri, 13 Oct 2017 20:14:56 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C38363680C Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Jiri Denemark To: libvir-list@redhat.com Date: Fri, 13 Oct 2017 20:14:45 +0200 Message-Id: <9f8c62e60f3587054714e06982ba9d2365319119.1507918307.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.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 13/22] cputest: Test CPU usability blockers 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 13 Oct 2017 18:22:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Gather query-cpu-definitions results and use them for testing CPU model usability blockers in CPUID to virCPUDef translation. Signed-off-by: Jiri Denemark Reviewed-by: John Ferlan --- Notes: Version 2: - no change src/qemu/qemu_capabilities.c | 2 +- src/qemu/qemu_capspriv.h | 5 +++++ tests/cputest.c | 12 +++++++++++- tests/cputestdata/cpu-cpuid.py | 26 +++++++++++++++++++------- tests/cputestdata/cpu-gather.sh | 1 + 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 8803980495..4de411e397 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2933,7 +2933,7 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCa= ps, } =20 =20 -static int +int virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps, qemuMonitorPtr mon, bool tcg) diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h index d05256bd35..f23995ec6e 100644 --- a/src/qemu/qemu_capspriv.h +++ b/src/qemu/qemu_capspriv.h @@ -101,4 +101,9 @@ virQEMUCapsParseHelpStr(const char *qemu, int virQEMUCapsParseDeviceStr(virQEMUCapsPtr qemuCaps, const char *str); + +int +virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps, + qemuMonitorPtr mon, + bool tcg); #endif diff --git a/tests/cputest.c b/tests/cputest.c index dcfdf57d43..0a07a2da14 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -673,6 +673,7 @@ cpuTestUpdateLive(const void *arg) typedef enum { JSON_NONE, JSON_HOST, + JSON_MODELS, } cpuTestCPUIDJson; =20 #if WITH_QEMU && WITH_YAJL @@ -704,10 +705,19 @@ cpuTestJSONCPUID(const void *arg) if (!(qemuCaps =3D virQEMUCapsNew())) goto cleanup; =20 + virQEMUCapsSet(qemuCaps, QEMU_CAPS_KVM); + if (data->flags =3D=3D JSON_MODELS) + virQEMUCapsSet(qemuCaps, QEMU_CAPS_QUERY_CPU_DEFINITIONS); + virQEMUCapsSetArch(qemuCaps, data->arch); virQEMUCapsSetCPUModelInfo(qemuCaps, VIR_DOMAIN_VIRT_KVM, model); model =3D NULL; =20 + if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, + qemuMonitorTestGetMonitor(testMo= n), + false) < 0) + goto cleanup; + if (VIR_ALLOC(cpu) < 0) goto cleanup; =20 @@ -870,7 +880,7 @@ mymain(void) do { \ if (json !=3D JSON_NONE) { \ DO_TEST(arch, cpuTestJSONCPUID, host, host, \ - NULL, NULL, 0, 0); \ + NULL, NULL, json, 0); \ } \ } while (0) #else diff --git a/tests/cputestdata/cpu-cpuid.py b/tests/cputestdata/cpu-cpuid.py index a2fd938c24..4fe8e8b952 100755 --- a/tests/cputestdata/cpu-cpuid.py +++ b/tests/cputestdata/cpu-cpuid.py @@ -228,17 +228,22 @@ def parseFeatureWords(path): s =3D f.read() =20 props =3D {} - for i in range(5): + rest =3D [] + chunk =3D 0 + while s !=3D "": (data, pos) =3D dec.raw_decode(s) - if i =3D=3D 0: + if chunk =3D=3D 0: features =3D data["return"] - else: + elif chunk < 5: keys =3D ["family", "model", "stepping", "model-id"] - props[keys[i - 1]] =3D data["return"] + props[keys[chunk - 1]] =3D data["return"] + else: + rest.append(data) =20 while pos < len(s) and s[pos] !=3D "{": pos +=3D 1 s =3D s[pos:] + chunk +=3D 1 =20 if props["model-id"].find("Intel") !=3D -1: props["vendor"] =3D "GenuineIntel" @@ -255,13 +260,13 @@ def parseFeatureWords(path): leaf =3D cpuidLeaf(cpuid, in_eax, in_ecx) leaf[feat["cpuid-register"].lower()] =3D feat["features"] =20 - return props, cpuid + return props, cpuid, rest =20 =20 def parseQemu(path, features): cpuid =3D {} with open(path, "r") as f: - data =3D json.load(f) + data, pos =3D json.JSONDecoder().raw_decode(f.read()) =20 for (prop, val) in data["return"]["model"]["props"].iteritems(): if val and prop in features: @@ -288,6 +293,7 @@ def parseCpuid(path): =20 =20 def formatCpuid(cpuid, path, comment): + print path with open(path, "w") as f: f.write("\n") f.write("\n") @@ -304,19 +310,25 @@ def formatCpuid(cpuid, path, comment): =20 =20 def convert(path): - props, cpuid =3D parseFeatureWords(path) + props, cpuid, rest =3D parseFeatureWords(path) =20 for feature in cpuidMap: value =3D cpuidIsSet(cpuid, feature) for name in feature["names"]: props[name] =3D value =20 + print path with open(path, "w") as f: json.dump({"return": {"model": {"name": "base", "props": props}}, "id": "model-expansion"}, f, indent =3D 2, separators =3D (',', ': ')) f.write("\n") =20 + for chunk in rest: + f.write("\n") + json.dump(chunk, f, indent =3D 2, separators =3D (',', ': ')) + f.write("\n") + =20 def diff(features, path): base =3D path.replace(".json", "") diff --git a/tests/cputestdata/cpu-gather.sh b/tests/cputestdata/cpu-gather= .sh index 83963557ec..9c696f57bd 100755 --- a/tests/cputestdata/cpu-gather.sh +++ b/tests/cputestdata/cpu-gather.sh @@ -58,5 +58,6 @@ $( qom_get model-id fi ) +{"execute":"query-cpu-definitions","id":"definitions"} {"execute":"quit"} EOF --=20 2.14.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list