Commit 6730cfd54c for qemu.org
commit 6730cfd54c81c9a3291f48d2e3d0c2225070c724
Author: Denis V. Lunev <den@openvz.org>
Date: Thu Aug 27 18:10:01 2026 +0200
iotests/nbd-commands: cover NBD_CMD_BLOCK_STATUS with a payload
With extended headers a client may name the meta contexts it wants in
a request payload. Our own client never sends one, so the server side
of it, nbd_co_block_status_payload_read(), is not exercised anywhere.
Export two meta contexts and ask libnbd for each of them in turn,
which is only answerable through that path.
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Eric Blake <eblake@redhat.com>
CC: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Message-ID: <20260827161002.310688-5-den@openvz.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
diff --git a/tests/qemu-iotests/tests/nbd-commands b/tests/qemu-iotests/tests/nbd-commands
index 3dfe913190..09e811724b 100755
--- a/tests/qemu-iotests/tests/nbd-commands
+++ b/tests/qemu-iotests/tests/nbd-commands
@@ -90,7 +90,7 @@ class TestNbdCommands(iotests.QMPTestCase):
self.h.shutdown()
self.h = None
- def block_status(self, count=size):
+ def block_status(self, count=size, wanted=None):
"""Map each meta context in the reply to its list of extents."""
reply = {}
@@ -98,7 +98,10 @@ class TestNbdCommands(iotests.QMPTestCase):
reply.setdefault(meta, []).extend(zip(entries[0::2],
entries[1::2]))
- self.h.block_status(count, 0, cb)
+ if wanted is None:
+ self.h.block_status(count, 0, cb)
+ else:
+ self.h.block_status_filter(count, 0, wanted, cb)
return reply
def top_extents(self):
@@ -148,6 +151,13 @@ class TestNbdCommands(iotests.QMPTestCase):
def test_commands_extended_headers(self):
self.check_commands(structured=True, extended=True)
+ def test_block_status_payload_filter(self):
+ self.assertEqual(sorted(self.block_status()),
+ ['base:allocation', 'qemu:allocation-depth'])
+
+ for wanted in (['base:allocation'], ['qemu:allocation-depth']):
+ self.assertEqual(sorted(self.block_status(wanted=wanted)), wanted)
+
def test_cache_past_end_of_export(self):
self.assertRaises(nbd.Error, self.h.cache, size + 1, 0)
diff --git a/tests/qemu-iotests/tests/nbd-commands.out b/tests/qemu-iotests/tests/nbd-commands.out
index 3f8a935a08..2f7d3902f2 100644
--- a/tests/qemu-iotests/tests/nbd-commands.out
+++ b/tests/qemu-iotests/tests/nbd-commands.out
@@ -1,5 +1,5 @@
-......
+.......
----------------------------------------------------------------------
-Ran 6 tests
+Ran 7 tests
OK