mirror of https://gitee.com/openkylin/libvirt.git
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 <abologna@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
c5a451ef21
commit
3dd1eb3b26
|
@ -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, "<hpt resizing='%s'/>\n",
|
||||
virDomainHPTResizingTypeToString(def->hpt_resizing));
|
||||
}
|
||||
if (def->features[i] == VIR_DOMAIN_HPT_RESIZING_NONE)
|
||||
break;
|
||||
|
||||
virBufferAsprintf(buf, "<hpt resizing='%s'/>\n",
|
||||
virDomainHPTResizingTypeToString(def->features[i]));
|
||||
break;
|
||||
|
||||
/* coverity[dead_error_begin] */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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 "
|
||||
|
|
Loading…
Reference in New Issue