From: Stefan Hajnoczi Date: Wed, 13 Feb 2013 15:53:43 +0000 (+0100) Subject: block: refuse negative iops and bps values X-Git-Tag: qemu-xen-4.4.0-rc1~6^2~1010^2~13 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=7d81c1413c9c9bdcc966453636e4ca7776b59861;p=qemu-upstream-4.5-testing.git 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 Signed-off-by: Stefan Hajnoczi --- diff --git a/blockdev.c b/blockdev.c index 9b0351343..ba3759c84 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; }