mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-12 13:17:58 +03:00
conf: Refactor formating of 'capabilities' features
Use virXMLFormatElement for the formatting which allows us to avoid looking through the array to see if any feature is enabled. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
89dda12b8d
commit
4653ae65af
@ -27928,30 +27928,23 @@ virDomainDefFormatFeatures(virBufferPtr buf,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_FEATURE_CAPABILITIES:
|
case VIR_DOMAIN_FEATURE_CAPABILITIES:
|
||||||
if (def->features[i] == VIR_DOMAIN_CAPABILITIES_POLICY_DEFAULT &&
|
virBufferSetChildIndent(&tmpChildBuf, buf);
|
||||||
!virDomainDefHasCapabilitiesFeatures(def)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
virBufferAsprintf(buf, "<capabilities policy='%s'",
|
|
||||||
virDomainCapabilitiesPolicyTypeToString(def->features[i]));
|
|
||||||
|
|
||||||
if (!virDomainDefHasCapabilitiesFeatures(def)) {
|
|
||||||
virBufferAddLit(buf, "/>\n");
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
virBufferAddLit(buf, ">\n");
|
|
||||||
}
|
|
||||||
virBufferAdjustIndent(buf, 2);
|
|
||||||
for (j = 0; j < VIR_DOMAIN_CAPS_FEATURE_LAST; j++) {
|
for (j = 0; j < VIR_DOMAIN_CAPS_FEATURE_LAST; j++) {
|
||||||
if (def->caps_features[j] != VIR_TRISTATE_SWITCH_ABSENT)
|
if (def->caps_features[j] != VIR_TRISTATE_SWITCH_ABSENT)
|
||||||
virBufferAsprintf(buf, "<%s state='%s'/>\n",
|
virBufferAsprintf(&tmpChildBuf, "<%s state='%s'/>\n",
|
||||||
virDomainCapsFeatureTypeToString(j),
|
virDomainCapsFeatureTypeToString(j),
|
||||||
virTristateSwitchTypeToString(
|
virTristateSwitchTypeToString(def->caps_features[j]));
|
||||||
def->caps_features[j]));
|
|
||||||
}
|
}
|
||||||
virBufferAdjustIndent(buf, -2);
|
|
||||||
virBufferAddLit(buf, "</capabilities>\n");
|
/* the 'default' policy should be printed if any capability is present */
|
||||||
|
if (def->features[i] != VIR_DOMAIN_CAPABILITIES_POLICY_DEFAULT ||
|
||||||
|
virBufferUse(&tmpChildBuf))
|
||||||
|
virBufferAsprintf(&tmpAttrBuf, " policy='%s'",
|
||||||
|
virDomainCapabilitiesPolicyTypeToString(def->features[i]));
|
||||||
|
|
||||||
|
if (virXMLFormatElement(buf, "capabilities", &tmpAttrBuf, &tmpChildBuf) < 0)
|
||||||
|
return -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_FEATURE_GIC:
|
case VIR_DOMAIN_FEATURE_GIC:
|
||||||
|
Loading…
Reference in New Issue
Block a user