[pve-devel] [PATCH storage 5/9] introduce resolve_format_hint() helper
Fiona Ebner
f.ebner at proxmox.com
Mon Jul 21 14:10:50 CEST 2025
Callers interested in the list of valid formats from
storage_default_format() actually want this functionality.
Signed-off-by: Fiona Ebner <f.ebner at 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
More information about the pve-devel
mailing list