[04/10] conf: domcaps: Add single line formatting macro

Message ID a816be3e7f3fb15f84a0d34b1d697b604f54d370.1550606392.git.crobinso@redhat.com
State Superseded
Headers show
Series
  • domcaps: use virTristateBool
Related show

Commit Message

Cole Robinson Feb. 19, 2019, 8:09 p.m.
Similar to the macros we have for formatting enums, add a macro to
simplify formatting the pattern:

  <FOO supported='yes|no'/>

Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
 src/conf/domain_capabilities.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Patch

diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index 6352eda343..4539281ff5 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -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, \
@@ -593,8 +599,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);
@@ -614,11 +619,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);