Skip to contentSkip to conversation

Fix regression with the default naming of throttling groups

PATCH In review Alberto Garcia 4 participants 9 messages Jul 8, 2016 – Jul 26, 2016

lore
Share & tools
lore
#0 lore raw

cover Fix regression with the default naming of throttling groups

Hi,

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

I sent a separate series for the git master, this is the backport for QEMU v2.6.0.

Berto

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

 blockdev.c                 |  9 +++--
 tests/qemu-iotests/093     | 98 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/093.out |  4 +-
 3 files changed, 106 insertions(+), 5 deletions(-)
Signature · 1 line
2.8.1
#1 lore raw

PATCH 1/2 blockdev: Fix regression with the default naming of throttling groups

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.

---
 blockdev.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
blockdev.c +6 -3
index f1f520a..260a6f5 100644
@@ -481,6 +481,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
@@ -510,6 +511,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);
 
@@ -579,7 +582,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
 
         if (throttle_enabled(&cfg)) {
             if (!throttling_group) {
-                throttling_group = blk_name(blk);
+                throttling_group = blk_id;
             }
             blk_rs->throttle_group = g_strdup(throttling_group);
             blk_rs->throttle_state = throttle_group_incref(throttling_group);
@@ -614,7 +617,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;
             }
             bdrv_io_limits_enable(bs, throttling_group);
             bdrv_set_io_limits(bs, &cfg);
@@ -636,7 +639,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;
Signature · 1 line
2.8.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH for-2.6 1/2] blockdev: Fix regression with the default naming of throttling groups

Quoted 7 lines · Alberto Garcia

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.

Quoted 7 lines
---
 blockdev.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
#3 lore raw

PATCH 2/2 qemu-iotests: Test naming of throttling groups

In reply to 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.

---
 tests/qemu-iotests/093     | 98 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/093.out |  4 +-
 2 files changed, 100 insertions(+), 2 deletions(-)
tests/qemu-iotests/093 +98 -0
index ce8e13c..ffcb271 100755
@@ -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"])
tests/qemu-iotests/093.out +2 -2
index 89968f3..914e373 100644
@@ -1,5 +1,5 @@
-....
+.....
 ----------------------------------------------------------------------
-Ran 4 tests
+Ran 5 tests
 
 OK
Signature · 1 line
2.8.1
Reviewed-by on v1 2/2
#4 lore raw

Re: [Qemu-devel] [PATCH for-2.6 2/2] qemu-iotests: Test naming of throttling groups

Quoted 5 lines · 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.

Quoted 7 lines

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

---
 tests/qemu-iotests/093     | 98 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/093.out |  4 +-
 2 files changed, 100 insertions(+), 2 deletions(-)
Reviewed-by on the v1 series
#5 lore raw
In reply to Alberto Garcia
Quoted 10 lines · Alberto Garcia

Hi,

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

I sent a separate series for the git master, this is the backport for QEMU v2.6.0.

Berto

Quoted 12 lines

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

 blockdev.c                 |  9 +++--
 tests/qemu-iotests/093     | 98 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/093.out |  4 +-
 3 files changed, 106 insertions(+), 5 deletions(-)
Signature · 1 line
2.8.1
#6 lore raw
In reply to Alberto Garcia
Quoted 7 lines · Alberto Garcia

Hi,

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

I sent a separate series for the git master, this is the backport for QEMU v2.6.0.

ping

Berto

#7 lore raw
Quoted 10 lines · Alberto Garcia
Quoted 7 lines · Alberto Garcia

Hi,

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

I sent a separate series for the git master, this is the backport for QEMU v2.6.0.

ping

We don't have a tree for 2.6.0, do we? I thought it only got pulled in when the stable release is being prepared.

Max

#8 lore raw
Quoted 10 lines · Max Reitz
Quoted 9 lines · Alberto Garcia
Quoted 7 lines · Alberto Garcia

Hi,

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

I sent a separate series for the git master, this is the backport for QEMU v2.6.0.

Quoted 7 lines
Quoted 1 line

ping

We don't have a tree for 2.6.0, do we? I thought it only got pulled in when the stable release is being prepared.

Max

Yeah, we don't really have a 2.6-stable tree except for the brief period of time that Michael Roth is working actively on the release.

Usually CCing qemu-stable is good enough.

--js