mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
conf: refactor hyperv features parsing
1. All hyperv features are tristate ones. So make tristate parsing code common. 2. Reindent switch statement. 3. Reduce nesting in spinlocks parsing. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
5b5f12cffa
commit
ae37d9f1d1
@ -15583,9 +15583,6 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|||||||
|
|
||||||
ctxt->node = nodes[i];
|
ctxt->node = nodes[i];
|
||||||
|
|
||||||
switch ((virDomainHyperv) feature) {
|
|
||||||
case VIR_DOMAIN_HYPERV_RELAXED:
|
|
||||||
case VIR_DOMAIN_HYPERV_VAPIC:
|
|
||||||
if (!(tmp = virXPathString("string(./@state)", ctxt))) {
|
if (!(tmp = virXPathString("string(./@state)", ctxt))) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
_("missing 'state' attribute for "
|
_("missing 'state' attribute for "
|
||||||
@ -15604,27 +15601,16 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|||||||
|
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
def->hyperv_features[feature] = value;
|
def->hyperv_features[feature] = value;
|
||||||
|
|
||||||
|
switch ((virDomainHyperv) feature) {
|
||||||
|
case VIR_DOMAIN_HYPERV_RELAXED:
|
||||||
|
case VIR_DOMAIN_HYPERV_VAPIC:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_HYPERV_SPINLOCKS:
|
case VIR_DOMAIN_HYPERV_SPINLOCKS:
|
||||||
if (!(tmp = virXPathString("string(./@state)", ctxt))) {
|
if (value != VIR_TRISTATE_SWITCH_ON)
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
break;
|
||||||
_("missing 'state' attribute for "
|
|
||||||
"HyperV Enlightenment feature '%s'"),
|
|
||||||
nodes[i]->name);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((value = virTristateSwitchTypeFromString(tmp)) < 0) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
_("invalid value of state argument "
|
|
||||||
"for HyperV Enlightenment feature '%s'"),
|
|
||||||
nodes[i]->name);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
VIR_FREE(tmp);
|
|
||||||
if (value == VIR_TRISTATE_SWITCH_ON) {
|
|
||||||
if (virXPathUInt("string(./@retries)", ctxt,
|
if (virXPathUInt("string(./@retries)", ctxt,
|
||||||
&def->hyperv_spinlocks) < 0) {
|
&def->hyperv_spinlocks) < 0) {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
@ -15638,8 +15624,6 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|||||||
"at least 4095"));
|
"at least 4095"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
def->hyperv_features[feature] = value;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* coverity[dead_error_begin] */
|
/* coverity[dead_error_begin] */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user