From nobody Thu May 15 13:05:31 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 1507130437630669.0243862960863; Wed, 4 Oct 2017 08:20:37 -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 61BD0272B3; Wed, 4 Oct 2017 15:20:36 +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 355006FDDC; Wed, 4 Oct 2017 15:20:36 +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 E514E3FAD7; Wed, 4 Oct 2017 15:20:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v94EwxYI006951 for ; Wed, 4 Oct 2017 10:58:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8CAA8619C0; Wed, 4 Oct 2017 14:58:59 +0000 (UTC) Received: from mamuti.net (unknown [10.34.246.102]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1F4A760276 for ; Wed, 4 Oct 2017 14:58:56 +0000 (UTC) Received: by mamuti.net (Postfix, from userid 500) id 58721107BD7; Wed, 4 Oct 2017 16:58:50 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 61BD0272B3 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 4 Oct 2017 16:58:37 +0200 Message-Id: <23117b3760ca7cde6e070788335e7ae9d66ac1be.1507128897.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.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 13/23] 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.39]); Wed, 04 Oct 2017 15:20:36 +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 --- 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 5c8b1d76b0..b5a5ba2b02 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