mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
virDomainFeaturesXENDefParse: 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
6b45c61e88
commit
f1149b8d3a
@ -17432,31 +17432,25 @@ virDomainFeaturesKVMDefParse(virDomainDef *def,
|
||||
|
||||
static int
|
||||
virDomainFeaturesXENDefParse(virDomainDef *def,
|
||||
xmlXPathContext *ctxt)
|
||||
xmlNodePtr node)
|
||||
{
|
||||
g_autofree xmlNodePtr *nodes = NULL;
|
||||
size_t i;
|
||||
int n;
|
||||
|
||||
def->features[VIR_DOMAIN_FEATURE_XEN] = VIR_TRISTATE_SWITCH_ON;
|
||||
|
||||
if (def->features[VIR_DOMAIN_FEATURE_XEN] == VIR_TRISTATE_SWITCH_ON) {
|
||||
int feature;
|
||||
virTristateSwitch value;
|
||||
|
||||
if ((n = virXPathNodeSet("./features/xen/*", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
feature = virDomainXenTypeFromString((const char *)nodes[i]->name);
|
||||
node = xmlFirstElementChild(node);
|
||||
while (node) {
|
||||
feature = virDomainXenTypeFromString((const char *)node->name);
|
||||
if (feature < 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unsupported Xen feature: %s"),
|
||||
nodes[i]->name);
|
||||
node->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virXMLPropTristateSwitch(nodes[i], "state",
|
||||
if (virXMLPropTristateSwitch(node, "state",
|
||||
VIR_XML_PROP_REQUIRED, &value) < 0)
|
||||
return -1;
|
||||
|
||||
@ -17470,7 +17464,7 @@ virDomainFeaturesXENDefParse(virDomainDef *def,
|
||||
if (value != VIR_TRISTATE_SWITCH_ON)
|
||||
break;
|
||||
|
||||
if (virXMLPropEnum(nodes[i], "mode",
|
||||
if (virXMLPropEnum(node, "mode",
|
||||
virDomainXenPassthroughModeTypeFromString,
|
||||
VIR_XML_PROP_NONZERO,
|
||||
&def->xen_passthrough_mode) < 0)
|
||||
@ -17480,8 +17474,9 @@ virDomainFeaturesXENDefParse(virDomainDef *def,
|
||||
case VIR_DOMAIN_XEN_LAST:
|
||||
break;
|
||||
}
|
||||
|
||||
node = xmlNextElementSibling(node);
|
||||
}
|
||||
VIR_FREE(nodes);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -17540,7 +17535,7 @@ virDomainFeaturesDefParse(virDomainDef *def,
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_FEATURE_XEN:
|
||||
if (virDomainFeaturesXENDefParse(def, ctxt) < 0)
|
||||
if (virDomainFeaturesXENDefParse(def, nodes[i]) < 0)
|
||||
return -1;
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user