From nobody Sun Apr 19 12:41:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1776240367; cv=none; d=zohomail.com; s=zohoarc; b=DEYvypagKy61WckgKG8qwOL+iWGW0QjYa9G+Ktv67lgzgY6ruWvOTmuMWFceF3Xpr4H2aoNIDc15DfXdYn2Uh+d9jy3CEIvbQEeKxYRyLb9bWUboru10jFmSgVg9E9Ab1LsmK/aMxl4DfInzk5dfii/ksTih+53m38rDrOPDp/A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776240367; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=CMDrFsWw0Upeubj98oDhSrcZizVAVvH1WLxb7VUoIGs=; b=hprGOemEolyTu589MBdnu6rU4y7Z4sOtfyu+Su/250ccT6dr6DAX/fmYNDbz239peUTGAIJlL2hAxZDbPk6IFnjXUncD9vMAryvaZb5Os3l5UKsJLt/Ko+Q0duJt1s/+uF6qaRkM+NQ8cco4AoWfUg6OMJcj8Be6/epThNwC2sA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1776240367277765.1202674711654; Wed, 15 Apr 2026 01:06:07 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 463AF418C2; Wed, 15 Apr 2026 04:06:06 -0400 (EDT) Received: from [172.19.199.3] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id D85F241945; Wed, 15 Apr 2026 04:04:30 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 5DCE23F2F3; Wed, 15 Apr 2026 04:04:13 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id BF2C13F2F6 for ; Wed, 15 Apr 2026 04:04:12 -0400 (EDT) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-V2LLPOcvNgmyN8tvHrInow-1; Wed, 15 Apr 2026 04:04:10 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3503319560AD for ; Wed, 15 Apr 2026 08:04:10 +0000 (UTC) Received: from speedmetal.lan (unknown [10.44.24.20]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5A7DC180044F for ; Wed, 15 Apr 2026 08:04:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS autolearn=no autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776240252; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CMDrFsWw0Upeubj98oDhSrcZizVAVvH1WLxb7VUoIGs=; b=KU6duKhhuLWtGfN2AW8UHobH0Pe4xzgEowa3B1U2jcey/lu21wgXFm2w47izMduI5jo1vJ BPStpjPhcV5p0QaNhlJPUmWuT58bdlXDbvuj7Iw45I3qenBhxrNT9DejiGQh+gzdRWC3Tg AgrooSj3plkPkunYo5Jk2gGnTtHu4tg= X-MC-Unique: V2LLPOcvNgmyN8tvHrInow-1 X-Mimecast-MFC-AGG-ID: V2LLPOcvNgmyN8tvHrInow_1776240250 To: devel@lists.libvirt.org Subject: [PATCH v2 1/3] virDomainBlockResizeFlags: Convert to prefix-style docs Date: Wed, 15 Apr 2026 10:04:04 +0200 Message-ID: <4e98e2b67e155de71e62e24daebd05893592c6ed.1776240030.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ZmqIcTz_rExJkNh8bBhSb8sUEyWrNiF18DdbToMQW3o_1776240250 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: T2REFDC4X63VKDHYJUGJ4QJZUMUQUTDN X-Message-ID-Hash: T2REFDC4X63VKDHYJUGJ4QJZUMUQUTDN X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1776240370340154100 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Upcoming patches will want to add more extensive docs for one of the new flags so this format will make it more readable. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- include/libvirt/libvirt-domain.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 09a797cab6..084debbf21 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -2346,8 +2346,11 @@ int virDomainBlockPeek (virDomai= nPtr dom, * Since: 0.9.11 */ typedef enum { - VIR_DOMAIN_BLOCK_RESIZE_BYTES =3D 1 << 0, /* size in bytes instead of = KiB (Since: 0.9.11) */ - VIR_DOMAIN_BLOCK_RESIZE_CAPACITY =3D 1 << 1, /* resize to full the cap= acity of the source (Since: 10.0.0) */ + /* size in bytes instead of KiB (Since: 0.9.11) */ + VIR_DOMAIN_BLOCK_RESIZE_BYTES =3D 1 << 0, + + /* resize to full the capacity of the source (Since: 10.0.0) */ + VIR_DOMAIN_BLOCK_RESIZE_CAPACITY =3D 1 << 1, } virDomainBlockResizeFlags; int virDomainBlockResize (virDomainPtr dom, --=20 2.53.0 From nobody Sun Apr 19 12:41:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1776240452; cv=none; d=zohomail.com; s=zohoarc; b=QTuZU6nhcwr111c1GcEka716VfzN276Q0Z94VjP/Q5kuhs3a1QhnSmGYP0iAg0MHTawio7dFaE/ZGWlhkt1nRT3o0wVZYazARCd1PeoWNM+sBQ7d7cswg7g76aZN414I/JVXpfeEZ++PMvhAbgjefQwIakbQtM2O4tW+9ROAD7s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776240452; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=6b6HJF52nUoZ/TG9f5ly6G68yqxuCGyBqujL5VUJ7CM=; b=i8YvP9cqZ7rU6tqmgHuji7y5rPHRDXtyXJ1ptm6p+oG3ufpFAHZA8tZN5G3mqDAnfB2Wx6hlS+IYmo5Y1TF9DCaMC8r3Ko2FsdF8Z/IeGfp4shll6YPDUZuiCAlnmP+LWsHKcRNpgkE/Zz+m2S+aQSEA1iVpoqpynNOOafVF2Y4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1776240452710161.00180422748042; Wed, 15 Apr 2026 01:07:32 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 82ACB41814; Wed, 15 Apr 2026 04:07:31 -0400 (EDT) Received: from [172.19.199.3] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id D99CC419CA; Wed, 15 Apr 2026 04:04:37 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id E58163F2FA; Wed, 15 Apr 2026 04:04:14 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 19FBE3F2F6 for ; Wed, 15 Apr 2026 04:04:14 -0400 (EDT) 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-441-Quo8BH39MUyzQmECL5Reug-1; Wed, 15 Apr 2026 04:04:12 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 87C821800367 for ; Wed, 15 Apr 2026 08:04:11 +0000 (UTC) Received: from speedmetal.lan (unknown [10.44.24.20]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B6E49180044F for ; Wed, 15 Apr 2026 08:04:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776240253; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6b6HJF52nUoZ/TG9f5ly6G68yqxuCGyBqujL5VUJ7CM=; b=VRwpOxfmG7hOw6cCBUIIEOYsqmQgsMcIrYZQMxhDXr6/LZxg6iWjIKS8MlVE1WaJg+HdI0 bf5NYzZqS274xqw0Cwo8W3OdGMqqGrEYoNhacn+3qv/RK3poYmCZavF3IuIxvY562A0h4B 6K+vvMaRvzPcYmVa9+UqNytpCsZka8A= X-MC-Unique: Quo8BH39MUyzQmECL5Reug-1 X-Mimecast-MFC-AGG-ID: Quo8BH39MUyzQmECL5Reug_1776240251 To: devel@lists.libvirt.org Subject: [PATCH v2 2/3] API/qemu: Introduce 'VIR_DOMAIN_BLOCK_RESIZE_EXTEND' for 'virDomainBlockResize' Date: Wed, 15 Apr 2026 10:04:05 +0200 Message-ID: <09e0b79029abd3ace1e1a3f1b85cdbe939a31113.1776240030.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: vbV_1AXhwj7qDbxc6tT-1Oz518YCBFO2WRdt7QOo_9A_1776240251 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: TV4DAW6XBPY53TO5DAJX7FEFHHLBPZVA X-Message-ID-Hash: TV4DAW6XBPY53TO5DAJX7FEFHHLBPZVA X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1776240453643158500 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Introduce a new flag VIR_DOMAIN_BLOCK_RESIZE_EXTEND which will prevent accidental shrinking of the block device. Warn callers that they ought to use it. While this won't prevent any old uses without the flag (which we couldn't change due to our API guarantees) it will give the users tools to handle the resizing of devices more safely. Implement it in the qemu driver. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- include/libvirt/libvirt-domain.h | 3 +++ src/libvirt-domain.c | 5 +++++ src/qemu/qemu_driver.c | 32 +++++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 084debbf21..4a8e3114b3 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -2351,6 +2351,9 @@ typedef enum { /* resize to full the capacity of the source (Since: 10.0.0) */ VIR_DOMAIN_BLOCK_RESIZE_CAPACITY =3D 1 << 1, + + /* Disallow shrinking (Since: 12.3.0) */ + VIR_DOMAIN_BLOCK_RESIZE_EXTEND =3D 1 << 2, } virDomainBlockResizeFlags; int virDomainBlockResize (virDomainPtr dom, diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index ed51180c91..db9eea5774 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -6451,6 +6451,11 @@ virDomainBlockPeek(virDomainPtr dom, * size. Depending on the file format, the hypervisor may round up * to the next alignment boundary. * + * *BEWARE*: The block device may be shrunk if @size is less than the curr= ent + * guest visible size. Callers who wish to only extend @disk should always= pass + * VIR_DOMAIN_BLOCK_RESIZE_EXTEND (since 12.3.0) in @flags which instructs= the + * hypervisor to deny an attempt to shrink the device. + * * If @flag contains VIR_DOMAIN_BLOCK_RESIZE_CAPACITY (since 10.0.0) the * hypervisor will resize the guest block device to fully fill the source. * @size must be either set to zero, or to the exact size of the block diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 2d31d4aa31..b5ea0086b9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9448,7 +9448,8 @@ qemuDomainBlockResize(virDomainPtr dom, virDomainDiskDef *persistDisk =3D NULL; virCheckFlags(VIR_DOMAIN_BLOCK_RESIZE_BYTES | - VIR_DOMAIN_BLOCK_RESIZE_CAPACITY, -1); + VIR_DOMAIN_BLOCK_RESIZE_CAPACITY | + VIR_DOMAIN_BLOCK_RESIZE_EXTEND, -1); /* We prefer operating on bytes. */ if ((flags & VIR_DOMAIN_BLOCK_RESIZE_BYTES) =3D=3D 0) { @@ -9587,11 +9588,40 @@ qemuDomainBlockResize(virDomainPtr dom, if (!qemuDiskBusIsSD(disk->bus)) { nodename =3D qemuBlockStorageSourceGetEffectiveNodename(disk->src); } else { + if (flags & VIR_DOMAIN_BLOCK_RESIZE_EXTEND) { + /* technically possible, just not implemented */ + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("cannot prevent shrink on SD devices")); + goto endjob; + } + if (!(device =3D qemuAliasDiskDriveFromDisk(disk))) goto endjob; } qemuDomainObjEnterMonitor(vm); + + if (flags & VIR_DOMAIN_BLOCK_RESIZE_EXTEND) { + g_autoptr(GHashTable) blockNamedNodeData =3D qemuMonitorBlockGetNa= medNodeData(priv->mon); + qemuBlockNamedNodeData *entry; + + if (!(entry =3D virHashLookup(blockNamedNodeData, nodename))) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("failed to determine current size of '%1$s'"), + path); + qemuDomainObjExitMonitor(vm); + goto endjob; + } + + if (entry->capacity > size) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("resize of '%1$s' would shrink it from '%2$ll= u' to '%3$llu' bytes"), + path, entry->capacity, size); + qemuDomainObjExitMonitor(vm); + goto endjob; + } + } + if (qemuMonitorBlockResize(priv->mon, device, nodename, size) < 0) { qemuDomainObjExitMonitor(vm); goto endjob; --=20 2.53.0 From nobody Sun Apr 19 12:41:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1776240503; cv=none; d=zohomail.com; s=zohoarc; b=Jh943a0QmXz9gF0VblurbjjSrTaeellMRyW64odJUelZemRxFWD/XYpP8mZ4rZoOgGdDpQ7XrpRL7HXj+qQZ8ZFps3IK7hDQN3yJ5GVDLZnuu3EE9zLf9EIt83lLD2vxwb4oIRI47maUu4tDNQ4gdTBsbIAh6OCrUCyPdCs/dDs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776240503; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=84iJsuxDydMRoDKUGxrTftwc1vqmeyURqyJvejUFyxI=; b=VHOtjPttgbA02JnGW4v4G0Qn4lhYA/YZYXWd5jLg+QvibETH+F3DvllNgFdo+8n8/v7VqTuBpMp05bcxRVeVKBa8VayCSb7cwhQS+l7GtbDGn5nckP3uArlynpQJrFl/2bc7J4xbEKjf7WIqS6jlr0cX5hN2A7S5IE1l957wcss= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1776240503078890.982357094755; Wed, 15 Apr 2026 01:08:23 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 1799A3F8B1; Wed, 15 Apr 2026 04:08:22 -0400 (EDT) Received: from [172.19.199.3] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id B8ACC41A0A; Wed, 15 Apr 2026 04:04:42 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 588913F2F3; Wed, 15 Apr 2026 04:04:16 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 75DDE3F2F5 for ; Wed, 15 Apr 2026 04:04:15 -0400 (EDT) Received: from mx-prod-mc-06.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-85-DXUHo8P1NNOps9GYQlAG-Q-1; Wed, 15 Apr 2026 04:04:13 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AFF501800358 for ; Wed, 15 Apr 2026 08:04:12 +0000 (UTC) Received: from speedmetal.lan (unknown [10.44.24.20]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 01D15180044F for ; Wed, 15 Apr 2026 08:04:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776240255; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=84iJsuxDydMRoDKUGxrTftwc1vqmeyURqyJvejUFyxI=; b=BsrvJVQ7Ev7MhyIZ5p07jHHh4CVVfvK3XGa3Ca0vYUz5MJDB2h2NF1VXxGRdI9RHrtAwza v514q1UMvemFUqiuyrG+e6odCsC9DFkRDv1dI8mBP704rK0kbLRGuNhQlqgLYzQaVr/xDb DmZYKPSlF9fj9WS5JAsi+WkbDBSHfv4= X-MC-Unique: DXUHo8P1NNOps9GYQlAG-Q-1 X-Mimecast-MFC-AGG-ID: DXUHo8P1NNOps9GYQlAG-Q_1776240252 To: devel@lists.libvirt.org Subject: [PATCH v2 3/3] virsh: blockresize: Introduce '--extend' flag Date: Wed, 15 Apr 2026 10:04:06 +0200 Message-ID: <04f08c6abb3572f621d53ef3c33c34912b9727af.1776240030.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ja_zu--wtLAXWfZa7Cth5Cqm2jlk0dN-UFQJIM5zMiA_1776240252 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: GILSQIQQIVMUH353N24IKZD5RKOP3OKG X-Message-ID-Hash: GILSQIQQIVMUH353N24IKZD5RKOP3OKG X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1776240503880158500 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Use the new VIR_DOMAIN_BLOCK_RESIZE_EXTEND to prevent accidentally shrinking a disk and thus destroying data. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- docs/manpages/virsh.rst | 7 ++++++- tools/virsh-domain.c | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 4b8bbec7d6..80b0ea14a8 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -1642,7 +1642,7 @@ blockresize :: - blockresize domain path ([size] | [--capacity]) + blockresize domain path ([size] | [--capacity]) [--extend] Resize a block device of domain while the domain is running, *path* specifies the absolute path of the block device; it corresponds @@ -1650,6 +1650,11 @@ to a unique target name () or = source file () for one of the disk devices attached to *domain* (see also ``domblklist`` for listing these names). +The *--extend* flag instructs the hypervisor to ensure that the new size i= sn't +smaller than the old size, thus prevents (accidental) shrinking of the blo= ck +device which may lead to data loss. Users are encouraged to always use this +flag unless communicating with an older hypervisor. + For image formats without metadata (raw) stored inside fixed-size storage = (e.g. block devices) the --capacity flag can be used to resize the device to the full size of the backing device. diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index a17c8b42e2..08a1ce3953 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -3339,6 +3339,10 @@ static const vshCmdOptDef opts_blockresize[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("resize to capacity of source (block device)") }, + {.name =3D "extend", + .type =3D VSH_OT_BOOL, + .help =3D N_("ensure that the new size is larger than actual capacity= (prevent shrink)") + }, {.name =3D NULL} }; @@ -3352,6 +3356,9 @@ cmdBlockresize(vshControl *ctl, const vshCmd *cmd) VSH_ALTERNATIVE_OPTIONS("size", "capacity"); + if (vshCommandOptBool(cmd, "extend")) + flags |=3D VIR_DOMAIN_BLOCK_RESIZE_EXTEND; + if (vshCommandOptString(ctl, cmd, "path", (const char **) &path) < 0) return false; --=20 2.53.0