[PATCH 5/5] qemu: Add better message for some invalid block I/O settings

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

 



For example when both total_bytes_sec and total_bytes_sec_max are set,
but the former gets cleaned due to new call setting, let's say,
read_bytes_sec, we end up with this weird message for the command:

 $ virsh blkdeviotune fedora vda --read-bytes-sec 3000
 error: Unable to change block I/O throttle
 error: unsupported configuration: value 'total_bytes_sec_max' cannot be set if 'total_bytes_sec' is not set

So let's make it more descriptive.  This is how it looks after the change:

 $ virsh blkdeviotune fedora vda --read-bytes-sec 3000
 error: Unable to change block I/O throttle
 error: unsupported configuration: cannot reset 'total_bytes_sec' when 'total_bytes_sec_max' is set

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1344897

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 46 +++++++++++++++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 15 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3a0245ec1cb8..82dda8db8f86 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17481,23 +17481,39 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
         qemuDomainSetBlockIoTuneDefaults(&info, &disk->blkdeviotune,
                                          set_fields);

-#define CHECK_MAX(val)                                                  \
+#define CHECK_MAX(val, _bool)                                           \
         do {                                                            \
-            if (info.val##_max && !info.val) {                          \
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,              \
-                               _("value '%s' cannot be set if "         \
-                                 "'%s' is not set"),                    \
-                               #val "_max", #val);                      \
-                goto endjob;                                            \
+            if (info.val##_max) {                                       \
+                if (!info.val) {                                        \
+                    if (QEMU_BLOCK_IOTUNE_SET_##_bool) {                \
+                        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,      \
+                                       _("cannot reset '%s' when "      \
+                                         "'%s' is set"),                \
+                                       #val, #val "_max");              \
+                    } else {                                            \
+                        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,      \
+                                       _("value '%s' cannot be set if " \
+                                         "'%s' is not set"),            \
+                                       #val "_max", #val);              \
+                    }                                                   \
+                    goto endjob;                                        \
+                }                                                       \
+                if (info.val##_max < info.val) {                        \
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,          \
+                                   _("value '%s' cannot be "            \
+                                     "smaller than '%s'"),              \
+                                   #val "_max", #val);                  \
+                    goto endjob;                                        \
+                }                                                       \
             }                                                           \
-        } while (false);
-
-        CHECK_MAX(total_bytes_sec);
-        CHECK_MAX(read_bytes_sec);
-        CHECK_MAX(write_bytes_sec);
-        CHECK_MAX(total_iops_sec);
-        CHECK_MAX(read_iops_sec);
-        CHECK_MAX(write_iops_sec);
+        } while (false)
+
+        CHECK_MAX(total_bytes_sec, BYTES);
+        CHECK_MAX(read_bytes_sec, BYTES);
+        CHECK_MAX(write_bytes_sec, BYTES);
+        CHECK_MAX(total_iops_sec, IOPS);
+        CHECK_MAX(read_iops_sec, IOPS);
+        CHECK_MAX(write_iops_sec, IOPS);

 #undef CHECK_MAX

-- 
2.11.0

--
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]
  Powered by Linux