From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 016721FF15C for <inbox@lore.proxmox.com>; Wed, 5 Mar 2025 11:50:24 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6EBDF14191; Wed, 5 Mar 2025 11:50:02 +0100 (CET) From: Fiona Ebner <f.ebner@proxmox.com> To: pve-devel@lists.proxmox.com Date: Wed, 5 Mar 2025 11:49:22 +0100 Message-Id: <20250305104923.23618-7-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250305104923.23618-1-f.ebner@proxmox.com> References: <20250305104923.23618-1-f.ebner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.043 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH v2 storage 6/7] introduce 'pve-storage-image-format' standard option for image format X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> The new 'pve-storage-image-format' standard option uses a simple enum instead of a subroutine verifier. Since the 'pve-storage-format' format that is replaced by it was used in pve-guest-common's StorageTunnel, the format cannot be removed without a versioned breaks. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> --- src/PVE/API2/Storage/Content.pm | 8 +++----- src/PVE/Storage/Common.pm | 27 +++++++++++++++++++++++++++ src/PVE/Storage/Plugin.pm | 9 ++++++--- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/PVE/API2/Storage/Content.pm b/src/PVE/API2/Storage/Content.pm index 03cc4a1..f84dbb7 100644 --- a/src/PVE/API2/Storage/Content.pm +++ b/src/PVE/API2/Storage/Content.pm @@ -6,7 +6,7 @@ use warnings; use PVE::SafeSyslog; use PVE::Cluster; use PVE::Storage; -use PVE::Storage::Plugin; # for 'pve-storage-format' format +use PVE::Storage::Common; # for 'pve-storage-image-format' standard option use PVE::INotify; use PVE::Exception qw(raise_param_exc); use PVE::RPCEnvironment; @@ -178,12 +178,10 @@ __PACKAGE__->register_method ({ type => 'string', pattern => '\d+[MG]?', }, - 'format' => { - type => 'string', - format => 'pve-storage-format', + format => get_standard_option('pve-storage-image-format', { requires => 'size', optional => 1, - }, + }), }, }, returns => { diff --git a/src/PVE/Storage/Common.pm b/src/PVE/Storage/Common.pm index 3ae20dd..1f81234 100644 --- a/src/PVE/Storage/Common.pm +++ b/src/PVE/Storage/Common.pm @@ -3,6 +3,8 @@ package PVE::Storage::Common; use strict; use warnings; +use PVE::JSONSchema; + =pod =head1 NAME @@ -25,6 +27,31 @@ be grouped in a submodule can also be found here. =back +=head1 STANDARD OPTIONS FOR JSON SCHEMA + +=over + +=back + +=head3 pve-storage-image-format + +Possible formats a guest image can have. + +=cut + +# TODO PVE 9 - Note that currently, qemu-server allows more formats for VM images, so third party +# storage plugins might potentially allow more too, but none of the plugins we are aware of do that. +# Those formats should either be allowed here or support for them should be phased out (at least in +# the storage layer). Can still be added again in the future, should any plugin provider request it. + +PVE::JSONSchema::register_standard_option('pve-storage-image-format', { + type => 'string', + enum => ['raw', 'qcow2', 'subvol', 'vmdk'], + description => "Format of the image.", +}); + +=pod + =head1 FUNCTIONS =cut diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm index dfdab16..6e23fec 100644 --- a/src/PVE/Storage/Plugin.pm +++ b/src/PVE/Storage/Plugin.pm @@ -184,11 +184,10 @@ my $defaultData = { type => 'string', format => 'pve-storage-path', optional => 1, }, - 'format' => { + format => get_standard_option('pve-storage-image-format', { description => "Default image format.", - type => 'string', format => 'pve-storage-format', optional => 1, - }, + }), preallocation => { description => "Preallocation mode for raw and qcow2 images. " . "Using 'metadata' on raw images results in preallocation=off.", @@ -342,6 +341,10 @@ sub verify_content { return $ct; } +# NOTE the 'pve-storage-format' is deprecated, use the 'pve-storage-image-format' standard option +# from Storage/Common.pm instead +# TODO PVE 9 - remove after doing a versioned breaks for pve-guest-common, which was using this +# format. PVE::JSONSchema::register_format('pve-storage-format', \&verify_format); sub verify_format { my ($fmt, $noerr) = @_; -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel