]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Limit maximum block device I/O tune values
authorMartin Kletzander <mkletzan@redhat.com>
Wed, 20 Apr 2016 14:14:02 +0000 (16:14 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Fri, 22 Apr 2016 05:29:03 +0000 (07:29 +0200)
The values are currently limited to LLONG_MAX which causes some
problems.  QEMU conveniently changed their maximum to 1e15 (1 PB) which
is enough for some time and we need to adapt to that so that we don't
throw "Unknown error" messages.  Strictly limiting these values actually
fixes some corner case values (off-by-one checks in QEMU probably).

Since values out of the new specified range do not overflow anything,
change the type of error as well.

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

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

index 2fb967acbfe8b857d1c84faf165e63c8e265222a..ef4a62dafb5b936e2f88260e065de111ded66838 100644 (file)
@@ -1394,22 +1394,22 @@ qemuBuildDriveStr(virConnectPtr conn,
         goto error;
     }
 
-    if (disk->blkdeviotune.total_bytes_sec > LLONG_MAX ||
-        disk->blkdeviotune.read_bytes_sec > LLONG_MAX ||
-        disk->blkdeviotune.write_bytes_sec > LLONG_MAX ||
-        disk->blkdeviotune.total_iops_sec > LLONG_MAX ||
-        disk->blkdeviotune.read_iops_sec > LLONG_MAX ||
-        disk->blkdeviotune.write_iops_sec > LLONG_MAX ||
-        disk->blkdeviotune.total_bytes_sec_max > LLONG_MAX ||
-        disk->blkdeviotune.read_bytes_sec_max > LLONG_MAX ||
-        disk->blkdeviotune.write_bytes_sec_max > LLONG_MAX ||
-        disk->blkdeviotune.total_iops_sec_max > LLONG_MAX ||
-        disk->blkdeviotune.read_iops_sec_max > LLONG_MAX ||
-        disk->blkdeviotune.write_iops_sec_max > LLONG_MAX ||
-        disk->blkdeviotune.size_iops_sec > LLONG_MAX) {
-        virReportError(VIR_ERR_OVERFLOW,
+    if (disk->blkdeviotune.total_bytes_sec > QEMU_BLOCK_IOTUNE_MAX ||
+        disk->blkdeviotune.read_bytes_sec > QEMU_BLOCK_IOTUNE_MAX ||
+        disk->blkdeviotune.write_bytes_sec > QEMU_BLOCK_IOTUNE_MAX ||
+        disk->blkdeviotune.total_iops_sec > QEMU_BLOCK_IOTUNE_MAX ||
+        disk->blkdeviotune.read_iops_sec > QEMU_BLOCK_IOTUNE_MAX ||
+        disk->blkdeviotune.write_iops_sec > QEMU_BLOCK_IOTUNE_MAX ||
+        disk->blkdeviotune.total_bytes_sec_max > QEMU_BLOCK_IOTUNE_MAX ||
+        disk->blkdeviotune.read_bytes_sec_max > QEMU_BLOCK_IOTUNE_MAX ||
+        disk->blkdeviotune.write_bytes_sec_max > QEMU_BLOCK_IOTUNE_MAX ||
+        disk->blkdeviotune.total_iops_sec_max > QEMU_BLOCK_IOTUNE_MAX ||
+        disk->blkdeviotune.read_iops_sec_max > QEMU_BLOCK_IOTUNE_MAX ||
+        disk->blkdeviotune.write_iops_sec_max > QEMU_BLOCK_IOTUNE_MAX ||
+        disk->blkdeviotune.size_iops_sec > QEMU_BLOCK_IOTUNE_MAX) {
+        virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
                       _("block I/O throttle limit must "
-                        "be less than %llu using QEMU"), LLONG_MAX);
+                        "be less than %llu using QEMU"), QEMU_BLOCK_IOTUNE_MAX);
         goto error;
     }
 
index 2e2f133ac34170ab47e28f1b3263f091d4a1484b..1e9ce6690603206381f0b2dbad9e8e0851cd9f9f 100644 (file)
@@ -40,6 +40,8 @@
 # define QEMU_DRIVE_HOST_PREFIX "drive-"
 # define QEMU_FSDEV_HOST_PREFIX "fsdev-"
 
+# define QEMU_BLOCK_IOTUNE_MAX 1000000000000000LL
+
 VIR_ENUM_DECL(qemuVideo)
 
 char *qemuBuildObjectCommandlineFromJSON(const char *type,
index 055f0714ddf32cc3b0350ac0ee13fae7d9ec59cd..90f541cf6d749bfa658bd448d63a6e21734ff2b8 100644 (file)
@@ -17526,10 +17526,10 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
     for (i = 0; i < nparams; i++) {
         virTypedParameterPtr param = &params[i];
 
-        if (param->value.ul > LLONG_MAX) {
-            virReportError(VIR_ERR_OVERFLOW,
+        if (param->value.ul > QEMU_BLOCK_IOTUNE_MAX) {
+            virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
                            _("block I/O throttle limit value must"
-                             " be less than %llu"), LLONG_MAX);
+                             " be less than %llu"), QEMU_BLOCK_IOTUNE_MAX);
             goto endjob;
         }