From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 storage 6/7] introduce 'pve-storage-image-format' standard option for image format
Date: Wed, 5 Mar 2025 11:49:22 +0100 [thread overview]
Message-ID: <20250305104923.23618-7-f.ebner@proxmox.com> (raw)
In-Reply-To: <20250305104923.23618-1-f.ebner@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
next prev parent reply other threads:[~2025-03-05 10:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-05 10:49 [pve-devel] [PATCH-SERIES v2 qemu-server/storage/guest-common 0/7] slightly improve image format handling Fiona Ebner
2025-03-05 10:49 ` [pve-devel] [PATCH v2 qemu-server 1/7] drive: remove ancient 'cow' from formats Fiona Ebner
2025-03-05 10:49 ` [pve-devel] [PATCH v2 storage 2/7] plugin: file size info: " Fiona Ebner
2025-03-05 10:49 ` [pve-devel] [PATCH v2 storage 3/7] api: code cleanup: remove unused Data::Dumper include Fiona Ebner
2025-03-05 10:49 ` [pve-devel] [PATCH v2 storage 4/7] schema: anchor regex for 'pve-storage-format' Fiona Ebner
2025-03-05 10:49 ` [pve-devel] [PATCH v2 storage 5/7] api: alloc: allow 'vmdk' for the 'format' option Fiona Ebner
2025-03-05 10:49 ` Fiona Ebner [this message]
2025-03-05 10:49 ` [pve-devel] [PATCH v2 guest-common 7/7] storage tunnel: use pve-storage-image-format standard option Fiona Ebner
2025-04-03 13:10 ` [pve-devel] [PATCH-SERIES v2 qemu-server/storage/guest-common 0/7] slightly improve image format handling Fabian Grünbichler
2025-04-04 8:00 ` [pve-devel] applied-series: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250305104923.23618-7-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.