All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/2] Block patches
@ 2015-08-14 14:41 Stefan Hajnoczi
  2015-08-14 14:41 ` [Qemu-devel] [PULL 1/2] throttle: refuse bps_max/iops_max without bps/iops Stefan Hajnoczi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2015-08-14 14:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Stefan Hajnoczi

The following changes since commit 2be4f242b50a84bf360df02480b173bfed161107:

  Merge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into staging (2015-08-04 16:51:24 +0100)

are available in the git repository at:

  git://github.com/stefanha/qemu.git tags/block-pull-request

for you to fetch changes up to 92e11a17612108b1729bde4ce61aad0cc1ce5889:

  throttle: add throttle_max_is_missing_limit() test (2015-08-05 12:53:48 +0100)

----------------------------------------------------------------

----------------------------------------------------------------

Stefan Hajnoczi (2):
  throttle: refuse bps_max/iops_max without bps/iops
  throttle: add throttle_max_is_missing_limit() test

 blockdev.c              |  6 ++++++
 include/qemu/throttle.h |  2 ++
 tests/test-throttle.c   | 21 +++++++++++++++++++++
 util/throttle.c         | 15 +++++++++++++++
 4 files changed, 44 insertions(+)

-- 
2.4.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PULL 1/2] throttle: refuse bps_max/iops_max without bps/iops
  2015-08-14 14:41 [Qemu-devel] [PULL 0/2] Block patches Stefan Hajnoczi
@ 2015-08-14 14:41 ` Stefan Hajnoczi
  2015-08-14 14:41 ` [Qemu-devel] [PULL 2/2] throttle: add throttle_max_is_missing_limit() test Stefan Hajnoczi
  2015-08-14 15:52 ` [Qemu-devel] [PULL 0/2] Block patches Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2015-08-14 14:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Stefan Hajnoczi

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              |  6 ++++++
 include/qemu/throttle.h |  2 ++
 util/throttle.c         | 15 +++++++++++++++
 3 files changed, 23 insertions(+)

diff --git a/blockdev.c b/blockdev.c
index 62a4586..4125ff6 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -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;
 }
 
diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h
index 995b2d5..12faaad 100644
--- a/include/qemu/throttle.h
+++ b/include/qemu/throttle.h
@@ -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);
diff --git a/util/throttle.c b/util/throttle.c
index 706c131..1113671 100644
--- a/util/throttle.c
+++ b/util/throttle.c
@@ -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)
 {
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PULL 2/2] throttle: add throttle_max_is_missing_limit() test
  2015-08-14 14:41 [Qemu-devel] [PULL 0/2] Block patches Stefan Hajnoczi
  2015-08-14 14:41 ` [Qemu-devel] [PULL 1/2] throttle: refuse bps_max/iops_max without bps/iops Stefan Hajnoczi
@ 2015-08-14 14:41 ` Stefan Hajnoczi
  2015-08-14 15:52 ` [Qemu-devel] [PULL 0/2] Block patches Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2015-08-14 14:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Stefan Hajnoczi

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Message-id: 1438683733-21111-3-git-send-email-stefanha@redhat.com
---
 tests/test-throttle.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tests/test-throttle.c b/tests/test-throttle.c
index 0168445..85c9b6c 100644
--- a/tests/test-throttle.c
+++ b/tests/test-throttle.c
@@ -329,6 +329,26 @@ static void test_is_valid(void)
     test_is_valid_for_value(1, true);
 }
 
+static void test_max_is_missing_limit(void)
+{
+    int i;
+
+    for (i = 0; i < BUCKETS_COUNT; i++) {
+        memset(&cfg, 0, sizeof(cfg));
+        cfg.buckets[i].max = 100;
+        cfg.buckets[i].avg = 0;
+        g_assert(throttle_max_is_missing_limit(&cfg));
+
+        cfg.buckets[i].max = 0;
+        cfg.buckets[i].avg = 0;
+        g_assert(!throttle_max_is_missing_limit(&cfg));
+
+        cfg.buckets[i].max = 0;
+        cfg.buckets[i].avg = 100;
+        g_assert(!throttle_max_is_missing_limit(&cfg));
+    }
+}
+
 static void test_have_timer(void)
 {
     /* zero structures */
@@ -591,6 +611,7 @@ int main(int argc, char **argv)
     g_test_add_func("/throttle/config/enabled",     test_enabled);
     g_test_add_func("/throttle/config/conflicting", test_conflicting_config);
     g_test_add_func("/throttle/config/is_valid",    test_is_valid);
+    g_test_add_func("/throttle/config/max",         test_max_is_missing_limit);
     g_test_add_func("/throttle/config_functions",   test_config_functions);
     g_test_add_func("/throttle/accounting",         test_accounting);
     g_test_add_func("/throttle/groups",             test_groups);
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PULL 0/2] Block patches
  2015-08-14 14:41 [Qemu-devel] [PULL 0/2] Block patches Stefan Hajnoczi
  2015-08-14 14:41 ` [Qemu-devel] [PULL 1/2] throttle: refuse bps_max/iops_max without bps/iops Stefan Hajnoczi
  2015-08-14 14:41 ` [Qemu-devel] [PULL 2/2] throttle: add throttle_max_is_missing_limit() test Stefan Hajnoczi
@ 2015-08-14 15:52 ` Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2015-08-14 15:52 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: QEMU Developers

On 14 August 2015 at 15:41, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> The following changes since commit 2be4f242b50a84bf360df02480b173bfed161107:
>
>   Merge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into staging (2015-08-04 16:51:24 +0100)
>
> are available in the git repository at:
>
>   git://github.com/stefanha/qemu.git tags/block-pull-request
>
> for you to fetch changes up to 92e11a17612108b1729bde4ce61aad0cc1ce5889:
>
>   throttle: add throttle_max_is_missing_limit() test (2015-08-05 12:53:48 +0100)
>
> ----------------------------------------------------------------
>
> ----------------------------------------------------------------

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-08-14 15:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-14 14:41 [Qemu-devel] [PULL 0/2] Block patches Stefan Hajnoczi
2015-08-14 14:41 ` [Qemu-devel] [PULL 1/2] throttle: refuse bps_max/iops_max without bps/iops Stefan Hajnoczi
2015-08-14 14:41 ` [Qemu-devel] [PULL 2/2] throttle: add throttle_max_is_missing_limit() test Stefan Hajnoczi
2015-08-14 15:52 ` [Qemu-devel] [PULL 0/2] Block patches Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.