]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Adjust how supportMaxOptions is used.
authorJohn Ferlan <jferlan@redhat.com>
Mon, 19 Sep 2016 21:46:07 +0000 (17:46 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 5 Oct 2016 22:53:55 +0000 (18:53 -0400)
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@redhat.com>
src/qemu/qemu_monitor_json.c

index 458b1127697224d9f95e47ea5157238e64308876..349a64fa30e31b8326eb53097e32687ce0c665f8 100644 (file)
@@ -4588,35 +4588,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,
+                                    !supportMaxOptions ? NULL :
+                                    "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);
     if (!cmd)
         return -1;