[PATCH 05/12] qemu: Adjust how supportMaxOptions is used.

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

 



We're about to add more options, let's avoid having multiple if-then-else
which each try to set up the qemuMonitorJSONMakeCommand call with all the
parameters it knows about.

Instead, use the fact that when a NULL is found in the argument list that
processing of the remaining arguments stops and just have call.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/qemu/qemu_monitor_json.c | 49 ++++++++++++++++++--------------------------
 1 file changed, 20 insertions(+), 29 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index e1494df..43a3fa7 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -4587,35 +4587,26 @@ int qemuMonitorJSONSetBlockIoThrottle(qemuMonitorPtr mon,
     virJSONValuePtr result = NULL;
 
     /* The qemu capability check has already been made in
-     * qemuDomainSetBlockIoTune */
-    if (supportMaxOptions) {
-        cmd = qemuMonitorJSONMakeCommand("block_set_io_throttle",
-                                         "s:device", device,
-                                         "U:bps", info->total_bytes_sec,
-                                         "U:bps_rd", info->read_bytes_sec,
-                                         "U:bps_wr", info->write_bytes_sec,
-                                         "U:iops", info->total_iops_sec,
-                                         "U:iops_rd", info->read_iops_sec,
-                                         "U:iops_wr", info->write_iops_sec,
-                                         "U:bps_max", info->total_bytes_sec_max,
-                                         "U:bps_rd_max", info->read_bytes_sec_max,
-                                         "U:bps_wr_max", info->write_bytes_sec_max,
-                                         "U:iops_max", info->total_iops_sec_max,
-                                         "U:iops_rd_max", info->read_iops_sec_max,
-                                         "U:iops_wr_max", info->write_iops_sec_max,
-                                         "U:iops_size", info->size_iops_sec,
-                                         NULL);
-    } else {
-        cmd = qemuMonitorJSONMakeCommand("block_set_io_throttle",
-                                         "s:device", device,
-                                         "U:bps", info->total_bytes_sec,
-                                         "U:bps_rd", info->read_bytes_sec,
-                                         "U:bps_wr", info->write_bytes_sec,
-                                         "U:iops", info->total_iops_sec,
-                                         "U:iops_rd", info->read_iops_sec,
-                                         "U:iops_wr", info->write_iops_sec,
-                                         NULL);
-    }
+     * qemuDomainSetBlockIoTune. NB, once a NULL is found in
+     * the sequence, qemuMonitorJSONMakeCommand will stop. So
+     * let's make use of that when !supportMaxOptions */
+   cmd = qemuMonitorJSONMakeCommand("block_set_io_throttle",
+                                    "s:device", device,
+                                    "U:bps", info->total_bytes_sec,
+                                    "U:bps_rd", info->read_bytes_sec,
+                                    "U:bps_wr", info->write_bytes_sec,
+                                    "U:iops", info->total_iops_sec,
+                                    "U:iops_rd", info->read_iops_sec,
+                                    "U:iops_wr", info->write_iops_sec,
+                                    "U:bps_max", info->total_bytes_sec_max,
+                                    !supportMaxOptions ? NULL :
+                                    "U:bps_rd_max", info->read_bytes_sec_max,
+                                    "U:bps_wr_max", info->write_bytes_sec_max,
+                                    "U:iops_max", info->total_iops_sec_max,
+                                    "U:iops_rd_max", info->read_iops_sec_max,
+                                    "U:iops_wr_max", info->write_iops_sec_max,
+                                    "U:iops_size", info->size_iops_sec,
+                                    NULL);
     if (!cmd)
         return -1;
 
-- 
2.7.4

--
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]