]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: domcaps: Add single line formatting macro
authorCole Robinson <crobinso@redhat.com>
Fri, 8 Feb 2019 23:32:48 +0000 (18:32 -0500)
committerCole Robinson <crobinso@redhat.com>
Mon, 18 Mar 2019 14:51:02 +0000 (10:51 -0400)
Similar to the macros we have for formatting enums, add a macro to
simplify formatting the pattern:

  <FOO supported='yes|no'/>

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
src/conf/domain_capabilities.c

index a6104920abcfa51f1d906f75133ed47d65f47d35..5a26329176969d5db59911d2f08d70ea60c1deb5 100644 (file)
@@ -384,6 +384,12 @@ virDomainCapsStringValuesFormat(virBufferPtr buf,
         virBufferAddLit(buf, "</" #item ">\n"); \
     } while (0)
 
+#define FORMAT_SINGLE(name, supported) \
+    do { \
+        virBufferAsprintf(&buf, "<%s supported='%s'/>\n", name, \
+                          supported ? "yes" : "no"); \
+    } while (0)
+
 #define ENUM_PROCESS(master, capsEnum, valToStr) \
     do { \
         virDomainCapsEnumFormat(buf, &master->capsEnum, \
@@ -594,8 +600,7 @@ virDomainCapsFormat(virDomainCapsPtr const caps)
     if (caps->maxvcpus)
         virBufferAsprintf(&buf, "<vcpu max='%d'/>\n", caps->maxvcpus);
 
-    virBufferAsprintf(&buf, "<iothreads supported='%s'/>\n",
-                      caps->iothreads ? "yes" : "no");
+    FORMAT_SINGLE("iothreads", caps->iothreads);
 
     virDomainCapsOSFormat(&buf, &caps->os);
     virDomainCapsCPUFormat(&buf, &caps->cpu);
@@ -615,11 +620,8 @@ virDomainCapsFormat(virDomainCapsPtr const caps)
     virBufferAdjustIndent(&buf, 2);
 
     virDomainCapsFeatureGICFormat(&buf, &caps->gic);
-    virBufferAsprintf(&buf, "<vmcoreinfo supported='%s'/>\n",
-                      caps->vmcoreinfo ? "yes" : "no");
-
-    virBufferAsprintf(&buf, "<genid supported='%s'/>\n",
-                      caps->genid ? "yes" : "no");
+    FORMAT_SINGLE("vmcoreinfo", caps->vmcoreinfo);
+    FORMAT_SINGLE("genid", caps->genid);
     virDomainCapsFeatureSEVFormat(&buf, caps->sev);
 
     virBufferAdjustIndent(&buf, -2);