conf: domaincaps: Extract formatting of the <features> subelement

Extract it to virDomainCapsFormatFeatures so that the main function does
not get so bloated over time.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2019-10-30 14:58:40 +01:00
parent c4940317ef
commit 8bc9131b1a

View File

@ -593,6 +593,23 @@ virDomainCapsFeatureSEVFormat(virBufferPtr buf,
}
static void
virDomainCapsFormatFeatures(const virDomainCaps *caps,
virBufferPtr buf)
{
virBufferAddLit(buf, "<features>\n");
virBufferAdjustIndent(buf, 2);
virDomainCapsFeatureGICFormat(buf, &caps->gic);
qemuDomainCapsFeatureFormatSimple(buf, "vmcoreinfo", caps->vmcoreinfo);
qemuDomainCapsFeatureFormatSimple(buf, "genid", caps->genid);
virDomainCapsFeatureSEVFormat(buf, caps->sev);
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</features>\n");
}
char *
virDomainCapsFormat(const virDomainCaps *caps)
{
@ -629,16 +646,7 @@ virDomainCapsFormat(const virDomainCaps *caps)
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</devices>\n");
virBufferAddLit(&buf, "<features>\n");
virBufferAdjustIndent(&buf, 2);
virDomainCapsFeatureGICFormat(&buf, &caps->gic);
qemuDomainCapsFeatureFormatSimple(&buf, "vmcoreinfo", caps->vmcoreinfo);
qemuDomainCapsFeatureFormatSimple(&buf, "genid", caps->genid);
virDomainCapsFeatureSEVFormat(&buf, caps->sev);
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</features>\n");
virDomainCapsFormatFeatures(caps, &buf);
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</domainCapabilities>\n");