From 541064a95b890f6147409d49a0a07cda4df39e57 Mon Sep 17 00:00:00 2001 From: Fiona Ebner Date: Fri, 6 Dec 2024 17:25:28 +0100 Subject: [PATCH] list images: return 'invalid' format value for image that cannot be queried in expected format The only (transitive) caller that seems to be interested in the format is the API endpoint for content listing. The warning about not being able to query in the expected format might not be seen by consumers that only use the API result, so this helps admins detect such images. It is also for future-proofing, should any new callers want to use only images of certain formats to error out early. Signed-off-by: Fiona Ebner --- src/PVE/Storage/BTRFSPlugin.pm | 1 + src/PVE/Storage/Plugin.pm | 1 + 2 files changed, 2 insertions(+) diff --git a/src/PVE/Storage/BTRFSPlugin.pm b/src/PVE/Storage/BTRFSPlugin.pm index 555ed9d..def51ef 100644 --- a/src/PVE/Storage/BTRFSPlugin.pm +++ b/src/PVE/Storage/BTRFSPlugin.pm @@ -678,6 +678,7 @@ sub list_images { warn "image '$fn' is not in expected format '$format', querying as raw\n"; ($size, undef, $used, $parent, $ctime) = PVE::Storage::Plugin::file_size_info($fn, undef, 'raw'); + $format = 'invalid'; } } next if !defined($size); diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm index 917bd61..ae3c9dc 100644 --- a/src/PVE/Storage/Plugin.pm +++ b/src/PVE/Storage/Plugin.pm @@ -1300,6 +1300,7 @@ sub list_images { die $err if $err !~ m/Image is not in \S+ format$/; warn "image '$fn' is not in expected format '$format', querying as raw\n"; ($size, undef, $used, $parent, $ctime) = file_size_info($fn, undef, 'raw'); + $format = 'invalid'; } next if !defined($size);