From 3dd1eb3b26504f91ec6c8487784c494718d884c1 Mon Sep 17 00:00:00 2001 From: Andrea Bolognani Date: Tue, 6 Feb 2018 14:49:41 +0100 Subject: [PATCH] conf: Improve HPT feature handling Instead of storing separately whether the feature is enabled or not and what resizing policy should be used, store both of them in a single place. Signed-off-by: Andrea Bolognani Reviewed-by: John Ferlan --- src/conf/domain_conf.c | 26 ++++++++++++-------------- src/conf/domain_conf.h | 4 ++-- src/qemu/qemu_command.c | 4 ++-- src/qemu/qemu_domain.c | 2 +- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9b50c6e249..3cfd6de5e0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -906,6 +906,7 @@ VIR_ENUM_IMPL(virDomainIOAPIC, VIR_ENUM_IMPL(virDomainHPTResizing, VIR_DOMAIN_HPT_RESIZING_LAST, + "none", "enabled", "disabled", "required", @@ -19239,14 +19240,13 @@ virDomainDefParseXML(xmlDocPtr xml, tmp = virXMLPropString(nodes[i], "resizing"); if (tmp) { int value = virDomainHPTResizingTypeFromString(tmp); - if (value < 0) { + if (value < 0 || value == VIR_DOMAIN_HPT_RESIZING_NONE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unknown HPT resizing setting: %s"), tmp); goto error; } - def->hpt_resizing = value; - def->features[val] = VIR_TRISTATE_SWITCH_ON; + def->features[val] = value; VIR_FREE(tmp); } break; @@ -21379,16 +21379,13 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src, break; case VIR_DOMAIN_FEATURE_HPT: - if (src->features[i] != dst->features[i] || - src->hpt_resizing != dst->hpt_resizing) { + if (src->features[i] != dst->features[i]) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("State of feature '%s' differs: " - "source: '%s,%s=%s', destination: '%s,%s=%s'"), + "source: '%s=%s', destination: '%s=%s'"), featureName, - virTristateSwitchTypeToString(src->features[i]), - "resizing", virDomainHPTResizingTypeToString(src->hpt_resizing), - virTristateSwitchTypeToString(dst->features[i]), - "resizing", virDomainHPTResizingTypeToString(dst->hpt_resizing)); + "resizing", virDomainHPTResizingTypeToString(src->features[i]), + "resizing", virDomainHPTResizingTypeToString(dst->features[i])); return false; } break; @@ -26949,10 +26946,11 @@ virDomainDefFormatInternal(virDomainDefPtr def, break; case VIR_DOMAIN_FEATURE_HPT: - if (def->features[i] == VIR_TRISTATE_SWITCH_ON) { - virBufferAsprintf(buf, "\n", - virDomainHPTResizingTypeToString(def->hpt_resizing)); - } + if (def->features[i] == VIR_DOMAIN_HPT_RESIZING_NONE) + break; + + virBufferAsprintf(buf, "\n", + virDomainHPTResizingTypeToString(def->features[i])); break; /* coverity[dead_error_begin] */ diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f5fbe1d973..e6212818aa 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1871,7 +1871,8 @@ typedef enum { VIR_ENUM_DECL(virDomainIOAPIC); typedef enum { - VIR_DOMAIN_HPT_RESIZING_ENABLED = 0, + VIR_DOMAIN_HPT_RESIZING_NONE = 0, + VIR_DOMAIN_HPT_RESIZING_ENABLED, VIR_DOMAIN_HPT_RESIZING_DISABLED, VIR_DOMAIN_HPT_RESIZING_REQUIRED, @@ -2363,7 +2364,6 @@ struct _virDomainDef { unsigned int hyperv_spinlocks; virGICVersion gic_version; char *hyperv_vendor_id; - virDomainHPTResizing hpt_resizing; int apic_eoi; virDomainClockDef clock; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ed19817c9a..55e573b619 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7249,7 +7249,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, } } - if (def->features[VIR_DOMAIN_FEATURE_HPT] == VIR_TRISTATE_SWITCH_ON) { + if (def->features[VIR_DOMAIN_FEATURE_HPT] != VIR_DOMAIN_HPT_RESIZING_NONE) { const char *str; if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT)) { @@ -7259,7 +7259,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, goto cleanup; } - str = virDomainHPTResizingTypeToString(def->hpt_resizing); + str = virDomainHPTResizingTypeToString(def->features[VIR_DOMAIN_FEATURE_HPT]); if (!str) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Invalid setting for HPT resizing")); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index eeb9691ca4..b60bb465a1 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3333,7 +3333,7 @@ qemuDomainDefValidateFeatures(const virDomainDef *def) break; case VIR_DOMAIN_FEATURE_HPT: - if (def->features[i] == VIR_TRISTATE_SWITCH_ON && + if (def->features[i] != VIR_DOMAIN_HPT_RESIZING_NONE && !qemuDomainIsPSeries(def)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("The '%s' feature is not supported for "