[libvirt] [PATCH 2/8] conf: domaincaps: Extract formatting of the <features> subelement

Peter Krempa pkrempa at redhat.com
Wed Nov 13 16:05:20 UTC 2019


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

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 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 099963dc6a..2c1c5fc9e8 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -600,6 +600,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)
 {
@@ -636,16 +653,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");
-- 
2.23.0




More information about the libvir-list mailing list