Create a helper to set the bytes/iops iotune default values based on
the current qemu setting
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/qemu/qemu_driver.c | 66 ++++++++++++++++++++++++++++++--------------------
1 file changed, 40 insertions(+), 26 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 78e917e..fcce3f0 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17286,6 +17286,43 @@ qemuDomainOpenGraphicsFD(virDomainPtr dom,
return ret;
}
+
+/* If the user didn't specify bytes limits, inherit previous values;
+ * likewise if the user didn't specify iops limits. */
+static void
+qemuDomainSetBlockIoTuneSetDefaults(virDomainBlockIoTuneInfoPtr newinfo,
+ virDomainBlockIoTuneInfoPtr oldinfo,
+ bool set_bytes,
+ bool set_iops,
+ bool set_bytes_max,
+ bool set_iops_max,
+ bool set_size_iops)
+{
+ if (!set_bytes) {
+ newinfo->total_bytes_sec = oldinfo->total_bytes_sec;
+ newinfo->read_bytes_sec = oldinfo->read_bytes_sec;
+ newinfo->write_bytes_sec = oldinfo->write_bytes_sec;
+ }
+ if (!set_bytes_max) {
+ newinfo->total_bytes_sec_max = oldinfo->total_bytes_sec_max;
+ newinfo->read_bytes_sec_max = oldinfo->read_bytes_sec_max;
+ newinfo->write_bytes_sec_max = oldinfo->write_bytes_sec_max;
+ }
+ if (!set_iops) {
+ newinfo->total_iops_sec = oldinfo->total_iops_sec;
+ newinfo->read_iops_sec = oldinfo->read_iops_sec;
+ newinfo->write_iops_sec = oldinfo->write_iops_sec;
+ }
+ if (!set_iops_max) {
+ newinfo->total_iops_sec_max = oldinfo->total_iops_sec_max;
+ newinfo->read_iops_sec_max = oldinfo->read_iops_sec_max;
+ newinfo->write_iops_sec_max = oldinfo->write_iops_sec_max;
+ }
+ if (!set_size_iops)
+ newinfo->size_iops_sec = oldinfo->size_iops_sec;
+}
+
+
static int
qemuDomainSetBlockIoTune(virDomainPtr dom,
const char *path,
@@ -17473,32 +17510,9 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
if (!(device = qemuAliasFromDisk(disk)))
goto endjob;
- /* If the user didn't specify bytes limits, inherit previous
- * values; likewise if the user didn't specify iops
- * limits. */
- oldinfo = &disk->blkdeviotune;
- if (!set_bytes) {
- info.total_bytes_sec = oldinfo->total_bytes_sec;
- info.read_bytes_sec = oldinfo->read_bytes_sec;
- info.write_bytes_sec = oldinfo->write_bytes_sec;
- }
- if (!set_bytes_max) {
- info.total_bytes_sec_max = oldinfo->total_bytes_sec_max;
- info.read_bytes_sec_max = oldinfo->read_bytes_sec_max;
- info.write_bytes_sec_max = oldinfo->write_bytes_sec_max;
- }
- if (!set_iops) {
- info.total_iops_sec = oldinfo->total_iops_sec;
- info.read_iops_sec = oldinfo->read_iops_sec;
- info.write_iops_sec = oldinfo->write_iops_sec;
- }
- if (!set_iops_max) {
- info.total_iops_sec_max = oldinfo->total_iops_sec_max;
- info.read_iops_sec_max = oldinfo->read_iops_sec_max;
- info.write_iops_sec_max = oldinfo->write_iops_sec_max;
- }
- if (!set_size_iops)
- info.size_iops_sec = oldinfo->size_iops_sec;
+ qemuDomainSetBlockIoTuneSetDefaults(&info, &disk->blkdeviotune,
+ set_bytes, set_iops, set_bytes_max,
+ set_iops_max, set_size_iops);
#define CHECK_MAX(val) \
do { \
--
2.7.4