Patchwork [2/2] block: refuse negative iops and bps values

login
register
mail settings
Submitter Stefan Hajnoczi
Date Feb. 13, 2013, 3:53 p.m.
Message ID <1360770823-29046-3-git-send-email-stefanha@redhat.com>
Download mbox | patch
Permalink /patch/220182/
State New
Headers show

Comments

Stefan Hajnoczi - Feb. 13, 2013, 3:53 p.m.
Negative I/O throttling iops and bps values do not make sense so reject
them with an error message.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 blockdev.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Patch

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;
 }