Callers interested in the list of valid formats from
storage_default_format() actually want this functionality.

Signed-off-by: Fiona Ebner <f.eb...@proxmox.com>
---
 src/PVE/Storage.pm | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/PVE/Storage.pm b/src/PVE/Storage.pm
index 3286144..24ca19f 100755
--- a/src/PVE/Storage.pm
+++ b/src/PVE/Storage.pm
@@ -1681,6 +1681,17 @@ sub storage_default_format {
         wantarray ? ($formats->{default}, [sort keys $formats->{valid}->%*]) : 
$formats->{default};
 }
 
+sub resolve_format_hint {
+    my ($cfg, $storeid, $format_hint) = @_;
+
+    my $scfg = storage_config($cfg, $storeid);
+    my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
+
+    my $formats = $plugin->get_formats($scfg, $storeid);
+    return $format_hint if $format_hint && $formats->{valid}->{$format_hint};
+    return $formats->{default};
+}
+
 sub vgroup_is_used {
     my ($cfg, $vgname) = @_;
 
-- 
2.47.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to