From nobody Wed May 1 20:24:36 2024 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 1505388016944992.765947703474; Thu, 14 Sep 2017 04:20:16 -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 CF982C04B952; Thu, 14 Sep 2017 11: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 ABEEA17AC9; Thu, 14 Sep 2017 11: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 774B83FACE; Thu, 14 Sep 2017 11:20:15 +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 v8EAvQMw018272 for ; Thu, 14 Sep 2017 06:57:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 569E05D963; Thu, 14 Sep 2017 10:57:26 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2B2735D744 for ; Thu, 14 Sep 2017 10:57:23 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 8F11D10022D; Thu, 14 Sep 2017 12:57:22 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CF982C04B952 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 14 Sep 2017 12:57:14 +0200 Message-Id: <593bdf7672eb53ae5c37fa90a8544eb4bcf9ff17.1505386577.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 1/7] cpu_conf: Introduce virCPUDefList{Parse, Free} 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.31]); Thu, 14 Sep 2017 11:20:16 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" For parsing a list of CPU XMLs into a NULL-terminated list of CPU defs. Signed-off-by: Jiri Denemark --- src/conf/cpu_conf.c | 78 ++++++++++++++++++++++++++++++++++++++++++++= ++++ src/conf/cpu_conf.h | 7 +++++ src/libvirt_private.syms | 2 ++ 3 files changed, 87 insertions(+) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index c21d11d244..7514842059 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -29,9 +29,12 @@ #include "cpu_conf.h" #include "domain_conf.h" #include "virstring.h" +#include "virlog.h" =20 #define VIR_FROM_THIS VIR_FROM_CPU =20 +VIR_LOG_INIT("conf.cpu_conf"); + VIR_ENUM_IMPL(virCPU, VIR_CPU_TYPE_LAST, "host", "guest", "auto") =20 @@ -939,3 +942,78 @@ virCPUDefIsEqual(virCPUDefPtr src, cleanup: return identical; } + + +/* + * Parses a list of CPU XMLs into a NULL-terminated list of CPU defs. + */ +virCPUDefPtr * +virCPUDefListParse(const char **xmlCPUs, + unsigned int ncpus, + virCPUType cpuType) +{ + xmlDocPtr doc =3D NULL; + xmlXPathContextPtr ctxt =3D NULL; + virCPUDefPtr *cpus =3D NULL; + size_t i; + + VIR_DEBUG("xmlCPUs=3D%p, ncpus=3D%u", xmlCPUs, ncpus); + + if (xmlCPUs) { + for (i =3D 0; i < ncpus; i++) + VIR_DEBUG("xmlCPUs[%zu]=3D%s", i, NULLSTR(xmlCPUs[i])); + } + + if (!xmlCPUs && ncpus !=3D 0) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("nonzero ncpus doesn't match with NULL xmlCPUs")); + goto error; + } + + if (ncpus < 1) { + virReportError(VIR_ERR_INVALID_ARG, "%s", _("no CPUs given")); + goto error; + } + + if (VIR_ALLOC_N(cpus, ncpus + 1)) + goto error; + + for (i =3D 0; i < ncpus; i++) { + if (!(doc =3D virXMLParseStringCtxt(xmlCPUs[i], _("(CPU_definition= )"), &ctxt))) + goto error; + + if (virCPUDefParseXML(ctxt, NULL, cpuType, &cpus[i]) < 0) + goto error; + + xmlXPathFreeContext(ctxt); + xmlFreeDoc(doc); + ctxt =3D NULL; + doc =3D NULL; + } + + return cpus; + + error: + virCPUDefListFree(cpus); + xmlXPathFreeContext(ctxt); + xmlFreeDoc(doc); + return NULL; +} + + +/* + * Frees NULL-terminated list of CPUs created by virCPUDefListParse. + */ +void +virCPUDefListFree(virCPUDefPtr *cpus) +{ + virCPUDefPtr *cpu; + + if (!cpus) + return; + + for (cpu =3D cpus; *cpu !=3D NULL; cpu++) + virCPUDefFree(*cpu); + + VIR_FREE(cpus); +} diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index b44974f47e..d3e2c84102 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -218,4 +218,11 @@ virCPUDefUpdateFeature(virCPUDefPtr cpu, const char *name, int policy); =20 +virCPUDefPtr * +virCPUDefListParse(const char **xmlCPUs, + unsigned int ncpus, + virCPUType cpuType); +void +virCPUDefListFree(virCPUDefPtr *cpus); + #endif /* __VIR_CPU_CONF_H__ */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 247d1175ba..857e417f94 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -82,6 +82,8 @@ virCPUDefFree; virCPUDefFreeFeatures; virCPUDefFreeModel; virCPUDefIsEqual; +virCPUDefListFree; +virCPUDefListParse; virCPUDefParseXML; virCPUDefStealModel; virCPUDefUpdateFeature; --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 20:24:36 2024 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 1505387998155229.22212703151217; Thu, 14 Sep 2017 04:19:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 08DBE5F7B3; Thu, 14 Sep 2017 11:19:57 +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 D015F77ED0; Thu, 14 Sep 2017 11:19:56 +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 953071806107; Thu, 14 Sep 2017 11:19:56 +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 v8EAvP1W018264 for ; Thu, 14 Sep 2017 06:57:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id D76126048C; Thu, 14 Sep 2017 10:57:25 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AC79960487 for ; Thu, 14 Sep 2017 10:57:23 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 918311002B7; Thu, 14 Sep 2017 12:57:22 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 08DBE5F7B3 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: Thu, 14 Sep 2017 12:57:15 +0200 Message-Id: <5e8ab56d89052241f972e1f85b858d3cbcb6d6b6.1505386577.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 2/7] cpu: Use virCPUDefListParse in cpuBaselineXML 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 14 Sep 2017 11:19:57 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark --- src/cpu/cpu.c | 52 ++++++---------------------------------------------- 1 file changed, 6 insertions(+), 46 deletions(-) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 96160901e1..bf3c6d53dd 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -523,11 +523,9 @@ cpuBaselineXML(const char **xmlCPUs, unsigned int nmodels, unsigned int flags) { - xmlDocPtr doc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; virCPUDefPtr *cpus =3D NULL; virCPUDefPtr cpu =3D NULL; - char *cpustr; + char *cpustr =3D NULL; size_t i; =20 VIR_DEBUG("ncpus=3D%u, nmodels=3D%u", ncpus, nmodels); @@ -535,67 +533,29 @@ cpuBaselineXML(const char **xmlCPUs, virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); =20 - if (xmlCPUs) { - for (i =3D 0; i < ncpus; i++) - VIR_DEBUG("xmlCPUs[%zu]=3D%s", i, NULLSTR(xmlCPUs[i])); - } if (models) { for (i =3D 0; i < nmodels; i++) VIR_DEBUG("models[%zu]=3D%s", i, NULLSTR(models[i])); } =20 - if (xmlCPUs =3D=3D NULL && ncpus !=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("nonzero ncpus doesn't match with NULL xmlC= PUs")); - return NULL; - } - - if (ncpus < 1) { - virReportError(VIR_ERR_INVALID_ARG, "%s", _("No CPUs given")); - return NULL; - } - - if (VIR_ALLOC_N(cpus, ncpus)) - goto error; - - for (i =3D 0; i < ncpus; i++) { - if (!(doc =3D virXMLParseStringCtxt(xmlCPUs[i], _("(CPU_definition= )"), &ctxt))) - goto error; - - if (virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_HOST, &cpus[i]) < 0) - goto error; - - xmlXPathFreeContext(ctxt); - xmlFreeDoc(doc); - ctxt =3D NULL; - doc =3D NULL; - } + if (!(cpus =3D virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST))) + goto cleanup; =20 if (!(cpu =3D cpuBaseline(cpus, ncpus, models, nmodels, !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE= )))) - goto error; + goto cleanup; =20 if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && virCPUExpandFeatures(cpus[0]->arch, cpu) < 0) - goto error; + goto cleanup; =20 cpustr =3D virCPUDefFormat(cpu, NULL, false); =20 cleanup: - if (cpus) { - for (i =3D 0; i < ncpus; i++) - virCPUDefFree(cpus[i]); - VIR_FREE(cpus); - } + virCPUDefListFree(cpus); virCPUDefFree(cpu); - xmlXPathFreeContext(ctxt); - xmlFreeDoc(doc); =20 return cpustr; - - error: - cpustr =3D NULL; - goto cleanup; } =20 =20 --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 20:24:36 2024 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 1505387533557786.2512098692335; Thu, 14 Sep 2017 04:12:13 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 75DFCC04B924; Thu, 14 Sep 2017 11:12:11 +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 ADBDF5883F; Thu, 14 Sep 2017 11:12: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 380CD1806107; Thu, 14 Sep 2017 11:12:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8EAvPK4018259 for ; Thu, 14 Sep 2017 06:57:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id CC17118214; Thu, 14 Sep 2017 10:57:25 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A1A315C54C for ; Thu, 14 Sep 2017 10:57:23 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 937A11002D6; Thu, 14 Sep 2017 12:57:22 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 75DFCC04B924 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 14 Sep 2017 12:57:16 +0200 Message-Id: <9ab6b4677f60fb99042268a7934e007c997f4bcb.1505386577.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.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/7] cpu: Don't log CPU models in cpuBaselineXML 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 14 Sep 2017 11:12:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" They are logged in cpuBaseline anyway. Signed-off-by: Jiri Denemark --- src/cpu/cpu.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index bf3c6d53dd..e75f406040 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -526,18 +526,12 @@ cpuBaselineXML(const char **xmlCPUs, virCPUDefPtr *cpus =3D NULL; virCPUDefPtr cpu =3D NULL; char *cpustr =3D NULL; - size_t i; =20 VIR_DEBUG("ncpus=3D%u, nmodels=3D%u", ncpus, nmodels); =20 virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); =20 - if (models) { - for (i =3D 0; i < nmodels; i++) - VIR_DEBUG("models[%zu]=3D%s", i, NULLSTR(models[i])); - } - if (!(cpus =3D virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST))) goto cleanup; =20 --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 20:24:36 2024 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 1505387567241734.1839493880034; Thu, 14 Sep 2017 04:12:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E094912E9; Thu, 14 Sep 2017 11:12:45 +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 92A4E5C54C; Thu, 14 Sep 2017 11:12:45 +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 2EBD33FC73; Thu, 14 Sep 2017 11:12:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8EAvQXw018283 for ; Thu, 14 Sep 2017 06:57:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 965C66267E; Thu, 14 Sep 2017 10:57:26 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 444C867592 for ; Thu, 14 Sep 2017 10:57:23 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 9595F1002D8; Thu, 14 Sep 2017 12:57:22 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E094912E9 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=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 14 Sep 2017 12:57:17 +0200 Message-Id: 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.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/7] cpu: Drop cpuBaselineXML 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 14 Sep 2017 11:12:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The implementation of virConnectBaselineCPU may be different for each hypervisor. Thus it shouldn't really be implmented in the cpu code. Signed-off-by: Jiri Denemark --- src/bhyve/bhyve_driver.c | 22 +++++++++++++++--- src/cpu/cpu.c | 58 --------------------------------------------= ---- src/cpu/cpu.h | 7 ------ src/libvirt_private.syms | 1 - src/libxl/libxl_driver.c | 22 +++++++++++++++--- src/qemu/qemu_driver.c | 22 +++++++++++++++--- src/test/test_driver.c | 22 +++++++++++++++--- src/vz/vz_driver.c | 22 +++++++++++++++++- 8 files changed, 97 insertions(+), 79 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 3bcff88975..e8241f39ff 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1420,7 +1420,9 @@ bhyveConnectBaselineCPU(virConnectPtr conn, unsigned int ncpus, unsigned int flags) { - char *cpu =3D NULL; + virCPUDefPtr *cpus =3D NULL; + virCPUDefPtr cpu =3D NULL; + char *cpustr =3D NULL; =20 virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); @@ -1428,10 +1430,24 @@ bhyveConnectBaselineCPU(virConnectPtr conn, if (virConnectBaselineCPUEnsureACL(conn) < 0) goto cleanup; =20 - cpu =3D cpuBaselineXML(xmlCPUs, ncpus, NULL, 0, flags); + if (!(cpus =3D virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST))) + goto cleanup; + + if (!(cpu =3D cpuBaseline(cpus, ncpus, NULL, 0, + !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE= )))) + goto cleanup; + + if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && + virCPUExpandFeatures(cpus[0]->arch, cpu) < 0) + goto cleanup; + + cpustr =3D virCPUDefFormat(cpu, NULL, false); =20 cleanup: - return cpu; + virCPUDefListFree(cpus); + virCPUDefFree(cpu); + + return cpustr; } =20 static int diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index e75f406040..a7c7c381b9 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -495,64 +495,6 @@ virCPUProbeHost(virArch arch) } =20 =20 -/** - * cpuBaselineXML: - * - * @xmlCPUs: list of host CPU XML descriptions - * @ncpus: number of CPUs in @xmlCPUs - * @models: list of CPU models that can be considered for the baseline CPU - * @nmodels: number of CPU models in @models - * @flags: bitwise-OR of virConnectBaselineCPUFlags - * - * Computes the most feature-rich CPU which is compatible with all given - * host CPUs. If @models array is NULL, all models supported by libvirt wi= ll - * be considered when computing the baseline CPU model, otherwise the base= line - * CPU model will be one of the provided CPU @models. - * - * If @flags includes VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES then libvirt - * will explicitly list all CPU features that are part of the host CPU, - * without this flag features that are part of the CPU model will not be - * listed. - * - * Returns XML description of the baseline CPU or NULL on error. - */ -char * -cpuBaselineXML(const char **xmlCPUs, - unsigned int ncpus, - const char **models, - unsigned int nmodels, - unsigned int flags) -{ - virCPUDefPtr *cpus =3D NULL; - virCPUDefPtr cpu =3D NULL; - char *cpustr =3D NULL; - - VIR_DEBUG("ncpus=3D%u, nmodels=3D%u", ncpus, nmodels); - - virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | - VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); - - if (!(cpus =3D virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST))) - goto cleanup; - - if (!(cpu =3D cpuBaseline(cpus, ncpus, models, nmodels, - !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE= )))) - goto cleanup; - - if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && - virCPUExpandFeatures(cpus[0]->arch, cpu) < 0) - goto cleanup; - - cpustr =3D virCPUDefFormat(cpu, NULL, false); - - cleanup: - virCPUDefListFree(cpus); - virCPUDefFree(cpu); - - return cpustr; -} - - /** * cpuBaseline: * diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index c6ca111e97..5dda46ee70 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -196,13 +196,6 @@ virCPUGetHost(virArch arch, virCPUDefPtr virCPUProbeHost(virArch arch); =20 -char * -cpuBaselineXML(const char **xmlCPUs, - unsigned int ncpus, - const char **models, - unsigned int nmodels, - unsigned int flags); - virCPUDefPtr cpuBaseline (virCPUDefPtr *cpus, unsigned int ncpus, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 857e417f94..888e4e329b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1077,7 +1077,6 @@ virStoragePoolObjVolumeListExport; =20 # cpu/cpu.h cpuBaseline; -cpuBaselineXML; cpuDecode; cpuEncode; virCPUCheckFeature; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 8fefce6631..4861e5db21 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -6450,7 +6450,9 @@ libxlConnectBaselineCPU(virConnectPtr conn, unsigned int ncpus, unsigned int flags) { - char *cpu =3D NULL; + virCPUDefPtr *cpus =3D NULL; + virCPUDefPtr cpu =3D NULL; + char *cpustr =3D NULL; =20 virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); @@ -6458,10 +6460,24 @@ libxlConnectBaselineCPU(virConnectPtr conn, if (virConnectBaselineCPUEnsureACL(conn) < 0) goto cleanup; =20 - cpu =3D cpuBaselineXML(xmlCPUs, ncpus, NULL, 0, flags); + if (!(cpus =3D virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST))) + goto cleanup; + + if (!(cpu =3D cpuBaseline(cpus, ncpus, NULL, 0, + !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE= )))) + goto cleanup; + + if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && + virCPUExpandFeatures(cpus[0]->arch, cpu) < 0) + goto cleanup; + + cpustr =3D virCPUDefFormat(cpu, NULL, false); =20 cleanup: - return cpu; + virCPUDefListFree(cpus); + virCPUDefFree(cpu); + + return cpustr; } =20 static virHypervisorDriver libxlHypervisorDriver =3D { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b334cf20be..e92c114f3e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12989,7 +12989,9 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBUTE= _UNUSED, unsigned int ncpus, unsigned int flags) { - char *cpu =3D NULL; + virCPUDefPtr *cpus =3D NULL; + virCPUDefPtr cpu =3D NULL; + char *cpustr =3D NULL; =20 virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); @@ -12997,10 +12999,24 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBU= TE_UNUSED, if (virConnectBaselineCPUEnsureACL(conn) < 0) goto cleanup; =20 - cpu =3D cpuBaselineXML(xmlCPUs, ncpus, NULL, 0, flags); + if (!(cpus =3D virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST))) + goto cleanup; + + if (!(cpu =3D cpuBaseline(cpus, ncpus, NULL, 0, + !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE= )))) + goto cleanup; + + if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && + virCPUExpandFeatures(cpus[0]->arch, cpu) < 0) + goto cleanup; + + cpustr =3D virCPUDefFormat(cpu, NULL, false); =20 cleanup: - return cpu; + virCPUDefListFree(cpus); + virCPUDefFree(cpu); + + return cpustr; } =20 =20 diff --git a/src/test/test_driver.c b/src/test/test_driver.c index aa38f54dd9..6e8a4b5782 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -1535,13 +1535,29 @@ testConnectBaselineCPU(virConnectPtr conn ATTRIBUTE= _UNUSED, unsigned int ncpus, unsigned int flags) { - char *cpu; + virCPUDefPtr *cpus =3D NULL; + virCPUDefPtr cpu =3D NULL; + char *cpustr =3D NULL; =20 virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, NULL); =20 - cpu =3D cpuBaselineXML(xmlCPUs, ncpus, NULL, 0, flags); + if (!(cpus =3D virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST))) + goto cleanup; =20 - return cpu; + if (!(cpu =3D cpuBaseline(cpus, ncpus, NULL, 0, false))) + goto cleanup; + + if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && + virCPUExpandFeatures(cpus[0]->arch, cpu) < 0) + goto cleanup; + + cpustr =3D virCPUDefFormat(cpu, NULL, false); + + cleanup: + virCPUDefListFree(cpus); + virCPUDefFree(cpu); + + return cpustr; } =20 static int testNodeGetInfo(virConnectPtr conn, diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 6f4aee3652..daeed5f114 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -945,12 +945,32 @@ vzConnectBaselineCPU(virConnectPtr conn, unsigned int ncpus, unsigned int flags) { + virCPUDefPtr *cpus =3D NULL; + virCPUDefPtr cpu =3D NULL; + char *cpustr =3D NULL; + virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, NULL); =20 if (virConnectBaselineCPUEnsureACL(conn) < 0) return NULL; =20 - return cpuBaselineXML(xmlCPUs, ncpus, NULL, 0, flags); + if (!(cpus =3D virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST))) + goto cleanup; + + if (!(cpu =3D cpuBaseline(cpus, ncpus, NULL, 0, false))) + goto cleanup; + + if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && + virCPUExpandFeatures(cpus[0]->arch, cpu) < 0) + goto cleanup; + + cpustr =3D virCPUDefFormat(cpu, NULL, false); + + cleanup: + virCPUDefListFree(cpus); + virCPUDefFree(cpu); + + return cpustr; } =20 =20 --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 20:24:36 2024 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 1505387933309244.22151758341647; Thu, 14 Sep 2017 04:18:53 -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 4CBF085542; Thu, 14 Sep 2017 11:18:52 +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 2903B6F431; Thu, 14 Sep 2017 11:18:52 +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 E2CD71800C8A; Thu, 14 Sep 2017 11:18:51 +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 v8EAvR3O018297 for ; Thu, 14 Sep 2017 06:57:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5BC4A60487; Thu, 14 Sep 2017 10:57:27 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 30B936048C for ; Thu, 14 Sep 2017 10:57:27 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 977DF1003C4; Thu, 14 Sep 2017 12:57:22 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4CBF085542 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 14 Sep 2017 12:57:18 +0200 Message-Id: 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 5/7] qemu: Pass virArch * to virQEMUCapsCPUFilterFeatures 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.28]); Thu, 14 Sep 2017 11:18:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The filter only needs to know the CPU architecture. Passing virQEMUCapsPtr as opaque is a bit overkill. Signed-off-by: Jiri Denemark --- src/qemu/qemu_capabilities.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index c690cb3498..52d63f44ec 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3320,9 +3320,9 @@ static bool virQEMUCapsCPUFilterFeatures(const char *name, void *opaque) { - virQEMUCapsPtr qemuCaps =3D opaque; + virArch *arch =3D opaque; =20 - if (!ARCH_IS_X86(qemuCaps->arch)) + if (!ARCH_IS_X86(*arch)) return true; =20 if (STREQ(name, "cmt") || @@ -3534,7 +3534,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps, if (!hostCPU || virCPUDefCopyModelFilter(cpu, hostCPU, true, virQEMUCapsCPUFilterFeatures, - qemuCaps) < 0) + &qemuCaps->arch) < 0) goto error; } else if (type =3D=3D VIR_DOMAIN_VIRT_KVM && virCPUGetHostIsSupported(qemuCaps->arch)) { --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 20:24:36 2024 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 1505387588351892.943203188047; Thu, 14 Sep 2017 04:13:08 -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 1EBE94E4D3; Thu, 14 Sep 2017 11:13:07 +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 EDEF56048C; Thu, 14 Sep 2017 11:13:06 +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 8D1E8180610F; Thu, 14 Sep 2017 11:13:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8EAvRnm018296 for ; Thu, 14 Sep 2017 06:57:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5966F5C737; Thu, 14 Sep 2017 10:57:27 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2F66D5C66F for ; Thu, 14 Sep 2017 10:57:27 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 999051003DC; Thu, 14 Sep 2017 12:57:22 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1EBE94E4D3 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 14 Sep 2017 12:57:19 +0200 Message-Id: <91ebd0a54d1c48acd5b9fc219512935707584510.1505386577.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.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/7] qemu: Publish virQEMUCapsCPUFilterFeatures 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.38]); Thu, 14 Sep 2017 11:13:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark --- src/qemu/qemu_capabilities.c | 2 +- src/qemu/qemu_capabilities.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 52d63f44ec..7bc88be0f5 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3316,7 +3316,7 @@ virQEMUCapsProbeQMPGICCapabilities(virQEMUCapsPtr qem= uCaps, } =20 =20 -static bool +bool virQEMUCapsCPUFilterFeatures(const char *name, void *opaque) { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 85c390abf5..1400e885d9 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -547,4 +547,7 @@ int virQEMUCapsFillDomainCaps(virCapsPtr caps, bool virQEMUCapsGuestIsNative(virArch host, virArch guest); =20 +bool virQEMUCapsCPUFilterFeatures(const char *name, + void *opaque); + #endif /* __QEMU_CAPABILITIES_H__*/ --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 20:24:36 2024 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 1505387608811920.8963719318; Thu, 14 Sep 2017 04:13:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9050A6772E; Thu, 14 Sep 2017 11:13:27 +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 644AB61786; Thu, 14 Sep 2017 11:13:27 +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 294F63FC74; Thu, 14 Sep 2017 11:13:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8EAvTwN018314 for ; Thu, 14 Sep 2017 06:57:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id E1A3817ABB; Thu, 14 Sep 2017 10:57:29 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B664217AB4 for ; Thu, 14 Sep 2017 10:57:27 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 9B8041003E0; Thu, 14 Sep 2017 12:57:22 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9050A6772E Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 14 Sep 2017 12:57:20 +0200 Message-Id: <60a83fa03e8d4e79214685c05daa79f24218b1da.1505386577.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.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/7] qemu: Filter CPU features returned by qemuConnectBaselineCPU 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 14 Sep 2017 11:13:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The host CPU definitions reported in the capabilities XML may contain CPU features unknown to QEMU, but the result of virConnectBaselineCPU is supposed to be directly usable as a guest CPU definition and thus it should only contain features QEMU knows about. https://bugzilla.redhat.com/show_bug.cgi?id=3D1450317 Signed-off-by: Jiri Denemark --- src/qemu/qemu_driver.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e92c114f3e..e1a0dd553e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12990,6 +12990,7 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBUTE= _UNUSED, unsigned int flags) { virCPUDefPtr *cpus =3D NULL; + virCPUDefPtr baseline =3D NULL; virCPUDefPtr cpu =3D NULL; char *cpustr =3D NULL; =20 @@ -13002,8 +13003,16 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBUT= E_UNUSED, if (!(cpus =3D virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST))) goto cleanup; =20 - if (!(cpu =3D cpuBaseline(cpus, ncpus, NULL, 0, - !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE= )))) + if (!(baseline =3D cpuBaseline(cpus, ncpus, NULL, 0, + !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRA= TABLE)))) + goto cleanup; + + if (!(cpu =3D virCPUDefCopyWithoutModel(baseline))) + goto cleanup; + + if (virCPUDefCopyModelFilter(cpu, baseline, false, + virQEMUCapsCPUFilterFeatures, + &cpus[0]->arch) < 0) goto cleanup; =20 if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && @@ -13014,6 +13023,7 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBUTE= _UNUSED, =20 cleanup: virCPUDefListFree(cpus); + virCPUDefFree(baseline); virCPUDefFree(cpu); =20 return cpustr; --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list