From 8bc9131b1a2a59fb21657ec9741700cd762a73d8 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 30 Oct 2019 14:58:40 +0100 Subject: [PATCH] conf: domaincaps: Extract formatting of the subelement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extract it to virDomainCapsFormatFeatures so that the main function does not get so bloated over time. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/conf/domain_capabilities.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index ec5bef55c6..6fa2e71afb 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -593,6 +593,23 @@ virDomainCapsFeatureSEVFormat(virBufferPtr buf, } +static void +virDomainCapsFormatFeatures(const virDomainCaps *caps, + virBufferPtr buf) +{ + virBufferAddLit(buf, "\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, "\n"); +} + + char * virDomainCapsFormat(const virDomainCaps *caps) { @@ -629,16 +646,7 @@ virDomainCapsFormat(const virDomainCaps *caps) virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); - virBufferAddLit(&buf, "\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, "\n"); + virDomainCapsFormatFeatures(caps, &buf); virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n");