]> git.proxmox.com Git - qemu.git/commitdiff
block: refuse negative iops and bps values
authorStefan Hajnoczi <stefanha@redhat.com>
Wed, 13 Feb 2013 15:53:43 +0000 (16:53 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 22 Feb 2013 20:21:09 +0000 (21:21 +0100)
Negative I/O throttling iops and bps values do not make sense so reject
them with an error message.

Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
blockdev.c

index 9b0351343ef2b436bd651f03f1df07b1a823c75b..ba3759c849189471adfb0d2532457ab59d63eedf 100644 (file)
@@ -274,6 +274,16 @@ static bool do_check_io_limits(BlockIOLimit *io_limits, Error **errp)
         return false;
     }
 
+    if (io_limits->bps[BLOCK_IO_LIMIT_TOTAL] < 0 ||
+        io_limits->bps[BLOCK_IO_LIMIT_WRITE] < 0 ||
+        io_limits->bps[BLOCK_IO_LIMIT_READ] < 0 ||
+        io_limits->iops[BLOCK_IO_LIMIT_TOTAL] < 0 ||
+        io_limits->iops[BLOCK_IO_LIMIT_WRITE] < 0 ||
+        io_limits->iops[BLOCK_IO_LIMIT_READ] < 0) {
+        error_setg(errp, "bps and iops values must be 0 or greater");
+        return false;
+    }
+
     return true;
 }