]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
throttle: refuse bps_max/iops_max without bps/iops
authorStefan Hajnoczi <stefanha@redhat.com>
Tue, 4 Aug 2015 10:22:12 +0000 (11:22 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Wed, 5 Aug 2015 11:53:48 +0000 (12:53 +0100)
The bps_max/iops_max values are meaningless without corresponding
bps/iops values.  Reported an error if bps_max/iops_max is given without
bps/iops.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Message-id: 1438683733-21111-2-git-send-email-stefanha@redhat.com

blockdev.c
include/qemu/throttle.h
util/throttle.c

index 62a4586cd65dccce85a384f4c94cba6af79233b4..4125ff642ad08f588f9b9e0d3c0c537ffd2db8cf 100644 (file)
@@ -337,6 +337,12 @@ static bool check_throttle_config(ThrottleConfig *cfg, Error **errp)
         return false;
     }
 
+    if (throttle_max_is_missing_limit(cfg)) {
+        error_setg(errp, "bps_max/iops_max require corresponding"
+                         " bps/iops values");
+        return false;
+    }
+
     return true;
 }
 
index 995b2d595751cc6cfa055b8652b6b396504437a3..12faaad959054bf1ab714cf5c1023cd7bd62197c 100644 (file)
@@ -114,6 +114,8 @@ bool throttle_conflicting(ThrottleConfig *cfg);
 
 bool throttle_is_valid(ThrottleConfig *cfg);
 
+bool throttle_max_is_missing_limit(ThrottleConfig *cfg);
+
 void throttle_config(ThrottleState *ts,
                      ThrottleTimers *tt,
                      ThrottleConfig *cfg);
index 706c13111e40c13dcc5b3ebab4c748801cd1a875..1113671ecf69ab52a66efbb4b09be433a6229ae3 100644 (file)
@@ -300,6 +300,21 @@ bool throttle_is_valid(ThrottleConfig *cfg)
     return !invalid;
 }
 
+/* check if bps_max/iops_max is used without bps/iops
+ * @cfg: the throttling configuration to inspect
+ */
+bool throttle_max_is_missing_limit(ThrottleConfig *cfg)
+{
+    int i;
+
+    for (i = 0; i < BUCKETS_COUNT; i++) {
+        if (cfg->buckets[i].max && !cfg->buckets[i].avg) {
+            return true;
+        }
+    }
+    return false;
+}
+
 /* fix bucket parameters */
 static void throttle_fix_bucket(LeakyBucket *bkt)
 {