mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-14 08:35:15 +00:00
conf: Make error reporting in virCPUDefIsEqual optional
The function will be used in paths where mismatching CPU defs are not an error. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
880b1a2e25
commit
25ec7f6fe9
@ -811,7 +811,8 @@ virCPUDefAddFeature(virCPUDefPtr def,
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
virCPUDefIsEqual(virCPUDefPtr src,
|
virCPUDefIsEqual(virCPUDefPtr src,
|
||||||
virCPUDefPtr dst)
|
virCPUDefPtr dst,
|
||||||
|
bool reportError)
|
||||||
{
|
{
|
||||||
bool identical = false;
|
bool identical = false;
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -819,98 +820,89 @@ virCPUDefIsEqual(virCPUDefPtr src,
|
|||||||
if (!src && !dst)
|
if (!src && !dst)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
#define MISMATCH(fmt, ...) \
|
||||||
|
if (reportError) \
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, fmt, __VA_ARGS__)
|
||||||
|
|
||||||
if ((src && !dst) || (!src && dst)) {
|
if ((src && !dst) || (!src && dst)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
MISMATCH("%s", _("Target CPU does not match source"));
|
||||||
_("Target CPU does not match source"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src->type != dst->type) {
|
if (src->type != dst->type) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
MISMATCH(_("Target CPU type %s does not match source %s"),
|
||||||
_("Target CPU type %s does not match source %s"),
|
virCPUTypeToString(dst->type),
|
||||||
virCPUTypeToString(dst->type),
|
virCPUTypeToString(src->type));
|
||||||
virCPUTypeToString(src->type));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src->mode != dst->mode) {
|
if (src->mode != dst->mode) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
MISMATCH(_("Target CPU mode %s does not match source %s"),
|
||||||
_("Target CPU mode %s does not match source %s"),
|
virCPUModeTypeToString(dst->mode),
|
||||||
virCPUModeTypeToString(dst->mode),
|
virCPUModeTypeToString(src->mode));
|
||||||
virCPUModeTypeToString(src->mode));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src->arch != dst->arch) {
|
if (src->arch != dst->arch) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
MISMATCH(_("Target CPU arch %s does not match source %s"),
|
||||||
_("Target CPU arch %s does not match source %s"),
|
virArchToString(dst->arch),
|
||||||
virArchToString(dst->arch),
|
virArchToString(src->arch));
|
||||||
virArchToString(src->arch));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STRNEQ_NULLABLE(src->model, dst->model)) {
|
if (STRNEQ_NULLABLE(src->model, dst->model)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
MISMATCH(_("Target CPU model %s does not match source %s"),
|
||||||
_("Target CPU model %s does not match source %s"),
|
NULLSTR(dst->model), NULLSTR(src->model));
|
||||||
NULLSTR(dst->model), NULLSTR(src->model));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STRNEQ_NULLABLE(src->vendor, dst->vendor)) {
|
if (STRNEQ_NULLABLE(src->vendor, dst->vendor)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
MISMATCH(_("Target CPU vendor %s does not match source %s"),
|
||||||
_("Target CPU vendor %s does not match source %s"),
|
NULLSTR(dst->vendor), NULLSTR(src->vendor));
|
||||||
NULLSTR(dst->vendor), NULLSTR(src->vendor));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STRNEQ_NULLABLE(src->vendor_id, dst->vendor_id)) {
|
if (STRNEQ_NULLABLE(src->vendor_id, dst->vendor_id)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
MISMATCH(_("Target CPU vendor id %s does not match source %s"),
|
||||||
_("Target CPU vendor id %s does not match source %s"),
|
NULLSTR(dst->vendor_id), NULLSTR(src->vendor_id));
|
||||||
NULLSTR(dst->vendor_id), NULLSTR(src->vendor_id));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src->sockets != dst->sockets) {
|
if (src->sockets != dst->sockets) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
MISMATCH(_("Target CPU sockets %d does not match source %d"),
|
||||||
_("Target CPU sockets %d does not match source %d"),
|
dst->sockets, src->sockets);
|
||||||
dst->sockets, src->sockets);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src->cores != dst->cores) {
|
if (src->cores != dst->cores) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
MISMATCH(_("Target CPU cores %d does not match source %d"),
|
||||||
_("Target CPU cores %d does not match source %d"),
|
dst->cores, src->cores);
|
||||||
dst->cores, src->cores);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src->threads != dst->threads) {
|
if (src->threads != dst->threads) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
MISMATCH(_("Target CPU threads %d does not match source %d"),
|
||||||
_("Target CPU threads %d does not match source %d"),
|
dst->threads, src->threads);
|
||||||
dst->threads, src->threads);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src->nfeatures != dst->nfeatures) {
|
if (src->nfeatures != dst->nfeatures) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
MISMATCH(_("Target CPU feature count %zu does not match source %zu"),
|
||||||
_("Target CPU feature count %zu does not match source %zu"),
|
dst->nfeatures, src->nfeatures);
|
||||||
dst->nfeatures, src->nfeatures);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < src->nfeatures; i++) {
|
for (i = 0; i < src->nfeatures; i++) {
|
||||||
if (STRNEQ(src->features[i].name, dst->features[i].name)) {
|
if (STRNEQ(src->features[i].name, dst->features[i].name)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
MISMATCH(_("Target CPU feature %s does not match source %s"),
|
||||||
_("Target CPU feature %s does not match source %s"),
|
dst->features[i].name, src->features[i].name);
|
||||||
dst->features[i].name, src->features[i].name);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src->features[i].policy != dst->features[i].policy) {
|
if (src->features[i].policy != dst->features[i].policy) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
MISMATCH(_("Target CPU feature policy %s does not match source %s"),
|
||||||
_("Target CPU feature policy %s does not match source %s"),
|
virCPUFeaturePolicyTypeToString(dst->features[i].policy),
|
||||||
virCPUFeaturePolicyTypeToString(dst->features[i].policy),
|
virCPUFeaturePolicyTypeToString(src->features[i].policy));
|
||||||
virCPUFeaturePolicyTypeToString(src->features[i].policy));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -920,11 +912,12 @@ virCPUDefIsEqual(virCPUDefPtr src,
|
|||||||
(src->cache && dst->cache &&
|
(src->cache && dst->cache &&
|
||||||
(src->cache->level != dst->cache->level ||
|
(src->cache->level != dst->cache->level ||
|
||||||
src->cache->mode != dst->cache->mode))) {
|
src->cache->mode != dst->cache->mode))) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
MISMATCH("%s", _("Target CPU cache does not match source"));
|
||||||
_("Target CPU cache does not match source"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef MISMATCH
|
||||||
|
|
||||||
identical = true;
|
identical = true;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
@ -189,7 +189,8 @@ virCPUDefParseXML(xmlNodePtr node,
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
virCPUDefIsEqual(virCPUDefPtr src,
|
virCPUDefIsEqual(virCPUDefPtr src,
|
||||||
virCPUDefPtr dst);
|
virCPUDefPtr dst,
|
||||||
|
bool reportError);
|
||||||
|
|
||||||
char *
|
char *
|
||||||
virCPUDefFormat(virCPUDefPtr def,
|
virCPUDefFormat(virCPUDefPtr def,
|
||||||
|
@ -20090,7 +20090,7 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virCPUDefIsEqual(src->cpu, dst->cpu))
|
if (!virCPUDefIsEqual(src->cpu, dst->cpu, true))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!virSysinfoIsEqual(src->sysinfo, dst->sysinfo))
|
if (!virSysinfoIsEqual(src->sysinfo, dst->sysinfo))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user