qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] Fix regression with the default naming of throttling groups
@ 2016-07-08 14:02 Alberto Garcia
  2016-07-08 14:03 ` [Qemu-devel] [PATCH 1/2] blockdev: " Alberto Garcia
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Alberto Garcia @ 2016-07-08 14:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-block, Stefan Hajnoczi, Max Reitz, Alberto Garcia

Hi,

Stefan reported this, this is a regression caused by commit
efaa7c4eeb7490c6f37f3.

QEMU v2.6.0 is affected but the patch cannot be backported as-is, I'll
send a separate version to qemu-stable.

Berto

Alberto Garcia (2):
  blockdev: Fix regression with the default naming of throttling groups
  qemu-iotests: Test naming of throttling groups

 blockdev.c                 |  7 +++-
 tests/qemu-iotests/093     | 98 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/093.out |  4 +-
 3 files changed, 105 insertions(+), 4 deletions(-)

-- 
2.8.1

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

* [Qemu-devel] [PATCH 1/2] blockdev: Fix regression with the default naming of throttling groups
  2016-07-08 14:02 [Qemu-devel] [PATCH 0/2] Fix regression with the default naming of throttling groups Alberto Garcia
@ 2016-07-08 14:03 ` Alberto Garcia
  2016-07-08 14:23   ` Max Reitz
  2016-07-08 14:03 ` [Qemu-devel] [PATCH 2/2] qemu-iotests: Test " Alberto Garcia
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Alberto Garcia @ 2016-07-08 14:03 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-block, Stefan Hajnoczi, Max Reitz, Alberto Garcia,
	qemu-stable

When I/O limits are set for a block device, the name of the throttling
group is taken from the BlockBackend if the user doesn't specify one.

Commit efaa7c4eeb7490c6f37f3 moved the naming of the BlockBackend in
blockdev_init() to the end of the function, after I/O limits are set.
The consequence is that the throttling group gets an empty name.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reported-by: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Max Reitz <mreitz@redhat.com>
Cc: qemu-stable@nongnu.org
---
 blockdev.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index 0f8065c..3ad7d29 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -483,6 +483,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
     const char *id;
     BlockdevDetectZeroesOptions detect_zeroes =
         BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF;
+    const char *blk_id;
     const char *throttling_group = NULL;
 
     /* Check common options by copying from bs_opts to opts, all other options
@@ -512,6 +513,8 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
 
     writethrough = !qemu_opt_get_bool(opts, BDRV_OPT_CACHE_WB, true);
 
+    blk_id = qemu_opts_id(opts);
+
     qdict_extract_subqdict(bs_opts, &interval_dict, "stats-intervals.");
     qdict_array_split(interval_dict, &interval_list);
 
@@ -616,7 +619,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
     /* disk I/O throttling */
     if (throttle_enabled(&cfg)) {
         if (!throttling_group) {
-            throttling_group = blk_name(blk);
+            throttling_group = blk_id;
         }
         blk_io_limits_enable(blk, throttling_group);
         blk_set_io_limits(blk, &cfg);
@@ -625,7 +628,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
     blk_set_enable_write_cache(blk, !writethrough);
     blk_set_on_error(blk, on_read_error, on_write_error);
 
-    if (!monitor_add_blk(blk, qemu_opts_id(opts), errp)) {
+    if (!monitor_add_blk(blk, blk_id, errp)) {
         blk_unref(blk);
         blk = NULL;
         goto err_no_bs_opts;
-- 
2.8.1

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

* [Qemu-devel] [PATCH 2/2] qemu-iotests: Test naming of throttling groups
  2016-07-08 14:02 [Qemu-devel] [PATCH 0/2] Fix regression with the default naming of throttling groups Alberto Garcia
  2016-07-08 14:03 ` [Qemu-devel] [PATCH 1/2] blockdev: " Alberto Garcia
@ 2016-07-08 14:03 ` Alberto Garcia
  2016-07-08 14:31   ` Max Reitz
  2016-07-08 14:36 ` [Qemu-devel] [PATCH 0/2] Fix regression with the default " Max Reitz
  2016-07-08 16:29 ` Stefan Hajnoczi
  3 siblings, 1 reply; 8+ messages in thread
From: Alberto Garcia @ 2016-07-08 14:03 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-block, Stefan Hajnoczi, Max Reitz, Alberto Garcia

Throttling groups are named using the 'group' parameter of the
block_set_io_throttle command and the throttling.group command-line
option. If that parameter is unspecified the groups get the name of
the block device.

This patch adds a new test to check the naming of throttling groups.

Signed-off-by: Alberto Garcia <berto@igalia.com>
---
 tests/qemu-iotests/093     | 98 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/093.out |  4 +-
 2 files changed, 100 insertions(+), 2 deletions(-)

diff --git a/tests/qemu-iotests/093 b/tests/qemu-iotests/093
index ce8e13c..ffcb271 100755
--- a/tests/qemu-iotests/093
+++ b/tests/qemu-iotests/093
@@ -184,5 +184,103 @@ class ThrottleTestCase(iotests.QMPTestCase):
 class ThrottleTestCoroutine(ThrottleTestCase):
     test_img = "null-co://"
 
+class ThrottleTestGroupNames(iotests.QMPTestCase):
+    test_img = "null-aio://"
+    max_drives = 3
+
+    def setUp(self):
+        self.vm = iotests.VM()
+        for i in range(0, self.max_drives):
+            self.vm.add_drive(self.test_img, "throttling.iops-total=100")
+        self.vm.launch()
+
+    def tearDown(self):
+        self.vm.shutdown()
+
+    def set_io_throttle(self, device, params):
+        params["device"] = device
+        result = self.vm.qmp("block_set_io_throttle", conv_keys=False, **params)
+        self.assert_qmp(result, 'return', {})
+
+    def verify_name(self, device, name):
+        result = self.vm.qmp("query-block")
+        for r in result["return"]:
+            if r["device"] == device:
+                info = r["inserted"]
+                if name:
+                    self.assertEqual(info["group"], name)
+                else:
+                    self.assertFalse(info.has_key('group'))
+                return
+
+        raise Exception("No group information found for '%s'" % device)
+
+    def test_group_naming(self):
+        params = {"bps": 0,
+                  "bps_rd": 0,
+                  "bps_wr": 0,
+                  "iops": 0,
+                  "iops_rd": 0,
+                  "iops_wr": 0}
+
+        # Check the drives added using the command line.
+        # The default throttling group name is the device name.
+        for i in range(self.max_drives):
+            devname = "drive%d" % i
+            self.verify_name(devname, devname)
+
+        # Clear throttling settings => the group name is gone.
+        for i in range(self.max_drives):
+            devname = "drive%d" % i
+            self.set_io_throttle(devname, params)
+            self.verify_name(devname, None)
+
+        # Set throttling settings using block_set_io_throttle and
+        # check the default group names.
+        params["iops"] = 10
+        for i in range(self.max_drives):
+            devname = "drive%d" % i
+            self.set_io_throttle(devname, params)
+            self.verify_name(devname, devname)
+
+        # Set a custom group name for each device
+        for i in range(3):
+            devname = "drive%d" % i
+            groupname = "group%d" % i
+            params['group'] = groupname
+            self.set_io_throttle(devname, params)
+            self.verify_name(devname, groupname)
+
+        # Put drive0 in group1 and check that all other devices remain
+        # unchanged
+        params['group'] = 'group1'
+        self.set_io_throttle('drive0', params)
+        self.verify_name('drive0', 'group1')
+        for i in range(1, self.max_drives):
+            devname = "drive%d" % i
+            groupname = "group%d" % i
+            self.verify_name(devname, groupname)
+
+        # Put drive0 in group2 and check that all other devices remain
+        # unchanged
+        params['group'] = 'group2'
+        self.set_io_throttle('drive0', params)
+        self.verify_name('drive0', 'group2')
+        for i in range(1, self.max_drives):
+            devname = "drive%d" % i
+            groupname = "group%d" % i
+            self.verify_name(devname, groupname)
+
+        # Clear throttling settings from drive0 check that all other
+        # devices remain unchanged
+        params["iops"] = 0
+        self.set_io_throttle('drive0', params)
+        self.verify_name('drive0', None)
+        for i in range(1, self.max_drives):
+            devname = "drive%d" % i
+            groupname = "group%d" % i
+            self.verify_name(devname, groupname)
+
+
 if __name__ == '__main__':
     iotests.main(supported_fmts=["raw"])
diff --git a/tests/qemu-iotests/093.out b/tests/qemu-iotests/093.out
index 89968f3..914e373 100644
--- a/tests/qemu-iotests/093.out
+++ b/tests/qemu-iotests/093.out
@@ -1,5 +1,5 @@
-....
+.....
 ----------------------------------------------------------------------
-Ran 4 tests
+Ran 5 tests
 
 OK
-- 
2.8.1

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

* Re: [Qemu-devel] [PATCH 1/2] blockdev: Fix regression with the default naming of throttling groups
  2016-07-08 14:03 ` [Qemu-devel] [PATCH 1/2] blockdev: " Alberto Garcia
@ 2016-07-08 14:23   ` Max Reitz
  2016-07-08 14:25     ` Alberto Garcia
  0 siblings, 1 reply; 8+ messages in thread
From: Max Reitz @ 2016-07-08 14:23 UTC (permalink / raw)
  To: Alberto Garcia, qemu-devel; +Cc: qemu-block, Stefan Hajnoczi, qemu-stable

[-- Attachment #1: Type: text/plain, Size: 2832 bytes --]

On 08.07.2016 16:03, Alberto Garcia wrote:
> When I/O limits are set for a block device, the name of the throttling
> group is taken from the BlockBackend if the user doesn't specify one.
> 
> Commit efaa7c4eeb7490c6f37f3 moved the naming of the BlockBackend in
> blockdev_init() to the end of the function, after I/O limits are set.
> The consequence is that the throttling group gets an empty name.
> 
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> Reported-by: Stefan Hajnoczi <stefanha@redhat.com>
> Cc: Max Reitz <mreitz@redhat.com>
> Cc: qemu-stable@nongnu.org
> ---
>  blockdev.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 0f8065c..3ad7d29 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -483,6 +483,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
>      const char *id;
>      BlockdevDetectZeroesOptions detect_zeroes =
>          BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF;
> +    const char *blk_id;
>      const char *throttling_group = NULL;
>  
>      /* Check common options by copying from bs_opts to opts, all other options
> @@ -512,6 +513,8 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
>  
>      writethrough = !qemu_opt_get_bool(opts, BDRV_OPT_CACHE_WB, true);
>  
> +    blk_id = qemu_opts_id(opts);
> +

Side note: The "id" variable is supposed to contain the exact same
value, but the string it points to is invalidated by the
qdict_del(bs_opts, "id") call.

So indeed we need to obtain the ID anew here (or we'd have to do
g_strdup() before and g_free() after, which is cumbersome). But
regarding the variable itself, you could have actually reused "id" (I
only noticed that just now).

But that's just a minor thing, so:

Reviewed-by: Max Reitz <mreitz@redhat.com>

>      qdict_extract_subqdict(bs_opts, &interval_dict, "stats-intervals.");
>      qdict_array_split(interval_dict, &interval_list);
>  
> @@ -616,7 +619,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
>      /* disk I/O throttling */
>      if (throttle_enabled(&cfg)) {
>          if (!throttling_group) {
> -            throttling_group = blk_name(blk);
> +            throttling_group = blk_id;
>          }
>          blk_io_limits_enable(blk, throttling_group);
>          blk_set_io_limits(blk, &cfg);
> @@ -625,7 +628,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
>      blk_set_enable_write_cache(blk, !writethrough);
>      blk_set_on_error(blk, on_read_error, on_write_error);
>  
> -    if (!monitor_add_blk(blk, qemu_opts_id(opts), errp)) {
> +    if (!monitor_add_blk(blk, blk_id, errp)) {
>          blk_unref(blk);
>          blk = NULL;
>          goto err_no_bs_opts;
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 498 bytes --]

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

* Re: [Qemu-devel] [PATCH 1/2] blockdev: Fix regression with the default naming of throttling groups
  2016-07-08 14:23   ` Max Reitz
@ 2016-07-08 14:25     ` Alberto Garcia
  0 siblings, 0 replies; 8+ messages in thread
From: Alberto Garcia @ 2016-07-08 14:25 UTC (permalink / raw)
  To: Max Reitz, qemu-devel; +Cc: qemu-block, Stefan Hajnoczi, qemu-stable

On Fri 08 Jul 2016 04:23:03 PM CEST, Max Reitz wrote:
>> +    blk_id = qemu_opts_id(opts);
>> +
>
> Side note: The "id" variable is supposed to contain the exact same
> value, but the string it points to is invalidated by the
> qdict_del(bs_opts, "id") call.
>
> So indeed we need to obtain the ID anew here (or we'd have to do
> g_strdup() before and g_free() after, which is cumbersome). But
> regarding the variable itself, you could have actually reused "id" (I
> only noticed that just now).
>
> But that's just a minor thing, so:
>
> Reviewed-by: Max Reitz <mreitz@redhat.com>

Ok, if this series doesn't get a new version feel free to modify the
patch when you apply it.

Berto

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

* Re: [Qemu-devel] [PATCH 2/2] qemu-iotests: Test naming of throttling groups
  2016-07-08 14:03 ` [Qemu-devel] [PATCH 2/2] qemu-iotests: Test " Alberto Garcia
@ 2016-07-08 14:31   ` Max Reitz
  0 siblings, 0 replies; 8+ messages in thread
From: Max Reitz @ 2016-07-08 14:31 UTC (permalink / raw)
  To: Alberto Garcia, qemu-devel; +Cc: qemu-block, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 637 bytes --]

On 08.07.2016 16:03, Alberto Garcia wrote:
> Throttling groups are named using the 'group' parameter of the
> block_set_io_throttle command and the throttling.group command-line
> option. If that parameter is unspecified the groups get the name of
> the block device.
> 
> This patch adds a new test to check the naming of throttling groups.
> 
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> ---
>  tests/qemu-iotests/093     | 98 ++++++++++++++++++++++++++++++++++++++++++++++
>  tests/qemu-iotests/093.out |  4 +-
>  2 files changed, 100 insertions(+), 2 deletions(-)

Reviewed-by: Max Reitz <mreitz@redhat.com>


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 498 bytes --]

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

* Re: [Qemu-devel] [PATCH 0/2] Fix regression with the default naming of throttling groups
  2016-07-08 14:02 [Qemu-devel] [PATCH 0/2] Fix regression with the default naming of throttling groups Alberto Garcia
  2016-07-08 14:03 ` [Qemu-devel] [PATCH 1/2] blockdev: " Alberto Garcia
  2016-07-08 14:03 ` [Qemu-devel] [PATCH 2/2] qemu-iotests: Test " Alberto Garcia
@ 2016-07-08 14:36 ` Max Reitz
  2016-07-08 16:29 ` Stefan Hajnoczi
  3 siblings, 0 replies; 8+ messages in thread
From: Max Reitz @ 2016-07-08 14:36 UTC (permalink / raw)
  To: Alberto Garcia, qemu-devel; +Cc: qemu-block, Stefan Hajnoczi

[-- Attachment #1: Type: text/plain, Size: 889 bytes --]

On 08.07.2016 16:02, Alberto Garcia wrote:
> Hi,
> 
> Stefan reported this, this is a regression caused by commit
> efaa7c4eeb7490c6f37f3.
> 
> QEMU v2.6.0 is affected but the patch cannot be backported as-is, I'll
> send a separate version to qemu-stable.
> 
> Berto
> 
> Alberto Garcia (2):
>   blockdev: Fix regression with the default naming of throttling groups
>   qemu-iotests: Test naming of throttling groups
> 
>  blockdev.c                 |  7 +++-
>  tests/qemu-iotests/093     | 98 ++++++++++++++++++++++++++++++++++++++++++++++
>  tests/qemu-iotests/093.out |  4 +-
>  3 files changed, 105 insertions(+), 4 deletions(-)

Thanks Berto, I've changed patch 1 to use "id" instead of "blk_id" (and
you even asked me which variable to use beforehand O:-)) and applied the
series to my block branch:

https://github.com/XanClic/qemu/commits/block

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 498 bytes --]

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

* Re: [Qemu-devel] [PATCH 0/2] Fix regression with the default naming of throttling groups
  2016-07-08 14:02 [Qemu-devel] [PATCH 0/2] Fix regression with the default naming of throttling groups Alberto Garcia
                   ` (2 preceding siblings ...)
  2016-07-08 14:36 ` [Qemu-devel] [PATCH 0/2] Fix regression with the default " Max Reitz
@ 2016-07-08 16:29 ` Stefan Hajnoczi
  3 siblings, 0 replies; 8+ messages in thread
From: Stefan Hajnoczi @ 2016-07-08 16:29 UTC (permalink / raw)
  To: Alberto Garcia; +Cc: qemu-devel, qemu-block, Max Reitz

[-- Attachment #1: Type: text/plain, Size: 753 bytes --]

On Fri, Jul 08, 2016 at 05:02:59PM +0300, Alberto Garcia wrote:
> Hi,
> 
> Stefan reported this, this is a regression caused by commit
> efaa7c4eeb7490c6f37f3.
> 
> QEMU v2.6.0 is affected but the patch cannot be backported as-is, I'll
> send a separate version to qemu-stable.
> 
> Berto
> 
> Alberto Garcia (2):
>   blockdev: Fix regression with the default naming of throttling groups
>   qemu-iotests: Test naming of throttling groups
> 
>  blockdev.c                 |  7 +++-
>  tests/qemu-iotests/093     | 98 ++++++++++++++++++++++++++++++++++++++++++++++
>  tests/qemu-iotests/093.out |  4 +-
>  3 files changed, 105 insertions(+), 4 deletions(-)
> 
> -- 
> 2.8.1
> 

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

end of thread, other threads:[~2016-07-08 16:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-08 14:02 [Qemu-devel] [PATCH 0/2] Fix regression with the default naming of throttling groups Alberto Garcia
2016-07-08 14:03 ` [Qemu-devel] [PATCH 1/2] blockdev: " Alberto Garcia
2016-07-08 14:23   ` Max Reitz
2016-07-08 14:25     ` Alberto Garcia
2016-07-08 14:03 ` [Qemu-devel] [PATCH 2/2] qemu-iotests: Test " Alberto Garcia
2016-07-08 14:31   ` Max Reitz
2016-07-08 14:36 ` [Qemu-devel] [PATCH 0/2] Fix regression with the default " Max Reitz
2016-07-08 16:29 ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).