From nobody Sat May 30 17:43:35 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1779358777; cv=none; d=zohomail.com; s=zohoarc; b=IVxpHAPtQTRqTZpB7HpgpnObtIF3qCLtjfhoyECQfnqESPLMlm9exafIGN9yNbfIGsK9KPc6KdELiwLM4CQhYx597hi4Icg8y44nvF0zk3/KGSeQIkoBveqLvHETyF0PIlc1QmhFcDXkPGgakvghL2IbCJpY8F5u8vyfYS+dHAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779358777; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KOMTjb0gSORELOxB+mb6xJUzLQDYaNSics2i7QREjdo=; b=fEoMVvsApsRr+l9z1VR+4HjoGS3/P56YQSDhtoFbVvnFLvRjxm9jiUAVJzvJMCaQ2dOfQXnQduNZoeVKqKR0ylzsdLtO+PBVEhzVzaVsPNdqh2myTmobvpp0VQ/+wEFCGa0Fh5HsnGJUwmRPBWaaRFZe8POa+lv0Ok6rckBv/u4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1779358777697492.4561424260056; Thu, 21 May 2026 03:19:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wQ0Um-0004ts-Uv; Thu, 21 May 2026 06:19:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ0Uk-0004t2-Ro for qemu-devel@nongnu.org; Thu, 21 May 2026 06:19:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wQ0Uj-00084Y-1S for qemu-devel@nongnu.org; Thu, 21 May 2026 06:19:14 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-115-_wvhXIXDPjuyGaWpxKEzXg-1; Thu, 21 May 2026 06:19:08 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6395C180035D; Thu, 21 May 2026 10:19:07 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.44.34.67]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7463A30001BE; Thu, 21 May 2026 10:19:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779358751; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=KOMTjb0gSORELOxB+mb6xJUzLQDYaNSics2i7QREjdo=; b=ev70shWhA9AykbriWQPFr6gr3IqezVbUJQHQYZpWNi9QBMtkr7PbZwWQUijkr7AKF2olWo vyUgYhgUXqL2dCSTLn/V9lpafLYqMQ/34V1og8QE55qMD2diWWziud1lOQKLPNqEaemuqv Ksj/uXJn2M4kOJX4NJPGlEteB8jEoYg= X-MC-Unique: _wvhXIXDPjuyGaWpxKEzXg-1 X-Mimecast-MFC-AGG-ID: _wvhXIXDPjuyGaWpxKEzXg_1779358747 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, hreitz@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PATCH] iotests/136: Test stats-intervals with -blockdev/-device Date: Thu, 21 May 2026 12:18:54 +0200 Message-ID: <20260521101854.31997-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1779358781255154100 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Stefan Hajnoczi --- 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 @@ =20 import iotests import os +import json =20 interval_length =3D 10 nsec_per_sec =3D 1000000000 @@ -45,14 +46,22 @@ class BlockDeviceStatsTestCase(iotests.QMPTestCase): wr_highest_offset =3D 0 account_invalid =3D False account_failed =3D False + stats_in_device =3D False + use_blockdev =3D False =20 def blockstats(self, device): result =3D self.vm.qmp("query-blockstats") for r in result['return']: - if r['device'] =3D=3D device: + if r['device'] =3D=3D device or r['node-name'] =3D=3D device: return r['stats'] raise Exception("Device not found for blockstats: %s" % device) =20 + def qemu_io(self, cmd): + if self.use_blockdev: + self.vm.hmp_qemu_io("virtio0/virtio-backend", cmd, qdev=3DTrue) + else: + self.vm.hmp_qemu_io("drive0", cmd) + def create_blkdebug_file(self): file =3D open(blkdebug_file, 'w') file.write(''' @@ -73,17 +82,54 @@ sector =3D "%d" =20 @iotests.skip_if_unsupported(required_drivers) def setUp(self): - drive_args =3D [] - drive_args.append("stats-intervals.0=3D%d" % interval_length) - drive_args.append("stats-account-invalid=3D%s" % - (self.account_invalid and "on" or "off")) - drive_args.append("stats-account-failed=3D%s" % - (self.account_failed and "on" or "off")) - drive_args.append("file.image.read-zeroes=3Don") self.create_blkdebug_file() - self.vm =3D iotests.VM().add_drive('blkdebug:%s:%s://' % - (blkdebug_file, self.test_driver), - ','.join(drive_args)) + self.vm =3D iotests.VM() + + drive_args =3D [ + "file.image.read-zeroes=3Don", + ] + if self.stats_in_device: + interface =3D "none" + dev_args =3D { + "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 =3D "virtio" + drive_args +=3D [ + "stats-intervals.0=3D%d" % interval_length, + "stats-account-invalid=3D%s" % + (self.account_invalid and "on" or "off"), + "stats-account-failed=3D%s" % + (self.account_failed and "on" or "off"), + ] + + if self.use_blockdev: + blockdev_args =3D { + "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=3Dinterface) + self.vm.launch() # Set an initial value for the clock self.vm.qtest("clock_step %d" % nsec_per_sec) @@ -261,7 +307,7 @@ sector =3D "%d" =20 # Now perform all operations for op in ops: - self.vm.hmp_qemu_io("drive0", op) + self.qemu_io(op) =20 # Update the expected totals self.total_rd_bytes +=3D rd_ops * rd_size @@ -328,6 +374,12 @@ sector =3D "%d" # All values must be sane before doing any I/O self.check_values() =20 +class BlockDeviceStatsTestDevice(BlockDeviceStatsTestCase): + stats_in_device =3D True + +class BlockDeviceStatsTestBlockdev(BlockDeviceStatsTestCase): + stats_in_device =3D True + use_blockdev =3D True =20 class BlockDeviceStatsTestAccountInvalid(BlockDeviceStatsTestCase): account_invalid =3D True @@ -341,6 +393,17 @@ class BlockDeviceStatsTestAccountBoth(BlockDeviceStats= TestCase): account_invalid =3D True account_failed =3D True =20 +class BlockDeviceStatsTestAccountBothDevice(BlockDeviceStatsTestCase): + account_invalid =3D True + account_failed =3D True + stats_in_device =3D True + +class BlockDeviceStatsTestAccountBothBlockdev(BlockDeviceStatsTestCase): + account_invalid =3D True + account_failed =3D True + stats_in_device =3D True + use_blockdev =3D True + class BlockDeviceStatsTestCoroutine(BlockDeviceStatsTestCase): test_driver =3D "null-co" =20 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 =20 OK --=20 2.54.0