]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Yet another check for blkdeviotune values
authorMartin Kletzander <mkletzan@redhat.com>
Tue, 7 Jun 2016 13:24:13 +0000 (15:24 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Thu, 9 Jun 2016 15:16:38 +0000 (17:16 +0200)
If you want to set block device I/O tuning values that end with '_max'
and there is nothing else set, libvirt emits an error.  In particular:

  error: internal error: Unexpected error

That's an unknown error.  That is because *_max values depend on their
respective non-_max values.  QEMU even says that in the error message
sent as a response to the monitor command:

  "error": {"class": "GenericError", "desc": "bps_max/iops_max require
  corresponding bps/iops values"}

the problem was that we didn't know that and there was no check for it.
Adding such check makes sure that there will be less confused users.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_driver.c

index e70d3cec65edc2b351ec153d2358880e9ba3db82..433968a0bfaa4ad3cf8c0acdc89d9e5bcc4e6645 100644 (file)
@@ -17358,6 +17358,27 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
         }
         if (!set_size_iops)
             info.size_iops_sec = oldinfo->size_iops_sec;
+
+#define CHECK_MAX(val)                                                  \
+        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;                                            \
+            }                                                           \
+        } 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);
+
+#undef CHECK_MAX
+
         qemuDomainObjEnterMonitor(driver, vm);
         ret = qemuMonitorSetBlockIoThrottle(priv->mon, device,
                                             &info, supportMaxOptions);