Allow a caller to specify the volume's intended content type and assert whether the specified content type may be stored on the specified storage before allocating any volume.
Signed-off-by: Daniel Kral <d.k...@proxmox.com> --- changes since v1: - add assertion at `vdisk_alloc` instead of wrapper `alloc_volume_disk` src/PVE/Storage.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm index 3776565..96d4e41 100755 --- a/src/PVE/Storage.pm +++ b/src/PVE/Storage.pm @@ -1059,6 +1059,13 @@ Specifies the name of the new volume. If undefined, the name will be generated with C<PVE::Storage::Plugin::find_free_diskname>. +=item * C<< $vtype => $string >> + +Specifies the content type of the new volume, which can be one of C<'images'>, C<'rootdir'>, +C<'vztmpl'>, C<'iso'>, C<'backup'>, C<'snippets'> or C<'import'>. + +If set, this will assert whether the storage supports the specified content type. + =back Returns the identifier for the new volume in the format C<"$storeid:$volname">. @@ -1069,6 +1076,7 @@ sub vdisk_alloc : prototype($$$$$;%) { my ($cfg, $storeid, $vmid, $fmt, $size, $opts) = @_; my $name = $opts->{name}; + my $vtype = $opts->{vtype}; die "no storage ID specified\n" if !$storeid; @@ -1086,6 +1094,8 @@ sub vdisk_alloc : prototype($$$$$;%) { activate_storage($cfg, $storeid); + assert_content_type_supported($cfg, $storeid, $vtype) if $vtype; + my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); # lock shared storage -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel