From nobody Mon Sep 22 02:17:13 2025 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 1758110202037200.7855626581386; Wed, 17 Sep 2025 04:56:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uyqlS-0000U7-Go; Wed, 17 Sep 2025 07:55:59 -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 1uyql4-0007pe-J3; Wed, 17 Sep 2025 07:55:38 -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 1uyqkw-0004bq-A9; Wed, 17 Sep 2025 07:55:34 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 4BCF44DC0F; Wed, 17 Sep 2025 13:55:20 +0200 (CEST) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, fam@euphon.net, stefanha@redhat.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v2 1/5] include/block/block_int-common: document when resize callback is used Date: Wed, 17 Sep 2025 13:54:48 +0200 Message-ID: <20250917115509.401015-2-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250917115509.401015-1-f.ebner@proxmox.com> References: <20250917115509.401015-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: 1758110111461 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: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1758110203451116600 Content-Type: text/plain; charset="utf-8" The 'resize' callback is only called by bdrv_parent_cb_resize() which is only called by bdrv_co_write_req_finish() to notify the parent(s) that the child was resized. Signed-off-by: Fiona Ebner Reviewed-by: Hanna Czenczek --- include/block/block_int-common.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 034c0634c8..8a3d427356 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -1020,6 +1020,9 @@ struct BdrvChildClass { * the I/O API. */ =20 + /* + * Notifies the parent that the child was resized. + */ void (*resize)(BdrvChild *child); =20 /* --=20 2.47.2 From nobody Mon Sep 22 02:17:13 2025 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 1758110223416769.8373029243687; Wed, 17 Sep 2025 04:57:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uyqlK-0008TB-VE; Wed, 17 Sep 2025 07:55:51 -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 1uyqky-0007hk-9V; Wed, 17 Sep 2025 07:55:28 -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 1uyqkv-0004bt-HA; Wed, 17 Sep 2025 07:55:28 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 51BCB4DC10; Wed, 17 Sep 2025 13:55:20 +0200 (CEST) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, fam@euphon.net, stefanha@redhat.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v2 2/5] block: make bdrv_co_parent_cb_resize() a proper IO API function Date: Wed, 17 Sep 2025 13:54:49 +0200 Message-ID: <20250917115509.401015-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250917115509.401015-1-f.ebner@proxmox.com> References: <20250917115509.401015-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: 1758110111485 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: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1758110225792116600 Content-Type: text/plain; charset="utf-8" In preparation for calling it via the bdrv_child_cb_resize() callback that will be added by the next commit. Rename it to include the "_co_" part while at it. Signed-off-by: Fiona Ebner Reviewed-by: Hanna Czenczek --- block/io.c | 9 +++------ include/block/block_int-io.h | 6 ++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/block/io.c b/block/io.c index 9bd8ba8431..928c02d1ad 100644 --- a/block/io.c +++ b/block/io.c @@ -46,9 +46,6 @@ /* Maximum read size for checking if data reads as zero, in bytes */ #define MAX_ZERO_CHECK_BUFFER (128 * KiB) =20 -static void coroutine_fn GRAPH_RDLOCK -bdrv_parent_cb_resize(BlockDriverState *bs); - static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes, BdrvRequestFlags flags); =20 @@ -2038,7 +2035,7 @@ bdrv_co_write_req_finish(BdrvChild *child, int64_t of= fset, int64_t bytes, end_sector > bs->total_sectors) && req->type !=3D BDRV_TRACKED_DISCARD) { bs->total_sectors =3D end_sector; - bdrv_parent_cb_resize(bs); + bdrv_co_parent_cb_resize(bs); bdrv_dirty_bitmap_truncate(bs, end_sector << BDRV_SECTOR_BITS); } if (req->bytes) { @@ -3570,11 +3567,11 @@ int coroutine_fn bdrv_co_copy_range(BdrvChild *src,= int64_t src_offset, bytes, read_flags, write_flags); } =20 -static void coroutine_fn GRAPH_RDLOCK -bdrv_parent_cb_resize(BlockDriverState *bs) +void coroutine_fn bdrv_co_parent_cb_resize(BlockDriverState *bs) { BdrvChild *c; =20 + IO_CODE(); assert_bdrv_graph_readable(); =20 QLIST_FOREACH(c, &bs->parents, next_parent) { diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h index 4f94eb3c5a..ed8b5657d6 100644 --- a/include/block/block_int-io.h +++ b/include/block/block_int-io.h @@ -191,4 +191,10 @@ void bdrv_bsc_invalidate_range(BlockDriverState *bs, */ void bdrv_bsc_fill(BlockDriverState *bs, int64_t offset, int64_t bytes); =20 +/* + * Notify all parents that the size of the child changed. + */ +void coroutine_fn GRAPH_RDLOCK +bdrv_co_parent_cb_resize(BlockDriverState *bs); + #endif /* BLOCK_INT_IO_H */ --=20 2.47.2 From nobody Mon Sep 22 02:17:13 2025 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 1758110207624498.56811592518113; Wed, 17 Sep 2025 04:56:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uyqlw-0001SH-LS; Wed, 17 Sep 2025 07:56:29 -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 1uyqky-0007hm-D3; Wed, 17 Sep 2025 07:55:28 -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 1uyqkv-0004bv-GD; Wed, 17 Sep 2025 07:55:28 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 7FB204DC09; Wed, 17 Sep 2025 13:55:20 +0200 (CEST) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, fam@euphon.net, stefanha@redhat.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v2 3/5] block: implement 'resize' callback for child_of_bds class Date: Wed, 17 Sep 2025 13:54:50 +0200 Message-ID: <20250917115509.401015-4-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250917115509.401015-1-f.ebner@proxmox.com> References: <20250917115509.401015-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: 1758110111502 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: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1758110209716116601 Content-Type: text/plain; charset="utf-8" If a filtered child is resized, the size of the parent node is now also refreshed (recursively for chains of filtered children). For filter block drivers that do not implement .bdrv_co_getlength(), this commit does not change the current behavior, because bdrv_co_refresh_total_sectors() will used the current size via the passed-in hint. This is the case for block drivers for (some) block jobs, as well as copy-before-write. Block jobs already set up a blocker preventing a QMP block_resize operation while the job is running. That does not directly cover an associated 'file' node of a 'raw' node, but resizing such a 'file' node is already prevented too (backup, commit, mirror and stream were checked). The other case is copy-before-write. This commit does not change the fact that the copy-before-write node still has the same size after its filtered child is resized. Block drivers that do implement .bdrv_co_getlength() and where .is_filter is true, already returned the length of the file child, so there is no change before and after this commit, with two exceptions: 1. preallocate can return an early data_end and otherwise queries the file child, but that special casing is not changed. 2. blkverify returns the length of the test file. This commit does not affect that behavior. Signed-off-by: Fiona Ebner --- Changes in v2: * Check for BDRV_CHILD_FILTERED rather than bs->drv->is_filter which is more generic and for example, also covers the case when the child of a 'raw' node is resized. * Expand commit message. block.c | 12 ++++++++++++ include/block/block_int-common.h | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 8848e9a7ed..cf08e64add 100644 --- a/block.c +++ b/block.c @@ -1497,6 +1497,17 @@ static void GRAPH_WRLOCK bdrv_child_cb_detach(BdrvCh= ild *child) } } =20 +static void coroutine_fn GRAPH_RDLOCK bdrv_child_cb_resize(BdrvChild *chil= d) +{ + BlockDriverState *bs =3D child->opaque; + + if (child->role & BDRV_CHILD_FILTERED) { + /* Best effort, ignore errors. */ + bdrv_co_refresh_total_sectors(bs, bs->total_sectors); + bdrv_co_parent_cb_resize(bs); + } +} + static int bdrv_child_cb_update_filename(BdrvChild *c, BlockDriverState *b= ase, const char *filename, bool backing_mask_protocol, @@ -1529,6 +1540,7 @@ const BdrvChildClass child_of_bds =3D { .detach =3D bdrv_child_cb_detach, .inactivate =3D bdrv_child_cb_inactivate, .change_aio_ctx =3D bdrv_child_cb_change_aio_ctx, + .resize =3D bdrv_child_cb_resize, .update_filename =3D bdrv_child_cb_update_filename, .get_parent_aio_context =3D child_of_bds_get_parent_aio_context, }; diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 8a3d427356..c55b35da8e 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -1023,7 +1023,7 @@ struct BdrvChildClass { /* * Notifies the parent that the child was resized. */ - void (*resize)(BdrvChild *child); + void GRAPH_RDLOCK_PTR (*resize)(BdrvChild *child); =20 /* * Returns a name that is supposedly more useful for human users than = the --=20 2.47.2 From nobody Mon Sep 22 02:17:13 2025 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 1758110206195949.0016291282401; Wed, 17 Sep 2025 04:56:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uyqlU-0000a3-SO; Wed, 17 Sep 2025 07:56:04 -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 1uyqkx-0007he-8o; Wed, 17 Sep 2025 07:55:28 -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 1uyqkt-0004bw-L0; Wed, 17 Sep 2025 07:55:26 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9E5E44DC0B; Wed, 17 Sep 2025 13:55:20 +0200 (CEST) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, fam@euphon.net, stefanha@redhat.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v2 4/5] iotests: add test for resizing a node below filters Date: Wed, 17 Sep 2025 13:54:51 +0200 Message-ID: <20250917115509.401015-5-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250917115509.401015-1-f.ebner@proxmox.com> References: <20250917115509.401015-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: 1758110111520 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: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1758110207522116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fiona Ebner Reviewed-by: Hanna Czenczek --- tests/qemu-iotests/tests/resize-below-filter | 73 +++++++++++++++++++ .../tests/resize-below-filter.out | 5 ++ 2 files changed, 78 insertions(+) create mode 100755 tests/qemu-iotests/tests/resize-below-filter create mode 100644 tests/qemu-iotests/tests/resize-below-filter.out diff --git a/tests/qemu-iotests/tests/resize-below-filter b/tests/qemu-iote= sts/tests/resize-below-filter new file mode 100755 index 0000000000..f55619cf34 --- /dev/null +++ b/tests/qemu-iotests/tests/resize-below-filter @@ -0,0 +1,73 @@ +#!/usr/bin/env python3 +# group: rw quick +# +# Test what happens when a node below filter nodes is resized. +# +# Copyright (C) Proxmox Server Solutions GmbH +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +import iotests +from iotests import imgfmt, qemu_img_create, QMPTestCase + +image_size =3D 1 * 1024 * 1024 +image =3D os.path.join(iotests.test_dir, 'test.img') + +class TestResizeBelowFilter(QMPTestCase): + def setUp(self) -> None: + qemu_img_create('-f', imgfmt, image, str(image_size)) + + self.vm =3D iotests.VM() + self.vm.add_blockdev(self.vm.qmp_to_opts({ + 'driver': imgfmt, + 'node-name': 'node0', + 'file': { + 'driver': 'file', + 'filename': image, + } + })) + self.vm.add_blockdev(self.vm.qmp_to_opts({ + 'driver': 'compress', + 'node-name': 'comp0', + 'file': 'node0', + })) + self.vm.add_object('throttle-group,id=3Dthrgr0') + self.vm.add_blockdev(self.vm.qmp_to_opts({ + 'driver': 'throttle', + 'node-name': 'thr0', + 'throttle-group': 'thrgr0', + 'file': 'comp0', + })) + self.vm.add_object('throttle-group,id=3Dthrgr1') + self.vm.add_blockdev(self.vm.qmp_to_opts({ + 'driver': 'throttle', + 'node-name': 'thr1', + 'throttle-group': 'thrgr1', + 'file': 'node0', + })) + self.vm.launch() + + def tearDown(self) -> None: + self.vm.shutdown() + os.remove(image) + + def assert_size(self, size: int) -> None: + nodes =3D self.vm.qmp('query-named-block-nodes', flat=3DTrue)['ret= urn'] + self.assertEqual(len(nodes), 5) + for node in nodes: + if node['drv'] =3D=3D 'file': + continue + self.assertEqual(node['image']['virtual-size'], size) + + def test_resize_below_filter(self) -> None: + self.assert_size(image_size) + self.vm.qmp('block_resize', node_name=3D'thr0', size=3D2*image_siz= e) + self.assert_size(2*image_size) + self.vm.qmp('block_resize', node_name=3D'comp0', size=3D3*image_si= ze) + self.assert_size(3*image_size) + self.vm.qmp('block_resize', node_name=3D'node0', size=3D4*image_si= ze) + self.assert_size(4*image_size) + +if __name__ =3D=3D '__main__': + iotests.main(supported_fmts=3D['qcow2'], supported_protocols=3D['file'= ]) diff --git a/tests/qemu-iotests/tests/resize-below-filter.out b/tests/qemu-= iotests/tests/resize-below-filter.out new file mode 100644 index 0000000000..ae1213e6f8 --- /dev/null +++ b/tests/qemu-iotests/tests/resize-below-filter.out @@ -0,0 +1,5 @@ +. +---------------------------------------------------------------------- +Ran 1 tests + +OK --=20 2.47.2 From nobody Mon Sep 22 02:17:13 2025 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 1758110196366435.94738734085536; Wed, 17 Sep 2025 04:56:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uyqlJ-0008Ou-Tx; Wed, 17 Sep 2025 07:55:50 -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 1uyql0-0007jr-QD; Wed, 17 Sep 2025 07:55:34 -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 1uyqky-0004dD-7h; Wed, 17 Sep 2025 07:55:29 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E6AC44DC0C; Wed, 17 Sep 2025 13:55:20 +0200 (CEST) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, fam@euphon.net, stefanha@redhat.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v2 5/5] iotests: add test for resizing a 'file' node below a 'raw' node Date: Wed, 17 Sep 2025 13:54:52 +0200 Message-ID: <20250917115509.401015-6-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250917115509.401015-1-f.ebner@proxmox.com> References: <20250917115509.401015-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: 1758110111538 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: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1758110197995116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fiona Ebner --- New in v2. tests/qemu-iotests/tests/resize-below-raw | 53 +++++++++++++++++++ tests/qemu-iotests/tests/resize-below-raw.out | 5 ++ 2 files changed, 58 insertions(+) create mode 100755 tests/qemu-iotests/tests/resize-below-raw create mode 100644 tests/qemu-iotests/tests/resize-below-raw.out diff --git a/tests/qemu-iotests/tests/resize-below-raw b/tests/qemu-iotests= /tests/resize-below-raw new file mode 100755 index 0000000000..3c9241c918 --- /dev/null +++ b/tests/qemu-iotests/tests/resize-below-raw @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 +# group: rw quick +# +# Test what happens when a 'file' node below a 'raw' node is resized. +# +# Copyright (C) Proxmox Server Solutions GmbH +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +import iotests +from iotests import imgfmt, qemu_img_create, QMPTestCase + +image_size =3D 1 * 1024 * 1024 +image =3D os.path.join(iotests.test_dir, 'test.img') + +class TestResizeBelowRaw(QMPTestCase): + def setUp(self) -> None: + qemu_img_create('-f', imgfmt, image, str(image_size)) + + self.vm =3D iotests.VM() + self.vm.add_blockdev(self.vm.qmp_to_opts({ + 'driver': imgfmt, + 'node-name': 'node0', + 'file': { + 'driver': 'file', + 'filename': image, + 'node-name': 'file0', + } + })) + self.vm.launch() + + def tearDown(self) -> None: + self.vm.shutdown() + os.remove(image) + + def assert_size(self, size: int) -> None: + nodes =3D self.vm.qmp('query-named-block-nodes', flat=3DTrue)['ret= urn'] + self.assertEqual(len(nodes), 2) + for node in nodes: + if node['drv'] =3D=3D 'file': + continue + self.assertEqual(node['image']['virtual-size'], size) + + def test_resize_below_raw(self) -> None: + self.assert_size(image_size) + self.vm.qmp('block_resize', node_name=3D'file0', size=3D2*image_si= ze) + self.assert_size(2*image_size) + self.vm.qmp('block_resize', node_name=3D'node0', size=3D3*image_si= ze) + self.assert_size(3*image_size) + +if __name__ =3D=3D '__main__': + iotests.main(supported_fmts=3D['raw'], supported_protocols=3D['file']) diff --git a/tests/qemu-iotests/tests/resize-below-raw.out b/tests/qemu-iot= ests/tests/resize-below-raw.out new file mode 100644 index 0000000000..ae1213e6f8 --- /dev/null +++ b/tests/qemu-iotests/tests/resize-below-raw.out @@ -0,0 +1,5 @@ +. +---------------------------------------------------------------------- +Ran 1 tests + +OK --=20 2.47.2