From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org
Subject: [PULL 3/8] iotests/136: Test stats-intervals with -blockdev/-device
Date: Mon, 8 Jun 2026 18:52:02 +0200 [thread overview]
Message-ID: <20260608165207.307488-4-kwolf@redhat.com> (raw)
In-Reply-To: <20260608165207.307488-1-kwolf@redhat.com>
Commit 9f0c763e introduced the "stats-intervals" qdev property for
block devices, a setting that was previously only accessible with
-drive. Extend the corresponding test to include test cases that set the
property on -device instead, both with -drive and -blockdev.
We wouldn't really improve coverage with testing every combination of
account_invalid and account_failed with all modes to set up statistics,
so it seems good enough to test all combinations with the old way, and
only both True or both False with the additional ways.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20260521101854.31997-1-kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
tests/qemu-iotests/136 | 87 ++++++++++++++++++++++++++++++++------
tests/qemu-iotests/136.out | 4 +-
2 files changed, 77 insertions(+), 14 deletions(-)
diff --git a/tests/qemu-iotests/136 b/tests/qemu-iotests/136
index 8fce88bd677..58df876bafc 100755
--- a/tests/qemu-iotests/136
+++ b/tests/qemu-iotests/136
@@ -22,6 +22,7 @@
import iotests
import os
+import json
interval_length = 10
nsec_per_sec = 1000000000
@@ -45,14 +46,22 @@ class BlockDeviceStatsTestCase(iotests.QMPTestCase):
wr_highest_offset = 0
account_invalid = False
account_failed = False
+ stats_in_device = False
+ use_blockdev = False
def blockstats(self, device):
result = self.vm.qmp("query-blockstats")
for r in result['return']:
- if r['device'] == device:
+ if r['device'] == device or r['node-name'] == device:
return r['stats']
raise Exception("Device not found for blockstats: %s" % device)
+ def qemu_io(self, cmd):
+ if self.use_blockdev:
+ self.vm.hmp_qemu_io("virtio0/virtio-backend", cmd, qdev=True)
+ else:
+ self.vm.hmp_qemu_io("drive0", cmd)
+
def create_blkdebug_file(self):
file = open(blkdebug_file, 'w')
file.write('''
@@ -73,17 +82,54 @@ sector = "%d"
@iotests.skip_if_unsupported(required_drivers)
def setUp(self):
- drive_args = []
- drive_args.append("stats-intervals.0=%d" % interval_length)
- drive_args.append("stats-account-invalid=%s" %
- (self.account_invalid and "on" or "off"))
- drive_args.append("stats-account-failed=%s" %
- (self.account_failed and "on" or "off"))
- drive_args.append("file.image.read-zeroes=on")
self.create_blkdebug_file()
- self.vm = iotests.VM().add_drive('blkdebug:%s:%s://' %
- (blkdebug_file, self.test_driver),
- ','.join(drive_args))
+ self.vm = iotests.VM()
+
+ drive_args = [
+ "file.image.read-zeroes=on",
+ ]
+ if self.stats_in_device:
+ interface = "none"
+ dev_args = {
+ "driver": "virtio-blk",
+ "id": "virtio0",
+ "drive": "drive0",
+ "stats-intervals": [ interval_length ],
+ "account-invalid": "on" if self.account_invalid else "off",
+ "account-failed": "on" if self.account_failed else "off",
+ }
+ self.vm.add_device(json.dumps(dev_args))
+ else:
+ assert not self.use_blockdev
+ interface = "virtio"
+ drive_args += [
+ "stats-intervals.0=%d" % interval_length,
+ "stats-account-invalid=%s" %
+ (self.account_invalid and "on" or "off"),
+ "stats-account-failed=%s" %
+ (self.account_failed and "on" or "off"),
+ ]
+
+ if self.use_blockdev:
+ blockdev_args = {
+ "node-name": "drive0",
+ "driver": "raw",
+ "file": {
+ "driver": "blkdebug",
+ "config": blkdebug_file,
+ "image": {
+ "driver": self.test_driver,
+ "read-zeroes": True,
+ },
+ },
+ }
+ self.vm.add_blockdev(json.dumps(blockdev_args))
+ else:
+ self.vm.add_drive('blkdebug:%s:%s://' %
+ (blkdebug_file, self.test_driver),
+ ','.join(drive_args),
+ interface=interface)
+
self.vm.launch()
# Set an initial value for the clock
self.vm.qtest("clock_step %d" % nsec_per_sec)
@@ -261,7 +307,7 @@ sector = "%d"
# Now perform all operations
for op in ops:
- self.vm.hmp_qemu_io("drive0", op)
+ self.qemu_io(op)
# Update the expected totals
self.total_rd_bytes += rd_ops * rd_size
@@ -328,6 +374,12 @@ sector = "%d"
# All values must be sane before doing any I/O
self.check_values()
+class BlockDeviceStatsTestDevice(BlockDeviceStatsTestCase):
+ stats_in_device = True
+
+class BlockDeviceStatsTestBlockdev(BlockDeviceStatsTestCase):
+ stats_in_device = True
+ use_blockdev = True
class BlockDeviceStatsTestAccountInvalid(BlockDeviceStatsTestCase):
account_invalid = True
@@ -341,6 +393,17 @@ class BlockDeviceStatsTestAccountBoth(BlockDeviceStatsTestCase):
account_invalid = True
account_failed = True
+class BlockDeviceStatsTestAccountBothDevice(BlockDeviceStatsTestCase):
+ account_invalid = True
+ account_failed = True
+ stats_in_device = True
+
+class BlockDeviceStatsTestAccountBothBlockdev(BlockDeviceStatsTestCase):
+ account_invalid = True
+ account_failed = True
+ stats_in_device = True
+ use_blockdev = True
+
class BlockDeviceStatsTestCoroutine(BlockDeviceStatsTestCase):
test_driver = "null-co"
diff --git a/tests/qemu-iotests/136.out b/tests/qemu-iotests/136.out
index cfa5c0d0e66..4823c113d58 100644
--- a/tests/qemu-iotests/136.out
+++ b/tests/qemu-iotests/136.out
@@ -1,5 +1,5 @@
-...................................
+...............................................................
----------------------------------------------------------------------
-Ran 35 tests
+Ran 63 tests
OK
--
2.54.0
next prev parent reply other threads:[~2026-06-08 16:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 16:51 [PULL 0/8] Block layer patches Kevin Wolf
2026-06-08 16:52 ` [PULL 1/8] virtio-blk: add missing VIRTIO_BLK_T_SCSI_CMD size check (CVE-2026-48914) Kevin Wolf
2026-06-08 16:52 ` [PULL 2/8] qemu-img: add sub-command --remove-all to 'qemu-img bitmap' Kevin Wolf
2026-06-08 16:52 ` Kevin Wolf [this message]
2026-06-08 16:52 ` [PULL 4/8] qcow2: Fix data loss on zero write with detect-zeroes=unmap Kevin Wolf
2026-06-08 16:52 ` [PULL 5/8] block/export/fuse: use struct fuse_init_in Kevin Wolf
2026-06-08 16:52 ` [PULL 6/8] block/export/fuse: set FUSE_DIRECT_IO_ALLOW_MMAP flag to fix regression Kevin Wolf
2026-06-08 16:52 ` [PULL 7/8] iotests: test shared mmap for fuse export Kevin Wolf
2026-06-08 16:52 ` [PULL 8/8] qed: Don't try to flush during incoming migration Kevin Wolf
2026-06-09 17:44 ` [PULL 0/8] Block layer patches Stefan Hajnoczi
2026-06-10 10:15 ` Kevin Wolf
2026-06-10 10:18 ` Fiona Ebner
2026-06-10 11:17 ` Daniel P. Berrangé
2026-06-10 11:39 ` Kevin Wolf
2026-06-10 11:48 ` Daniel P. Berrangé
2026-06-10 12:21 ` Kevin Wolf
2026-06-10 12:39 ` Daniel P. Berrangé
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=20260608165207.307488-4-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--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.