[PATCH 1/8] conf: domaincaps: Replace FORMAT_SINGLE macro by a function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Introduce qemuDomainCapsFeatureFormatSimple which does exactly the same
thing but it's a function.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/domain_capabilities.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index f922cb9055..099963dc6a 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -380,14 +380,6 @@ virDomainCapsStringValuesFormat(virBufferPtr buf,
         virBufferAddLit(buf, "</" #item ">\n"); \
     } while (0)

-#define FORMAT_SINGLE(name, supported) \
-    do { \
-        if (supported != VIR_TRISTATE_BOOL_ABSENT) { \
-            virBufferAsprintf(&buf, "<%s supported='%s'/>\n", name, \
-                    (supported == VIR_TRISTATE_BOOL_YES) ? "yes" : "no"); \
-        } \
-    } while (0)
-
 #define ENUM_PROCESS(master, capsEnum, valToStr) \
     do { \
         virDomainCapsEnumFormat(buf, &master->capsEnum, \
@@ -395,6 +387,19 @@ virDomainCapsStringValuesFormat(virBufferPtr buf,
     } while (0)


+static void
+qemuDomainCapsFeatureFormatSimple(virBufferPtr buf,
+                                  const char *featurename,
+                                  virTristateBool supported)
+{
+    if (supported == VIR_TRISTATE_BOOL_ABSENT)
+        return;
+
+    virBufferAsprintf(buf, "<%s supported='%s'/>\n", featurename,
+                      virTristateBoolTypeToString(supported));
+}
+
+
 static void
 virDomainCapsLoaderFormat(virBufferPtr buf,
                           const virDomainCapsLoader *loader)
@@ -614,7 +619,7 @@ virDomainCapsFormat(const virDomainCaps *caps)
     if (caps->maxvcpus)
         virBufferAsprintf(&buf, "<vcpu max='%d'/>\n", caps->maxvcpus);

-    FORMAT_SINGLE("iothreads", caps->iothreads);
+    qemuDomainCapsFeatureFormatSimple(&buf, "iothreads", caps->iothreads);

     virDomainCapsOSFormat(&buf, &caps->os);
     virDomainCapsCPUFormat(&buf, &caps->cpu);
@@ -635,8 +640,8 @@ virDomainCapsFormat(const virDomainCaps *caps)
     virBufferAdjustIndent(&buf, 2);

     virDomainCapsFeatureGICFormat(&buf, &caps->gic);
-    FORMAT_SINGLE("vmcoreinfo", caps->vmcoreinfo);
-    FORMAT_SINGLE("genid", caps->genid);
+    qemuDomainCapsFeatureFormatSimple(&buf, "vmcoreinfo", caps->vmcoreinfo);
+    qemuDomainCapsFeatureFormatSimple(&buf, "genid", caps->genid);
     virDomainCapsFeatureSEVFormat(&buf, caps->sev);

     virBufferAdjustIndent(&buf, -2);
-- 
2.23.0

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





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux