qemu: Adjust how supportMaxOptions is used.

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>
This commit is contained in:
John Ferlan 2016-09-19 17:46:07 -04:00
parent a1417d5305
commit 85f05f66f4

View 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;