From nobody Tue Apr 7 23:43:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773241112678809.410100925369; Wed, 11 Mar 2026 07:58:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w0L0F-0001Pf-3r; Wed, 11 Mar 2026 10:57:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w0L0D-0001NL-1A; Wed, 11 Mar 2026 10:57:37 -0400 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w0L0A-0002oQ-Pz; Wed, 11 Mar 2026 10:57:36 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 2837A874F9; Wed, 11 Mar 2026 15:57:26 +0100 (CET) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru, jsnow@redhat.com, qemu-stable@nongnu.org Subject: [PATCH 2/3] iotests/041: add test for mirror with throttled NBD export as target Date: Wed, 11 Mar 2026 15:54:26 +0100 Message-ID: <20260311145717.668492-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260311145717.668492-1-f.ebner@proxmox.com> References: <20260311145717.668492-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1773241010367 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=lists.gnu.org; Received-SPF: pass client-ip=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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-ZM-MESSAGEID: 1773241116358154100 Content-Type: text/plain; charset="utf-8" Mostly in preparation for commit "iotests/041: add test for duplicate job-complete with throttled target". Signed-off-by: Fiona Ebner --- tests/qemu-iotests/041 | 112 ++++++++++++++++++++++++++++++++++++- tests/qemu-iotests/041.out | 4 +- 2 files changed, 113 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index 8452845f44..a7e1980f13 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -24,7 +24,7 @@ import os import re import json import iotests -from iotests import qemu_img, qemu_img_map, qemu_io +from iotests import qemu_img, qemu_img_map, qemu_io, QemuStorageDaemon =20 backing_img =3D os.path.join(iotests.test_dir, 'backing.img') target_backing_img =3D os.path.join(iotests.test_dir, 'target-backing.img') @@ -1373,6 +1373,116 @@ class TestFilters(iotests.QMPTestCase): =20 self.complete_and_wait('mirror') =20 +# Tests for mirror where the target is a throttled NBD export. +class TestThrottledNBDTarget(iotests.QMPTestCase): + image_len =3D 3 * 1024 * 1024 + bps_total =3D 1 * 1024 * 1024 + + def setUp(self): + iotests.create_image(backing_img, self.image_len) + iotests.create_image(target_backing_img, self.image_len) + qemu_img('create', '-f', iotests.imgfmt, + '-o', f'backing_file=3D{backing_img}', '-F', 'raw', test_= img) + qemu_img('create', '-f', iotests.imgfmt, + '-o', f'backing_file=3D{target_backing_img}', '-F', 'raw', + target_img) + qemu_io('-c', 'write -P 23 0 3M', test_img) + + self.qsd =3D QemuStorageDaemon('--nbd-server', + f'addr.type=3Dunix,addr.path=3D{nbd_s= ock_path}', + qmp=3DTrue) + + self.qsd.cmd('object-add', { + 'qom-type': 'throttle-group', + 'id': 'thrgr-target', + 'limits': { + 'bps-total': self.bps_total, + } + }) + + self.qsd.cmd('blockdev-add', { + 'node-name': 'target', + 'driver': 'throttle', + 'throttle-group': 'thrgr-target', + 'file': { + 'driver': iotests.imgfmt, + 'file': { + 'driver': 'file', + 'filename': target_img + } + } + }) + + self.qsd.cmd('block-export-add', { + 'id': 'exp0', + 'type': 'nbd', + 'node-name': 'target', + 'writable': True + }) + + self.vm =3D iotests.VM().add_device('virtio-scsi,id=3Dvio-scsi') + self.vm.launch() + + self.vm.cmd('blockdev-add',{ + 'node-name': 'source', + 'driver': iotests.imgfmt, + 'file': { + 'driver': 'file', + 'filename': test_img + }, + 'backing': { + 'node-name': 'backing', + 'driver': 'raw', + 'file': { + 'driver': 'file', + 'filename': backing_img + } + } + }) + + self.vm.cmd('device_add', + driver=3D'scsi-hd', + id=3D'virtio', + bus=3D'vio-scsi.0', + drive=3D'source') + + self.vm.cmd('blockdev-add', { + 'node-name': 'target', + 'driver': 'nbd', + 'export': 'target', + 'server': { + 'type': 'unix', + 'path': nbd_sock_path + } + }) + + def tearDown(self): + os.remove(test_img) + os.remove(target_img) + os.remove(backing_img) + os.remove(target_backing_img) + + def test_throttled(self): + self.vm.cmd('blockdev-mirror', + job_id=3D'mirror', + device=3D'source', + target=3D'target', + sync=3D'full') + + time.sleep(1) + result =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(result, 'return[0]/ready', False) + self.vm.qtest(f'clock_step {4 * 1000 * 1000 * 1000}') + time.sleep(1) # in real time, the rest should now comlpete fast + result =3D self.vm.qmp('query-block-jobs') + self.assert_qmp(result, 'return[0]/ready', True) + + self.complete_and_wait('mirror') + self.vm.shutdown() + self.qsd.stop() + self.assertTrue(iotests.compare_images(test_img, target_img), + 'target image does not match source after mirrorin= g') + =20 if __name__ =3D=3D '__main__': iotests.main(supported_fmts=3D['qcow2', 'qed'], diff --git a/tests/qemu-iotests/041.out b/tests/qemu-iotests/041.out index 46651953e8..5273ce86c3 100644 --- a/tests/qemu-iotests/041.out +++ b/tests/qemu-iotests/041.out @@ -1,5 +1,5 @@ -..........................................................................= ................................. +..........................................................................= .................................. ---------------------------------------------------------------------- -Ran 107 tests +Ran 108 tests =20 OK --=20 2.47.3