From nobody Mon Sep 8 20:25:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; 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 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmelikov.ru Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 17533680571701010.1137418629121; Thu, 24 Jul 2025 07:40:57 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0B0E7CF7; Thu, 24 Jul 2025 10:40:56 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6C420C7F; Thu, 24 Jul 2025 10:40:37 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 90BAD995; Thu, 24 Jul 2025 10:40:34 -0400 (EDT) Received: from forward204a.mail.yandex.net (forward204a.mail.yandex.net [178.154.239.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 3A706995 for ; Thu, 24 Jul 2025 10:40:33 -0400 (EDT) Received: from forward101a.mail.yandex.net (forward101a.mail.yandex.net [IPv6:2a02:6b8:c0e:500:1:45:d181:d101]) by forward204a.mail.yandex.net (Yandex) with ESMTPS id 2E66381A7A for ; Thu, 24 Jul 2025 17:34:21 +0300 (MSK) Received: from mail-nwsmtp-smtp-production-main-76.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-76.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:bc97:0:640:ee90:0]) by forward101a.mail.yandex.net (Yandex) with ESMTPS id 523D48046B for ; Thu, 24 Jul 2025 17:34:10 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-76.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id 3YVqDmBMkSw0-H8BcaoUK; Thu, 24 Jul 2025 17:34:09 +0300 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-Greylist: delayed 375 seconds by postgrey-1.37 at lists.libvirt.org; Thu, 24 Jul 2025 10:40:33 EDT X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmelikov.ru; s=mail; t=1753367649; bh=xQlyFVZ2L+6w+enwcN1p9pvoazkkToXw1BJyPT3Nkkc=; h=Message-ID:Date:Cc:Subject:To:From; b=I9/IFGgrbDbe+TBUyiYpPf/oVJvBREB4FdlFUnR1FxEYOdO2QmNCnWOGVkGAbE78i qHiHZDiLafJ9C9GtuHa+qTbaDhPWocp0qv1hl1DoaRaatxuEscAdHxLcUm1MD+l+ea t+JBu3FypWPC3XPPrPiBine2+Z80pxCgAPWRUcSI= Authentication-Results: mail-nwsmtp-smtp-production-main-76.iva.yp-c.yandex.net; dkim=pass header.i=@gmelikov.ru From: George Melikov To: devel@lists.libvirt.org Subject: [PATCH] Storage: ZFS: implement `resizeVol` method to support native resize Date: Thu, 24 Jul 2025 17:34:03 +0300 Message-ID: <20250724143403.167003-1-mail@gmelikov.ru> X-Mailer: git-send-email 2.47.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: IDFE7ORHA6EUY2H5SERL5RI3YS2PDD57 X-Message-ID-Hash: IDFE7ORHA6EUY2H5SERL5RI3YS2PDD57 X-MailFrom: mail@gmelikov.ru X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: George Melikov X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Computed bodyhash is different from the expected one) X-ZM-MESSAGEID: 1753368060724116600 Content-Type: text/plain; charset="utf-8" From: George Melikov ZFS doesn't have thick allocations, every allocation is thin-provisioned, so resize operation is essentially a zvol size limit change (`zfs set volsize=3DX pool/zvol_name`). Shrink is allowed too (which leads to data destruction), but shrink restriction is already implemented in libvirt, so this function doesn't need to check anything. This patch is posted via PR too and has green test runs https://gitlab.com/libvirt/libvirt/-/merge_requests/495 Signed-off-by: George Melikov Reviewed-by: Daniel P. Berrang=C3=A9 --- src/storage/storage_backend_zfs.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backen= d_zfs.c index 178b505e92..33434d0cac 100644 --- a/src/storage/storage_backend_zfs.c +++ b/src/storage/storage_backend_zfs.c @@ -439,6 +439,25 @@ virStorageBackendZFSDeletePool(virStoragePoolObj *pool, return virCommandRun(cmd, NULL); } =20 +static int +virStorageBackendZFSResizeVol(virStoragePoolObj *pool, + virStorageVolDef *vol, + unsigned long long capacity, + unsigned int flags) +{ + virStoragePoolDef *def =3D virStoragePoolObjGetDef(pool); + g_autoptr(virCommand) resize_cmd =3D NULL; + + virCheckFlags(0, -1); + + resize_cmd =3D virCommandNewArgList(ZFS, "set", NULL); + virCommandAddArgFormat(resize_cmd, "volsize=3D%llu", capacity); + virCommandAddArgFormat(resize_cmd, "%s/%s", + def->source.name, vol->name); + + return virCommandRun(resize_cmd, NULL); +} + virStorageBackend virStorageBackendZFS =3D { .type =3D VIR_STORAGE_POOL_ZFS, =20 @@ -450,6 +469,7 @@ virStorageBackend virStorageBackendZFS =3D { .deletePool =3D virStorageBackendZFSDeletePool, .uploadVol =3D virStorageBackendVolUploadLocal, .downloadVol =3D virStorageBackendVolDownloadLocal, + .resizeVol =3D virStorageBackendZFSResizeVol, }; =20 =20 --=20 2.47.2