Rewrite the old-style parser to use virXMLNodeGetSubelementList
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/conf/domain_conf.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d510279472..3a08034b9d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16355,24 +16355,24 @@ static int
virDomainFeaturesKVMDefParse(virDomainDef *def,
xmlNodePtr node)
{
- g_autofree virDomainFeatureKVM *kvm = NULL;
-
- kvm = g_new0(virDomainFeatureKVM, 1);
+ g_autofree virDomainFeatureKVM *kvm = g_new0(virDomainFeatureKVM, 1);
+ g_autofree xmlNodePtr *feats = NULL;
+ size_t nfeats = virXMLNodeGetSubelementList(node, NULL, &feats);
+ size_t i;
- node = xmlFirstElementChild(node);
- while (node) {
+ for (i = 0; i < nfeats; i++) {
int feature;
virTristateSwitch value;
- feature = virDomainKVMTypeFromString((const char *)node->name);
+ feature = virDomainKVMTypeFromString((const char *)feats[i]->name);
if (feature < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported KVM feature: %1$s"),
- node->name);
+ feats[i]->name);
return -1;
}
- if (virXMLPropTristateSwitch(node, "state", VIR_XML_PROP_REQUIRED,
+ if (virXMLPropTristateSwitch(feats[i], "state", VIR_XML_PROP_REQUIRED,
&value) < 0)
return -1;
@@ -16382,7 +16382,7 @@ virDomainFeaturesKVMDefParse(virDomainDef *def,
if (feature == VIR_DOMAIN_KVM_DIRTY_RING &&
value == VIR_TRISTATE_SWITCH_ON) {
- if (virXMLPropUInt(node, "size", 0, VIR_XML_PROP_REQUIRED,
+ if (virXMLPropUInt(feats[i], "size", 0, VIR_XML_PROP_REQUIRED,
&kvm->dirty_ring_size) < 0) {
return -1;
}
@@ -16396,8 +16396,6 @@ virDomainFeaturesKVMDefParse(virDomainDef *def,
return -1;
}
}
-
- node = xmlNextElementSibling(node);
}
def->features[VIR_DOMAIN_FEATURE_KVM] = VIR_TRISTATE_SWITCH_ON;
--
2.41.0