提交 3dd1eb3b 编写于 作者: A Andrea Bolognani

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: NAndrea Bolognani <abologna@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 c5a451ef
...@@ -906,6 +906,7 @@ VIR_ENUM_IMPL(virDomainIOAPIC, ...@@ -906,6 +906,7 @@ VIR_ENUM_IMPL(virDomainIOAPIC,
VIR_ENUM_IMPL(virDomainHPTResizing, VIR_ENUM_IMPL(virDomainHPTResizing,
VIR_DOMAIN_HPT_RESIZING_LAST, VIR_DOMAIN_HPT_RESIZING_LAST,
"none",
"enabled", "enabled",
"disabled", "disabled",
"required", "required",
...@@ -19239,14 +19240,13 @@ virDomainDefParseXML(xmlDocPtr xml, ...@@ -19239,14 +19240,13 @@ virDomainDefParseXML(xmlDocPtr xml,
tmp = virXMLPropString(nodes[i], "resizing"); tmp = virXMLPropString(nodes[i], "resizing");
if (tmp) { if (tmp) {
int value = virDomainHPTResizingTypeFromString(tmp); int value = virDomainHPTResizingTypeFromString(tmp);
if (value < 0) { if (value < 0 || value == VIR_DOMAIN_HPT_RESIZING_NONE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unknown HPT resizing setting: %s"), _("Unknown HPT resizing setting: %s"),
tmp); tmp);
goto error; goto error;
} }
def->hpt_resizing = value; def->features[val] = value;
def->features[val] = VIR_TRISTATE_SWITCH_ON;
VIR_FREE(tmp); VIR_FREE(tmp);
} }
break; break;
...@@ -21379,16 +21379,13 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src, ...@@ -21379,16 +21379,13 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
break; break;
case VIR_DOMAIN_FEATURE_HPT: case VIR_DOMAIN_FEATURE_HPT:
if (src->features[i] != dst->features[i] || if (src->features[i] != dst->features[i]) {
src->hpt_resizing != dst->hpt_resizing) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("State of feature '%s' differs: " _("State of feature '%s' differs: "
"source: '%s,%s=%s', destination: '%s,%s=%s'"), "source: '%s=%s', destination: '%s=%s'"),
featureName, featureName,
virTristateSwitchTypeToString(src->features[i]), "resizing", virDomainHPTResizingTypeToString(src->features[i]),
"resizing", virDomainHPTResizingTypeToString(src->hpt_resizing), "resizing", virDomainHPTResizingTypeToString(dst->features[i]));
virTristateSwitchTypeToString(dst->features[i]),
"resizing", virDomainHPTResizingTypeToString(dst->hpt_resizing));
return false; return false;
} }
break; break;
...@@ -26949,10 +26946,11 @@ virDomainDefFormatInternal(virDomainDefPtr def, ...@@ -26949,10 +26946,11 @@ virDomainDefFormatInternal(virDomainDefPtr def,
break; break;
case VIR_DOMAIN_FEATURE_HPT: case VIR_DOMAIN_FEATURE_HPT:
if (def->features[i] == VIR_TRISTATE_SWITCH_ON) { if (def->features[i] == VIR_DOMAIN_HPT_RESIZING_NONE)
break;
virBufferAsprintf(buf, "<hpt resizing='%s'/>\n", virBufferAsprintf(buf, "<hpt resizing='%s'/>\n",
virDomainHPTResizingTypeToString(def->hpt_resizing)); virDomainHPTResizingTypeToString(def->features[i]));
}
break; break;
/* coverity[dead_error_begin] */ /* coverity[dead_error_begin] */
......
...@@ -1871,7 +1871,8 @@ typedef enum { ...@@ -1871,7 +1871,8 @@ typedef enum {
VIR_ENUM_DECL(virDomainIOAPIC); VIR_ENUM_DECL(virDomainIOAPIC);
typedef enum { 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_DISABLED,
VIR_DOMAIN_HPT_RESIZING_REQUIRED, VIR_DOMAIN_HPT_RESIZING_REQUIRED,
...@@ -2363,7 +2364,6 @@ struct _virDomainDef { ...@@ -2363,7 +2364,6 @@ struct _virDomainDef {
unsigned int hyperv_spinlocks; unsigned int hyperv_spinlocks;
virGICVersion gic_version; virGICVersion gic_version;
char *hyperv_vendor_id; char *hyperv_vendor_id;
virDomainHPTResizing hpt_resizing;
int apic_eoi; int apic_eoi;
virDomainClockDef clock; virDomainClockDef clock;
......
...@@ -7249,7 +7249,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, ...@@ -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; const char *str;
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT)) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT)) {
...@@ -7259,7 +7259,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, ...@@ -7259,7 +7259,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
goto cleanup; goto cleanup;
} }
str = virDomainHPTResizingTypeToString(def->hpt_resizing); str = virDomainHPTResizingTypeToString(def->features[VIR_DOMAIN_FEATURE_HPT]);
if (!str) { if (!str) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Invalid setting for HPT resizing")); _("Invalid setting for HPT resizing"));
......
...@@ -3333,7 +3333,7 @@ qemuDomainDefValidateFeatures(const virDomainDef *def) ...@@ -3333,7 +3333,7 @@ qemuDomainDefValidateFeatures(const virDomainDef *def)
break; break;
case VIR_DOMAIN_FEATURE_HPT: case VIR_DOMAIN_FEATURE_HPT:
if (def->features[i] == VIR_TRISTATE_SWITCH_ON && if (def->features[i] != VIR_DOMAIN_HPT_RESIZING_NONE &&
!qemuDomainIsPSeries(def)) { !qemuDomainIsPSeries(def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("The '%s' feature is not supported for " _("The '%s' feature is not supported for "
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册