From d97d7ff676dae13ff6dc796103bbc2ef7f32f9e7 Mon Sep 17 00:00:00 2001 From: Fiona Ebner Date: Mon, 3 Mar 2025 10:24:43 +0100 Subject: [PATCH] plugin: volume export formats: avoid superfluous file_size_info() call The result from the file_size_info() call is not used by volume_export_formats() and most failure scenarios of file_size_info() lead to an undefined return value rather than a failure. This includes the case for a non-existent file. The default path() implementation doesn't do any existence check either. An interesting scenario where file_size_info() does fail, is when the volume is corrupted or not in the queried format. But this is a rare edge case, so an early check doesn't seem worth it. It will be caught by volume_export() itself, or in case of VM migration, also when querying the size during scanning of local volumes. While checking for the definedness of $size could serve as an early sanity check, it is not currently done and other plugins don't do such early checks in their implementation of volume_export_formats() either. Keep the implementation abstract in Plugin.pm too and avoid doing IO. Callers that want to do early existence checks or similar can do so themselves explicitly, covering all plugins. Signed-off-by: Fiona Ebner Link: https://lore.proxmox.com/20250303092445.13873-4-f.ebner@proxmox.com --- src/PVE/Storage/Plugin.pm | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm index 086c02c..4e16420 100644 --- a/src/PVE/Storage/Plugin.pm +++ b/src/PVE/Storage/Plugin.pm @@ -1758,10 +1758,7 @@ sub volume_export { sub volume_export_formats { my ($class, $scfg, $storeid, $volname, $snapshot, $base_snapshot, $with_snapshots) = @_; if ($scfg->{path} && !defined($snapshot) && !defined($base_snapshot)) { - my ($file) = $class->path($scfg, $volname, $storeid) - or return; my $format = ($class->parse_volname($volname))[6]; - my $size = file_size_info($file, undef, $format); if ($with_snapshots) { return ($format.'+size') if ($format eq 'qcow2' || $format eq 'vmdk');