All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alberto Garcia <berto@igalia.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Alberto Garcia <berto@igalia.com>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH 9/9] throttle: add name of ThrottleGroup to BlockDeviceInfo
Date: Fri, 13 Feb 2015 18:06:17 +0200	[thread overview]
Message-ID: <14cbc4c207ba6451894101aae39d146144a3c6dc.1423842044.git.berto@igalia.com> (raw)
In-Reply-To: <cover.1423842044.git.berto@igalia.com>
In-Reply-To: <cover.1423842044.git.berto@igalia.com>

Replace also throttle_group_compare() with throttle_group_get_name()

Signed-off-by: Alberto Garcia <berto@igalia.com>
---
 block.c                         |  2 +-
 block/qapi.c                    |  5 +++++
 block/throttle-groups.c         | 14 ++++----------
 hmp.c                           |  6 ++++--
 include/block/throttle-groups.h |  2 +-
 qapi/block-core.json            |  4 +++-
 6 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/block.c b/block.c
index 625f1c8..a53cb76 100644
--- a/block.c
+++ b/block.c
@@ -271,7 +271,7 @@ void bdrv_io_limits_update_group(BlockDriverState *bs, const char *group)
     }
 
     /* this bs is a part of the same group than the one we want */
-    if (throttle_group_compare(bs->throttle_state, group)) {
+    if (!g_strcmp0(throttle_group_get_name(bs->throttle_state), group)) {
         return;
     }
 
diff --git a/block/qapi.c b/block/qapi.c
index 9ed3e68..3d61bab 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -64,9 +64,11 @@ BlockDeviceInfo *bdrv_block_device_info(BlockDriverState *bs)
 
     if (bs->io_limits_enabled) {
         ThrottleConfig cfg;
+        char *group_name;
 
         throttle_group_lock(bs->throttle_state);
         throttle_get_config(bs->throttle_state, &cfg);
+        group_name = g_strdup(throttle_group_get_name(bs->throttle_state));
         throttle_group_unlock(bs->throttle_state);
 
         info->bps     = cfg.buckets[THROTTLE_BPS_TOTAL].avg;
@@ -93,6 +95,9 @@ BlockDeviceInfo *bdrv_block_device_info(BlockDriverState *bs)
 
         info->has_iops_size = cfg.op_size;
         info->iops_size = cfg.op_size;
+
+        info->has_group = true;
+        info->group = group_name;
     }
 
     info->write_threshold = bdrv_write_threshold_get(bs);
diff --git a/block/throttle-groups.c b/block/throttle-groups.c
index 399ae5e..98c0a5e 100644
--- a/block/throttle-groups.c
+++ b/block/throttle-groups.c
@@ -117,21 +117,15 @@ bool throttle_group_unref(ThrottleState *ts)
     return true;
 }
 
-/* Compare a name with a given ThrottleState group name
+/* Get the name from a ThrottleState's ThrottleGroup
  *
  * @ts:   the throttle state whose group we are inspecting
- * @name: the name to compare
- * @ret:  true if names are equal else false
+ * @ret:  the name of the group
  */
-bool throttle_group_compare(ThrottleState *ts, const char *name)
+const char *throttle_group_get_name(ThrottleState *ts)
 {
     ThrottleGroup *tg = container_of(ts, ThrottleGroup, ts);
-
-    if (!name) {
-        return false;
-    }
-
-    return !strcmp(name, tg->name);
+    return tg->name;
 }
 
 /* Register a BlockDriverState in the doubly linked list
diff --git a/hmp.c b/hmp.c
index 47663ce..ae3ef15 100644
--- a/hmp.c
+++ b/hmp.c
@@ -369,7 +369,8 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
                         " iops_max=%" PRId64
                         " iops_rd_max=%" PRId64
                         " iops_wr_max=%" PRId64
-                        " iops_size=%" PRId64 "\n",
+                        " iops_size=%" PRId64
+                        " group=%s\n",
                         inserted->bps,
                         inserted->bps_rd,
                         inserted->bps_wr,
@@ -382,7 +383,8 @@ static void print_block_info(Monitor *mon, BlockInfo *info,
                         inserted->iops_max,
                         inserted->iops_rd_max,
                         inserted->iops_wr_max,
-                        inserted->iops_size);
+                        inserted->iops_size,
+                        inserted->group);
     }
 
     if (verbose) {
diff --git a/include/block/throttle-groups.h b/include/block/throttle-groups.h
index d000067..8f8d285 100644
--- a/include/block/throttle-groups.h
+++ b/include/block/throttle-groups.h
@@ -29,7 +29,7 @@
 ThrottleState *throttle_group_incref(const char *name);
 bool throttle_group_unref(ThrottleState *ts);
 
-bool throttle_group_compare(ThrottleState *ts, const char *name);
+const char *throttle_group_get_name(ThrottleState *ts);
 
 void throttle_group_register_bs(ThrottleState *ts, BlockDriverState *bs);
 BlockDriverState *throttle_group_next_bs(BlockDriverState *bs);
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 563b11f..5653924 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -255,6 +255,8 @@
 #
 # @iops_size: #optional an I/O size in bytes (Since 1.7)
 #
+# @group: #optional throttle group name (Since 2.3)
+#
 # @cache: the cache mode used for the block device (since: 2.3)
 #
 # @write_threshold: configured write threshold for the device.
@@ -274,7 +276,7 @@
             '*bps_max': 'int', '*bps_rd_max': 'int',
             '*bps_wr_max': 'int', '*iops_max': 'int',
             '*iops_rd_max': 'int', '*iops_wr_max': 'int',
-            '*iops_size': 'int', 'cache': 'BlockdevCacheInfo',
+            '*iops_size': 'int', '*group': 'str', 'cache': 'BlockdevCacheInfo',
             'write_threshold': 'int' } }
 
 ##
-- 
2.1.4

  parent reply	other threads:[~2015-02-13 16:07 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-13 16:06 [Qemu-devel] [PATCH v2 0/9] Block Throttle Group Support Alberto Garcia
2015-02-13 16:06 ` [Qemu-devel] [PATCH 1/9] throttle: Extract timers from ThrottleState into a separate ThrottleTimers structure Alberto Garcia
2015-03-03 16:03   ` Stefan Hajnoczi
2015-02-13 16:06 ` [Qemu-devel] [PATCH 2/9] throttle: Add throttle group infrastructure Alberto Garcia
2015-03-03 16:38   ` Stefan Hajnoczi
2015-03-04 10:18     ` Alberto Garcia
2015-03-04 16:02       ` Stefan Hajnoczi
2015-02-13 16:06 ` [Qemu-devel] [PATCH 3/9] throttle: Add throttle group infrastructure tests Alberto Garcia
2015-02-13 16:06 ` [Qemu-devel] [PATCH 4/9] throttle: Prepare to have multiple timers for one ThrottleState Alberto Garcia
2015-03-03 16:50   ` Stefan Hajnoczi
2015-02-13 16:06 ` [Qemu-devel] [PATCH 5/9] throttle: Add a way to know if throttle_schedule_timer had armed a timer Alberto Garcia
2015-02-13 16:06 ` [Qemu-devel] [PATCH 6/9] throttle: Add a way to fire one of the timers asap like a bottom half Alberto Garcia
2015-03-03 17:08   ` Stefan Hajnoczi
2015-02-13 16:06 ` [Qemu-devel] [PATCH 7/9] throttle: Add throttle group support Alberto Garcia
2015-02-24 16:45   ` Eric Blake
2015-02-24 16:47     ` Eric Blake
2015-03-03 21:00   ` Stefan Hajnoczi
2015-03-04 13:53     ` Alberto Garcia
2015-03-04 16:04       ` Stefan Hajnoczi
2015-03-04 16:16         ` Alberto Garcia
2015-03-05 17:41           ` Stefan Hajnoczi
2015-02-13 16:06 ` [Qemu-devel] [PATCH 8/9] throttle: Update throttle infrastructure copyright Alberto Garcia
2015-02-24 16:49   ` Eric Blake
2015-02-24 20:21     ` Benoît Canet
2015-02-13 16:06 ` Alberto Garcia [this message]
2015-02-24 16:54   ` [Qemu-devel] [PATCH 9/9] throttle: add name of ThrottleGroup to BlockDeviceInfo Eric Blake
2015-02-25 10:56     ` Alberto Garcia
2015-02-25 15:23       ` Eric Blake
2015-02-25 15:37         ` Alberto Garcia
2015-02-26 13:56         ` Alberto Garcia
2015-03-03 17:53           ` Eric Blake
2015-03-04  7:09             ` Markus Armbruster
2015-03-04  7:20               ` Alberto Garcia
2015-03-03 21:07 ` [Qemu-devel] [PATCH v2 0/9] Block Throttle Group Support Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14cbc4c207ba6451894101aae39d146144a3c6dc.1423842044.git.berto@igalia.com \
    --to=berto@igalia.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.