virDomainFeaturesCapabilitiesDefParse: Remove ctxt
Iterating over all child elements of a node does not require xpath. By doing away with xpath for this code, the code can be simplified. Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
2afc9fdc82
commit
f1a65a8163
@ -17483,12 +17483,8 @@ virDomainFeaturesXENDefParse(virDomainDef *def,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
virDomainFeaturesCapabilitiesDefParse(virDomainDef *def,
|
virDomainFeaturesCapabilitiesDefParse(virDomainDef *def,
|
||||||
xmlNodePtr node,
|
xmlNodePtr node)
|
||||||
xmlXPathContext *ctxt)
|
|
||||||
{
|
{
|
||||||
g_autofree xmlNodePtr *nodes = NULL;
|
|
||||||
size_t i;
|
|
||||||
int n;
|
|
||||||
virDomainCapabilitiesPolicy policy;
|
virDomainCapabilitiesPolicy policy;
|
||||||
|
|
||||||
if (virXMLPropEnumDefault(node, "policy",
|
if (virXMLPropEnumDefault(node, "policy",
|
||||||
@ -17499,27 +17495,25 @@ virDomainFeaturesCapabilitiesDefParse(virDomainDef *def,
|
|||||||
|
|
||||||
def->features[VIR_DOMAIN_FEATURE_CAPABILITIES] = policy;
|
def->features[VIR_DOMAIN_FEATURE_CAPABILITIES] = policy;
|
||||||
|
|
||||||
if ((n = virXPathNodeSet("./features/capabilities/*", ctxt, &nodes)) < 0)
|
node = xmlFirstElementChild(node);
|
||||||
return -1;
|
while (node) {
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
virTristateSwitch state;
|
virTristateSwitch state;
|
||||||
int val = virDomainProcessCapsFeatureTypeFromString((const char *)nodes[i]->name);
|
int val = virDomainProcessCapsFeatureTypeFromString((const char *)node->name);
|
||||||
if (val < 0) {
|
if (val < 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unexpected capability feature '%s'"), nodes[i]->name);
|
_("unexpected capability feature '%s'"), node->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (virXMLPropTristateSwitch(nodes[i], "state", VIR_XML_PROP_NONE,
|
if (virXMLPropTristateSwitch(node, "state", VIR_XML_PROP_NONE, &state) < 0)
|
||||||
&state) < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (state == VIR_TRISTATE_SWITCH_ABSENT)
|
if (state == VIR_TRISTATE_SWITCH_ABSENT)
|
||||||
state = VIR_TRISTATE_SWITCH_ON;
|
state = VIR_TRISTATE_SWITCH_ON;
|
||||||
|
|
||||||
def->caps_features[val] = state;
|
def->caps_features[val] = state;
|
||||||
|
node = xmlNextElementSibling(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -17594,7 +17588,7 @@ virDomainFeaturesDefParse(virDomainDef *def,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_FEATURE_CAPABILITIES: {
|
case VIR_DOMAIN_FEATURE_CAPABILITIES: {
|
||||||
if (virDomainFeaturesCapabilitiesDefParse(def, nodes[i], ctxt) < 0)
|
if (virDomainFeaturesCapabilitiesDefParse(def, nodes[i]) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user