From nobody Fri May 16 07:24:28 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.zoho.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 1496824694293455.36052719218765; Wed, 7 Jun 2017 01:38:14 -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 457D3C057FA1; Wed, 7 Jun 2017 08:38:12 +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 030EF171F9; Wed, 7 Jun 2017 08:38:12 +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 A0E344A48E; Wed, 7 Jun 2017 08:38:11 +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 v578bnCj004793 for ; Wed, 7 Jun 2017 04:37:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id DA6BF1724E; Wed, 7 Jun 2017 08:37:49 +0000 (UTC) Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 88C535C88E for ; Wed, 7 Jun 2017 08:37:47 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 6B47710008A; Wed, 7 Jun 2017 10:37:46 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 457D3C057FA1 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 457D3C057FA1 From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 7 Jun 2017 10:37:26 +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.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 01/20] conf: Make error reporting in virCPUDefIsEqual optional 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.32]); Wed, 07 Jun 2017 08:38:13 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The function will be used in paths where mismatching CPU defs are not an error. Signed-off-by: Jiri Denemark --- Notes: Version 2: - move all the if (reportError) statements into a macro src/conf/cpu_conf.c | 83 +++++++++++++++++++++++-----------------------= ---- src/conf/cpu_conf.h | 3 +- src/conf/domain_conf.c | 2 +- 3 files changed, 41 insertions(+), 47 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index a4be5742e..ffb2e83d6 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -811,7 +811,8 @@ virCPUDefAddFeature(virCPUDefPtr def, =20 bool virCPUDefIsEqual(virCPUDefPtr src, - virCPUDefPtr dst) + virCPUDefPtr dst, + bool reportError) { bool identical =3D false; size_t i; @@ -819,98 +820,89 @@ virCPUDefIsEqual(virCPUDefPtr src, if (!src && !dst) return true; =20 +#define MISMATCH(fmt, ...) \ + if (reportError) \ + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, fmt, __VA_ARGS__) + if ((src && !dst) || (!src && dst)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Target CPU does not match source")); + MISMATCH("%s", _("Target CPU does not match source")); goto cleanup; } =20 if (src->type !=3D dst->type) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU type %s does not match source %s"), - virCPUTypeToString(dst->type), - virCPUTypeToString(src->type)); + MISMATCH(_("Target CPU type %s does not match source %s"), + virCPUTypeToString(dst->type), + virCPUTypeToString(src->type)); goto cleanup; } =20 if (src->mode !=3D dst->mode) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU mode %s does not match source %s"), - virCPUModeTypeToString(dst->mode), - virCPUModeTypeToString(src->mode)); + MISMATCH(_("Target CPU mode %s does not match source %s"), + virCPUModeTypeToString(dst->mode), + virCPUModeTypeToString(src->mode)); goto cleanup; } =20 if (src->arch !=3D dst->arch) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU arch %s does not match source %s"), - virArchToString(dst->arch), - virArchToString(src->arch)); + MISMATCH(_("Target CPU arch %s does not match source %s"), + virArchToString(dst->arch), + virArchToString(src->arch)); goto cleanup; } =20 if (STRNEQ_NULLABLE(src->model, dst->model)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU model %s does not match source %s"), - NULLSTR(dst->model), NULLSTR(src->model)); + MISMATCH(_("Target CPU model %s does not match source %s"), + NULLSTR(dst->model), NULLSTR(src->model)); goto cleanup; } =20 if (STRNEQ_NULLABLE(src->vendor, dst->vendor)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU vendor %s does not match source %s"), - NULLSTR(dst->vendor), NULLSTR(src->vendor)); + MISMATCH(_("Target CPU vendor %s does not match source %s"), + NULLSTR(dst->vendor), NULLSTR(src->vendor)); goto cleanup; } =20 if (STRNEQ_NULLABLE(src->vendor_id, dst->vendor_id)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU vendor id %s does not match source %s= "), - NULLSTR(dst->vendor_id), NULLSTR(src->vendor_id)); + MISMATCH(_("Target CPU vendor id %s does not match source %s"), + NULLSTR(dst->vendor_id), NULLSTR(src->vendor_id)); goto cleanup; } =20 if (src->sockets !=3D dst->sockets) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU sockets %d does not match source %d"), - dst->sockets, src->sockets); + MISMATCH(_("Target CPU sockets %d does not match source %d"), + dst->sockets, src->sockets); goto cleanup; } =20 if (src->cores !=3D dst->cores) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU cores %d does not match source %d"), - dst->cores, src->cores); + MISMATCH(_("Target CPU cores %d does not match source %d"), + dst->cores, src->cores); goto cleanup; } =20 if (src->threads !=3D dst->threads) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU threads %d does not match source %d"), - dst->threads, src->threads); + MISMATCH(_("Target CPU threads %d does not match source %d"), + dst->threads, src->threads); goto cleanup; } =20 if (src->nfeatures !=3D dst->nfeatures) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU feature count %zu does not match sour= ce %zu"), - dst->nfeatures, src->nfeatures); + MISMATCH(_("Target CPU feature count %zu does not match source %zu= "), + dst->nfeatures, src->nfeatures); goto cleanup; } =20 for (i =3D 0; i < src->nfeatures; i++) { if (STRNEQ(src->features[i].name, dst->features[i].name)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU feature %s does not match source = %s"), - dst->features[i].name, src->features[i].name); + MISMATCH(_("Target CPU feature %s does not match source %s"), + dst->features[i].name, src->features[i].name); goto cleanup; } =20 if (src->features[i].policy !=3D dst->features[i].policy) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target CPU feature policy %s does not match = source %s"), - virCPUFeaturePolicyTypeToString(dst->features[i= ].policy), - virCPUFeaturePolicyTypeToString(src->features[i= ].policy)); + MISMATCH(_("Target CPU feature policy %s does not match source= %s"), + virCPUFeaturePolicyTypeToString(dst->features[i].poli= cy), + virCPUFeaturePolicyTypeToString(src->features[i].poli= cy)); goto cleanup; } } @@ -920,11 +912,12 @@ virCPUDefIsEqual(virCPUDefPtr src, (src->cache && dst->cache && (src->cache->level !=3D dst->cache->level || src->cache->mode !=3D dst->cache->mode))) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Target CPU cache does not match source")); + MISMATCH("%s", _("Target CPU cache does not match source")); goto cleanup; } =20 +#undef MISMATCH + identical =3D true; =20 cleanup: diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index 09438b68b..b0d891552 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -189,7 +189,8 @@ virCPUDefParseXML(xmlNodePtr node, =20 bool virCPUDefIsEqual(virCPUDefPtr src, - virCPUDefPtr dst); + virCPUDefPtr dst, + bool reportError); =20 char * virCPUDefFormat(virCPUDefPtr def, diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 958a5b7cd..5f99dad9c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -20090,7 +20090,7 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr = src, goto error; } =20 - if (!virCPUDefIsEqual(src->cpu, dst->cpu)) + if (!virCPUDefIsEqual(src->cpu, dst->cpu, true)) goto error; =20 if (!virSysinfoIsEqual(src->sysinfo, dst->sysinfo)) --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list