aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2013-02-13 16:53:43 +0100
committerKevin Wolf <kwolf@redhat.com>2013-02-22 21:21:09 +0100
commit7d81c1413c9c9bdcc966453636e4ca7776b59861 (patch)
tree25d87d2bbcb2d83ea366fe3e9d0b457f8218bc13
parentc546194f260fb3e391193cb8cc33505618077ecb (diff)
downloadqemu-7d81c1413c9c9bdcc966453636e4ca7776b59861.zip
qemu-7d81c1413c9c9bdcc966453636e4ca7776b59861.tar.gz
qemu-7d81c1413c9c9bdcc966453636e4ca7776b59861.tar.bz2
block: refuse negative iops and bps values
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>
-rw-r--r--blockdev.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/blockdev.c b/blockdev.c
index 9b03513..ba3759c 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -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;
}