mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
virDomainFeaturesXENDefParse: Use virXMLNodeGetSubelementList
Rewrite the old-style parser to use virXMLNodeGetSubelementList Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
ee7a005012
commit
8d76c9390e
@ -16385,22 +16385,25 @@ static int
|
|||||||
virDomainFeaturesXENDefParse(virDomainDef *def,
|
virDomainFeaturesXENDefParse(virDomainDef *def,
|
||||||
xmlNodePtr node)
|
xmlNodePtr node)
|
||||||
{
|
{
|
||||||
|
g_autofree xmlNodePtr *feats = NULL;
|
||||||
|
size_t nfeats = virXMLNodeGetSubelementList(node, NULL, &feats);
|
||||||
|
size_t i;
|
||||||
|
|
||||||
def->features[VIR_DOMAIN_FEATURE_XEN] = VIR_TRISTATE_SWITCH_ON;
|
def->features[VIR_DOMAIN_FEATURE_XEN] = VIR_TRISTATE_SWITCH_ON;
|
||||||
|
|
||||||
node = xmlFirstElementChild(node);
|
for (i = 0; i < nfeats; i++) {
|
||||||
while (node) {
|
|
||||||
int feature;
|
int feature;
|
||||||
virTristateSwitch value;
|
virTristateSwitch value;
|
||||||
|
|
||||||
feature = virDomainXenTypeFromString((const char *)node->name);
|
feature = virDomainXenTypeFromString((const char *)feats[i]->name);
|
||||||
if (feature < 0) {
|
if (feature < 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unsupported Xen feature: %1$s"),
|
_("unsupported Xen feature: %1$s"),
|
||||||
node->name);
|
feats[i]->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virXMLPropTristateSwitch(node, "state",
|
if (virXMLPropTristateSwitch(feats[i], "state",
|
||||||
VIR_XML_PROP_REQUIRED, &value) < 0)
|
VIR_XML_PROP_REQUIRED, &value) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -16414,7 +16417,7 @@ virDomainFeaturesXENDefParse(virDomainDef *def,
|
|||||||
if (value != VIR_TRISTATE_SWITCH_ON)
|
if (value != VIR_TRISTATE_SWITCH_ON)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (virXMLPropEnum(node, "mode",
|
if (virXMLPropEnum(feats[i], "mode",
|
||||||
virDomainXenPassthroughModeTypeFromString,
|
virDomainXenPassthroughModeTypeFromString,
|
||||||
VIR_XML_PROP_NONZERO,
|
VIR_XML_PROP_NONZERO,
|
||||||
&def->xen_passthrough_mode) < 0)
|
&def->xen_passthrough_mode) < 0)
|
||||||
@ -16424,8 +16427,6 @@ virDomainFeaturesXENDefParse(virDomainDef *def,
|
|||||||
case VIR_DOMAIN_XEN_LAST:
|
case VIR_DOMAIN_XEN_LAST:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
node = xmlNextElementSibling(node);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user