From nobody Mon Feb 9 00:07:35 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.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