[PATCH 17/23] conf: get rid of macros in virDomainDiskDefFormatIotune

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

 



Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
---
 src/conf/domain_conf.c | 42 +++++++++---------------------------------
 1 file changed, 9 insertions(+), 33 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 024d0e3..bbe6ae7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -24225,54 +24225,30 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf,
 }
 
 
-#define FORMAT_IOTUNE(val) \
-        if (disk->blkdeviotune.val) { \
-            virBufferAsprintf(&childBuf, "<" #val ">%llu</" #val ">\n", \
-                              disk->blkdeviotune.val); \
-        }
-
 static void
 virDomainDiskDefFormatIotune(virBufferPtr buf,
                              virDomainDiskDefPtr disk)
 {
     g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
+    g_autofree unsigned long long **fields =
+                            virDomainBlockIoTuneFields(&disk->blkdeviotune);
+    size_t i;
 
-    FORMAT_IOTUNE(total_bytes_sec);
-    FORMAT_IOTUNE(read_bytes_sec);
-    FORMAT_IOTUNE(write_bytes_sec);
-    FORMAT_IOTUNE(total_iops_sec);
-    FORMAT_IOTUNE(read_iops_sec);
-    FORMAT_IOTUNE(write_iops_sec);
-
-    FORMAT_IOTUNE(total_bytes_sec_max);
-    FORMAT_IOTUNE(read_bytes_sec_max);
-    FORMAT_IOTUNE(write_bytes_sec_max);
-    FORMAT_IOTUNE(total_iops_sec_max);
-    FORMAT_IOTUNE(read_iops_sec_max);
-    FORMAT_IOTUNE(write_iops_sec_max);
+    for (i = 0; i < G_N_ELEMENTS(virDomainBlockIoTuneFieldNames); i++) {
+        const char *name = virDomainBlockIoTuneFieldNames[i];
 
-    if (disk->blkdeviotune.size_iops_sec) {
-        virBufferAsprintf(&childBuf, "<size_iops_sec>%llu</size_iops_sec>\n",
-                          disk->blkdeviotune.size_iops_sec);
+        if (*fields[i])
+            virBufferAsprintf(&childBuf, "<%s>%llu</%s>\n",
+                              name, *fields[i], name);
     }
 
-    if (disk->blkdeviotune.group_name) {
+    if (disk->blkdeviotune.group_name)
         virBufferEscapeString(&childBuf, "<group_name>%s</group_name>\n",
                               disk->blkdeviotune.group_name);
-    }
-
-    FORMAT_IOTUNE(total_bytes_sec_max_length);
-    FORMAT_IOTUNE(read_bytes_sec_max_length);
-    FORMAT_IOTUNE(write_bytes_sec_max_length);
-    FORMAT_IOTUNE(total_iops_sec_max_length);
-    FORMAT_IOTUNE(read_iops_sec_max_length);
-    FORMAT_IOTUNE(write_iops_sec_max_length);
 
     virXMLFormatElement(buf, "iotune", NULL, &childBuf);
 }
 
-#undef FORMAT_IOTUNE
-
 
 static void
 virDomainDiskDefFormatDriver(virBufferPtr buf,
-- 
1.8.3.1




[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