From c86d8f6d804cfef41764bb2fe05f813e87042ab9 Mon Sep 17 00:00:00 2001 From: Fiona Ebner Date: Mon, 21 Jul 2025 14:10:50 +0200 Subject: [PATCH] introduce resolve_format_hint() helper Callers interested in the list of valid formats from storage_default_format() actually want this functionality. Signed-off-by: Fiona Ebner --- 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) = @_;