From nobody Thu May 15 13:09:41 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 1507130417268647.4385693028516; Wed, 4 Oct 2017 08:20:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E08F13D961; Wed, 4 Oct 2017 15:20:15 +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 B5C0B61346; Wed, 4 Oct 2017 15:20:15 +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 7D0483FAD4; Wed, 4 Oct 2017 15:20:15 +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 v94Ewxwk006952 for ; Wed, 4 Oct 2017 10:58:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8D83760276; 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 1DD3760F81 for ; Wed, 4 Oct 2017 14:58:56 +0000 (UTC) Received: by mamuti.net (Postfix, from userid 500) id 5A519107BB5; Wed, 4 Oct 2017 16:58:50 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E08F13D961 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: Wed, 4 Oct 2017 16:58:38 +0200 Message-Id: <26ac623a403a6856e5618587ae2d11b5c870ea17.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 14/23] cputest: Separate QEMUCaps creation from cpuTestCPUIDJson 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 04 Oct 2017 15:20:16 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" To make the code reusable by other tests. Signed-off-by: Jiri Denemark Reviewed-by: John Ferlan --- tests/cputest.c | 97 +++++++++++++++++++++++++++++++++++------------------= ---- 1 file changed, 60 insertions(+), 37 deletions(-) diff --git a/tests/cputest.c b/tests/cputest.c index 0a07a2da14..b72c17a168 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -460,6 +460,64 @@ cpuTestHasFeature(const void *arg) } =20 =20 +typedef enum { + JSON_NONE, + JSON_HOST, + JSON_MODELS, +} cpuTestCPUIDJson; + +#if WITH_QEMU && WITH_YAJL +static virQEMUCapsPtr +cpuTestMakeQEMUCaps(const struct data *data) +{ + virQEMUCapsPtr qemuCaps =3D NULL; + qemuMonitorTestPtr testMon =3D NULL; + qemuMonitorCPUModelInfoPtr model =3D NULL; + char *json =3D NULL; + + if (virAsprintf(&json, "%s/cputestdata/%s-cpuid-%s.json", + abs_srcdir, virArchToString(data->arch), data->host) <= 0) + goto error; + + if (!(testMon =3D qemuMonitorTestNewFromFile(json, driver.xmlopt, true= ))) + goto error; + + if (qemuMonitorGetCPUModelExpansion(qemuMonitorTestGetMonitor(testMon), + QEMU_MONITOR_CPU_MODEL_EXPANSION_S= TATIC, + "host", true, &model) < 0) + goto error; + + if (!(qemuCaps =3D virQEMUCapsNew())) + goto error; + + 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; + + if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, + qemuMonitorTestGetMonitor(testMo= n), + false) < 0) + goto error; + + cleanup: + qemuMonitorCPUModelInfoFree(model); + qemuMonitorTestFree(testMon); + VIR_FREE(json); + + return qemuCaps; + + error: + virObjectUnref(qemuCaps); + qemuCaps =3D NULL; + goto cleanup; +} +#endif + + static int cpuTestCPUID(bool guest, const void *arg) { @@ -670,52 +728,20 @@ cpuTestUpdateLive(const void *arg) } =20 =20 -typedef enum { - JSON_NONE, - JSON_HOST, - JSON_MODELS, -} cpuTestCPUIDJson; - #if WITH_QEMU && WITH_YAJL static int cpuTestJSONCPUID(const void *arg) { const struct data *data =3D arg; - qemuMonitorCPUModelInfoPtr model =3D NULL; virQEMUCapsPtr qemuCaps =3D NULL; virCPUDefPtr cpu =3D NULL; - qemuMonitorTestPtr testMon =3D NULL; - char *json =3D NULL; char *result =3D NULL; int ret =3D -1; =20 - if (virAsprintf(&json, "%s/cputestdata/%s-cpuid-%s.json", - abs_srcdir, virArchToString(data->arch), data->host) <= 0 || - virAsprintf(&result, "cpuid-%s-json", data->host) < 0) + if (virAsprintf(&result, "cpuid-%s-json", data->host) < 0) goto cleanup; =20 - if (!(testMon =3D qemuMonitorTestNewFromFile(json, driver.xmlopt, true= ))) - goto cleanup; - - if (qemuMonitorGetCPUModelExpansion(qemuMonitorTestGetMonitor(testMon), - QEMU_MONITOR_CPU_MODEL_EXPANSION_S= TATIC, - "host", true, &model) < 0) - goto cleanup; - - if (!(qemuCaps =3D virQEMUCapsNew())) - goto cleanup; - - 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; - - if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, - qemuMonitorTestGetMonitor(testMo= n), - false) < 0) + if (!(qemuCaps =3D cpuTestMakeQEMUCaps(data))) goto cleanup; =20 if (VIR_ALLOC(cpu) < 0) @@ -732,12 +758,9 @@ cpuTestJSONCPUID(const void *arg) ret =3D cpuTestCompareXML(data->arch, cpu, result); =20 cleanup: - qemuMonitorCPUModelInfoFree(model); virObjectUnref(qemuCaps); - qemuMonitorTestFree(testMon); virCPUDefFree(cpu); VIR_FREE(result); - VIR_FREE(json); return ret; } #endif --=20 2.14.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list