qemuValidateDomainDefPSeriesFeature: Simplify feature validation

Unify validation of VIR_DOMAIN_FEATURE_HTM, VIR_DOMAIN_FEATURE_NESTED_HV,
VIR_DOMAIN_FEATURE_CCF_ASSIST and remove temporary string.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2023-03-21 16:15:25 +01:00
parent f13a45d8a9
commit 723a3e74ab

View File

@ -39,8 +39,6 @@ static int
qemuValidateDomainDefPSeriesFeature(const virDomainDef *def, qemuValidateDomainDefPSeriesFeature(const virDomainDef *def,
int feature) int feature)
{ {
const char *str;
if (def->features[feature] == VIR_TRISTATE_SWITCH_ABSENT) if (def->features[feature] == VIR_TRISTATE_SWITCH_ABSENT)
return 0; return 0;
@ -59,8 +57,7 @@ qemuValidateDomainDefPSeriesFeature(const virDomainDef *def,
break; break;
if (def->hpt_resizing != VIR_DOMAIN_HPT_RESIZING_NONE) { if (def->hpt_resizing != VIR_DOMAIN_HPT_RESIZING_NONE) {
str = virDomainHPTResizingTypeToString(def->hpt_resizing); if (!virDomainHPTResizingTypeToString(def->hpt_resizing)) {
if (!str) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Invalid setting for HPT resizing")); _("Invalid setting for HPT resizing"));
return -1; return -1;
@ -69,33 +66,15 @@ qemuValidateDomainDefPSeriesFeature(const virDomainDef *def,
break; break;
case VIR_DOMAIN_FEATURE_HTM: case VIR_DOMAIN_FEATURE_HTM:
str = virTristateSwitchTypeToString(def->features[feature]);
if (!str) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Invalid setting for HTM state"));
return -1;
}
break;
case VIR_DOMAIN_FEATURE_NESTED_HV: case VIR_DOMAIN_FEATURE_NESTED_HV:
str = virTristateSwitchTypeToString(def->features[feature]);
if (!str) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Invalid setting for nested HV state"));
return -1;
}
break;
case VIR_DOMAIN_FEATURE_CCF_ASSIST: case VIR_DOMAIN_FEATURE_CCF_ASSIST:
str = virTristateSwitchTypeToString(def->features[feature]); if (!virTristateSwitchTypeToString(def->features[feature])) {
if (!str) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Invalid setting for pseries feature '%1$s'"),
_("Invalid setting for ccf-assist state")); virDomainFeatureTypeToString(feature));
return -1; return -1;
} }
break; break;
case VIR_DOMAIN_FEATURE_CFPC: case VIR_DOMAIN_FEATURE_CFPC: