[PATCH 04/12] qemu: Convert from shorthand to longer throttling names

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

 



We're about to add 6 new options and it appears (from testing) one cannot
utilize both the shorthand (alias) and (much) longer names for the arguments.
So modify the command builder to use the longer name and of course alter the
test output .args to have the similarly innocuous long name.

Also utilize a macro to build that name makes it so much more visually
appealing and saves a few characters or potential cut-n-paste issues.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/qemu/qemu_command.c                            | 77 +++++-----------------
 .../qemuxml2argv-blkdeviotune-max.args             | 10 ++-
 .../qemuxml2argv-blkdeviotune.args                 |  5 +-
 3 files changed, 28 insertions(+), 64 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 1ac0fa1..20fe6fc 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1766,70 +1766,29 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
         goto error;
     }
 
-    if (disk->blkdeviotune.total_bytes_sec) {
-        virBufferAsprintf(&opt, ",bps=%llu",
-                          disk->blkdeviotune.total_bytes_sec);
+#define IOTUNE_ADD(_field, _label)                                             \
+    if (disk->blkdeviotune._field) {                                           \
+        virBufferAsprintf(&opt, ",throttling." _label "=%llu",                 \
+                           disk->blkdeviotune._field);                         \
     }
 
-    if (disk->blkdeviotune.read_bytes_sec) {
-        virBufferAsprintf(&opt, ",bps_rd=%llu",
-                          disk->blkdeviotune.read_bytes_sec);
-    }
-
-    if (disk->blkdeviotune.write_bytes_sec) {
-        virBufferAsprintf(&opt, ",bps_wr=%llu",
-                          disk->blkdeviotune.write_bytes_sec);
-    }
-
-    if (disk->blkdeviotune.total_iops_sec) {
-        virBufferAsprintf(&opt, ",iops=%llu",
-                          disk->blkdeviotune.total_iops_sec);
-    }
-
-    if (disk->blkdeviotune.read_iops_sec) {
-        virBufferAsprintf(&opt, ",iops_rd=%llu",
-                          disk->blkdeviotune.read_iops_sec);
-    }
-
-    if (disk->blkdeviotune.write_iops_sec) {
-        virBufferAsprintf(&opt, ",iops_wr=%llu",
-                          disk->blkdeviotune.write_iops_sec);
-    }
-
-    if (disk->blkdeviotune.total_bytes_sec_max) {
-        virBufferAsprintf(&opt, ",bps_max=%llu",
-                          disk->blkdeviotune.total_bytes_sec_max);
-    }
-
-    if (disk->blkdeviotune.read_bytes_sec_max) {
-        virBufferAsprintf(&opt, ",bps_rd_max=%llu",
-                          disk->blkdeviotune.read_bytes_sec_max);
-    }
-
-    if (disk->blkdeviotune.write_bytes_sec_max) {
-        virBufferAsprintf(&opt, ",bps_wr_max=%llu",
-                          disk->blkdeviotune.write_bytes_sec_max);
-    }
+    IOTUNE_ADD(total_bytes_sec, "bps-total");
+    IOTUNE_ADD(read_bytes_sec, "bps-read");
+    IOTUNE_ADD(write_bytes_sec, "bps-write");
+    IOTUNE_ADD(total_iops_sec, "iops-total");
+    IOTUNE_ADD(read_iops_sec, "iops-read");
+    IOTUNE_ADD(write_iops_sec, "iops-write");
 
-    if (disk->blkdeviotune.total_iops_sec_max) {
-        virBufferAsprintf(&opt, ",iops_max=%llu",
-                          disk->blkdeviotune.total_iops_sec_max);
-    }
+    IOTUNE_ADD(total_bytes_sec_max, "bps-total-max");
+    IOTUNE_ADD(read_bytes_sec_max, "bps-read-max");
+    IOTUNE_ADD(write_bytes_sec_max, "bps-write-max");
+    IOTUNE_ADD(total_iops_sec_max, "iops-total-max");
+    IOTUNE_ADD(read_iops_sec_max, "iops-read-max");
+    IOTUNE_ADD(write_iops_sec_max, "iops-write-max");
 
-    if (disk->blkdeviotune.read_iops_sec_max) {
-        virBufferAsprintf(&opt, ",iops_rd_max=%llu",
-                          disk->blkdeviotune.read_iops_sec_max);
-    }
+    IOTUNE_ADD(size_iops_sec, "iops-size");
 
-    if (disk->blkdeviotune.write_iops_sec_max) {
-        virBufferAsprintf(&opt, ",iops_wr_max=%llu",
-                          disk->blkdeviotune.write_iops_sec_max);
-    }
-
-    if (disk->blkdeviotune.size_iops_sec) {
-        virBufferAsprintf(&opt, ",iops_size=%llu",
-                          disk->blkdeviotune.size_iops_sec);
-    }
+#undef IOTUNE_ADD
 
     if (virBufferCheckError(&opt) < 0)
         goto error;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-blkdeviotune-max.args b/tests/qemuxml2argvdata/qemuxml2argv-blkdeviotune-max.args
index 66e1c10..58c15c8 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-blkdeviotune-max.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-blkdeviotune-max.args
@@ -18,10 +18,14 @@ QEMU_AUDIO_DRV=none \
 -boot c \
 -usb \
 -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\
-cache=none,bps=5000,iops=6000,bps_max=10000,iops_max=11000 \
+cache=none,throttling.bps-total=5000,throttling.iops-total=6000,\
+throttling.bps-total-max=10000,throttling.iops-total-max=11000 \
 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
 -drive file=/dev/HostVG/QEMUGuest2,format=qcow2,if=none,id=drive-ide0-0-1,\
-cache=none,bps_rd=5000,bps_wr=5500,iops_rd=3500,iops_wr=4000,bps_rd_max=6000,\
-bps_wr_max=6500,iops_rd_max=7000,iops_wr_max=7500,iops_size=2000 \
+cache=none,throttling.bps-read=5000,throttling.bps-write=5500,\
+throttling.iops-read=3500,throttling.iops-write=4000,\
+throttling.bps-read-max=6000,throttling.bps-write-max=6500,\
+throttling.iops-read-max=7000,throttling.iops-write-max=7500,\
+throttling.iops-size=2000 \
 -device ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-blkdeviotune.args b/tests/qemuxml2argvdata/qemuxml2argv-blkdeviotune.args
index 1f9983f..11833e6 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-blkdeviotune.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-blkdeviotune.args
@@ -18,9 +18,10 @@ QEMU_AUDIO_DRV=none \
 -boot c \
 -usb \
 -drive file=/dev/HostVG/QEMUGuest1,format=qcow2,if=none,id=drive-ide0-0-0,\
-cache=none,bps=5000,iops=6000 \
+cache=none,throttling.bps-total=5000,throttling.iops-total=6000 \
 -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
 -drive file=/dev/HostVG/QEMUGuest2,format=qcow2,if=none,id=drive-ide0-0-1,\
-cache=none,bps_rd=5000,bps_wr=5000,iops=7000 \
+cache=none,throttling.bps-read=5000,throttling.bps-write=5000,\
+throttling.iops-total=7000 \
 -device ide-drive,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
-- 
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]