mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
virDomainFeaturesDefParse: Factor out KVM parsing into separate function
Only moving code, cleanup to follow. Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
95ef93f2a3
commit
947204c1a2
@ -17398,6 +17398,54 @@ virDomainFeaturesHyperVDefParse(virDomainDef *def,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virDomainFeaturesKVMDefParse(virDomainDef *def,
|
||||
xmlXPathContext *ctxt)
|
||||
{
|
||||
g_autofree xmlNodePtr *nodes = NULL;
|
||||
size_t i;
|
||||
int n;
|
||||
|
||||
def->features[VIR_DOMAIN_FEATURE_KVM] = VIR_TRISTATE_SWITCH_ON;
|
||||
|
||||
if (def->features[VIR_DOMAIN_FEATURE_KVM] == VIR_TRISTATE_SWITCH_ON) {
|
||||
int feature;
|
||||
virTristateSwitch value;
|
||||
if ((n = virXPathNodeSet("./features/kvm/*", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
feature = virDomainKVMTypeFromString((const char *)nodes[i]->name);
|
||||
if (feature < 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unsupported KVM feature: %s"),
|
||||
nodes[i]->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch ((virDomainKVM) feature) {
|
||||
case VIR_DOMAIN_KVM_HIDDEN:
|
||||
case VIR_DOMAIN_KVM_DEDICATED:
|
||||
case VIR_DOMAIN_KVM_POLLCONTROL:
|
||||
if (virXMLPropTristateSwitch(nodes[i], "state",
|
||||
VIR_XML_PROP_REQUIRED,
|
||||
&value) < 0)
|
||||
return -1;
|
||||
|
||||
def->kvm_features[feature] = value;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_KVM_LAST:
|
||||
break;
|
||||
}
|
||||
}
|
||||
VIR_FREE(nodes);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virDomainFeaturesDefParse(virDomainDef *def,
|
||||
xmlXPathContextPtr ctxt)
|
||||
@ -17435,7 +17483,6 @@ virDomainFeaturesDefParse(virDomainDef *def,
|
||||
case VIR_DOMAIN_FEATURE_PAE:
|
||||
case VIR_DOMAIN_FEATURE_VIRIDIAN:
|
||||
case VIR_DOMAIN_FEATURE_PRIVNET:
|
||||
case VIR_DOMAIN_FEATURE_KVM:
|
||||
case VIR_DOMAIN_FEATURE_MSRS:
|
||||
case VIR_DOMAIN_FEATURE_XEN:
|
||||
def->features[val] = VIR_TRISTATE_SWITCH_ON;
|
||||
@ -17446,6 +17493,11 @@ virDomainFeaturesDefParse(virDomainDef *def,
|
||||
return -1;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_FEATURE_KVM:
|
||||
if (virDomainFeaturesKVMDefParse(def, ctxt) < 0)
|
||||
return -1;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_FEATURE_CAPABILITIES: {
|
||||
virDomainCapabilitiesPolicy policy;
|
||||
|
||||
@ -17579,40 +17631,6 @@ virDomainFeaturesDefParse(virDomainDef *def,
|
||||
}
|
||||
VIR_FREE(nodes);
|
||||
|
||||
if (def->features[VIR_DOMAIN_FEATURE_KVM] == VIR_TRISTATE_SWITCH_ON) {
|
||||
int feature;
|
||||
virTristateSwitch value;
|
||||
if ((n = virXPathNodeSet("./features/kvm/*", ctxt, &nodes)) < 0)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
feature = virDomainKVMTypeFromString((const char *)nodes[i]->name);
|
||||
if (feature < 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unsupported KVM feature: %s"),
|
||||
nodes[i]->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch ((virDomainKVM) feature) {
|
||||
case VIR_DOMAIN_KVM_HIDDEN:
|
||||
case VIR_DOMAIN_KVM_DEDICATED:
|
||||
case VIR_DOMAIN_KVM_POLLCONTROL:
|
||||
if (virXMLPropTristateSwitch(nodes[i], "state",
|
||||
VIR_XML_PROP_REQUIRED,
|
||||
&value) < 0)
|
||||
return -1;
|
||||
|
||||
def->kvm_features[feature] = value;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_KVM_LAST:
|
||||
break;
|
||||
}
|
||||
}
|
||||
VIR_FREE(nodes);
|
||||
}
|
||||
|
||||
if (def->features[VIR_DOMAIN_FEATURE_XEN] == VIR_TRISTATE_SWITCH_ON) {
|
||||
int feature;
|
||||
virTristateSwitch value;
|
||||
|
Loading…
Reference in New Issue
Block a user