mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 09:17:52 +03:00
virDomainFeaturesKVMDefParse: 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
6d338f2083
commit
ee7a005012
@ -16331,24 +16331,24 @@ static int
|
|||||||
virDomainFeaturesKVMDefParse(virDomainDef *def,
|
virDomainFeaturesKVMDefParse(virDomainDef *def,
|
||||||
xmlNodePtr node)
|
xmlNodePtr node)
|
||||||
{
|
{
|
||||||
g_autofree virDomainFeatureKVM *kvm = NULL;
|
g_autofree virDomainFeatureKVM *kvm = g_new0(virDomainFeatureKVM, 1);
|
||||||
|
g_autofree xmlNodePtr *feats = NULL;
|
||||||
|
size_t nfeats = virXMLNodeGetSubelementList(node, NULL, &feats);
|
||||||
|
size_t i;
|
||||||
|
|
||||||
kvm = g_new0(virDomainFeatureKVM, 1);
|
for (i = 0; i < nfeats; i++) {
|
||||||
|
|
||||||
node = xmlFirstElementChild(node);
|
|
||||||
while (node) {
|
|
||||||
int feature;
|
int feature;
|
||||||
virTristateSwitch value;
|
virTristateSwitch value;
|
||||||
|
|
||||||
feature = virDomainKVMTypeFromString((const char *)node->name);
|
feature = virDomainKVMTypeFromString((const char *)feats[i]->name);
|
||||||
if (feature < 0) {
|
if (feature < 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unsupported KVM feature: %1$s"),
|
_("unsupported KVM feature: %1$s"),
|
||||||
node->name);
|
feats[i]->name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virXMLPropTristateSwitch(node, "state", VIR_XML_PROP_REQUIRED,
|
if (virXMLPropTristateSwitch(feats[i], "state", VIR_XML_PROP_REQUIRED,
|
||||||
&value) < 0)
|
&value) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -16358,7 +16358,7 @@ virDomainFeaturesKVMDefParse(virDomainDef *def,
|
|||||||
if (feature == VIR_DOMAIN_KVM_DIRTY_RING &&
|
if (feature == VIR_DOMAIN_KVM_DIRTY_RING &&
|
||||||
value == VIR_TRISTATE_SWITCH_ON) {
|
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) {
|
&kvm->dirty_ring_size) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -16372,8 +16372,6 @@ virDomainFeaturesKVMDefParse(virDomainDef *def,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
node = xmlNextElementSibling(node);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def->features[VIR_DOMAIN_FEATURE_KVM] = VIR_TRISTATE_SWITCH_ON;
|
def->features[VIR_DOMAIN_FEATURE_KVM] = VIR_TRISTATE_SWITCH_ON;
|
||||||
|
Loading…
Reference in New Issue
Block a user