[pve-devel] [RFC storage 3/3] storage: plugin: volume_size_info: fallback to raw for non-image volumes

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Dec 10 12:19:30 CET 2024


as a safeguard for external storage plugins that
- override parse_volname and return "weird" formats
- but don't override volume_size_info

to prevent them from running into new file_size_info checks that only work for
certain formats we know about.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
not sure if such plugins even exist? but the warning might help us find out ;)

 src/PVE/Storage/Plugin.pm | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index 5875553..1028cc1 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -1129,7 +1129,13 @@ sub update_volume_attribute {
 
 sub volume_size_info {
     my ($class, $scfg, $storeid, $volname, $timeout) = @_;
-    my $format = ($class->parse_volname($volname))[6];
+    my ($vtype, $format) = ($class->parse_volname($volname))[0,6];
+
+    if ($vtype ne 'images' && $format && $format ne 'raw') {
+        warn "volume_size_info: '$storeid:$volname': falling back from format '$format' to 'raw'\n";
+        $format = 'raw';
+    }
+
     my $path = $class->filesystem_path($scfg, $volname);
     return file_size_info($path, $timeout, $format);
 
-- 
2.39.5





More information about the pve-devel mailing list