]> git.proxmox.com Git - pve-storage.git/commitdiff
vdisk list: only collect images from storages with an appropriate content type
authorFabian Ebner <f.ebner@proxmox.com>
Fri, 12 Mar 2021 09:50:26 +0000 (10:50 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 15 Mar 2021 12:36:53 +0000 (13:36 +0100)
Only these storages are activated in the first place, and it's bad behavior to
list images when no appropriate content type is not set.

For example, on VM destruction, this avoids unreferenced images to be deleted
from a storage with only 'backup' content type set, which is supposedly what
happened in this[0] forum thread.

(Some) callers expect all keys to be present and valid array references in the
result, so initialization is needed.

Now, the enabled check is already done by the preceding code for every element
that is iterated over, and thus isn't needed in the main loop anymore.

[0]: https://forum.proxmox.com/threads/erasing-all-vm-disks-after-a-failed-vm-migration-task.85068

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/Storage.pm

index 8ee2c929341c217974bb004ef3f43cdc116b5994..18c03ec30d0d6a054f85fcb37c873a2334542762 100755 (executable)
@@ -938,7 +938,7 @@ sub vdisk_list {
 
     storage_check_enabled($cfg, $storeid) if ($storeid);
 
-    my $res = {};
+    my $res = { map { $_ => [] } keys %{$ids} };
 
     # prepare/activate/refresh all storages
 
@@ -964,9 +964,8 @@ sub vdisk_list {
 
     activate_storage_list($cfg, $storage_list, $cache);
 
-    foreach my $sid (keys %$ids) {
+    foreach my $sid (@{$storage_list}) {
        next if $storeid && $storeid ne $sid;
-       next if !storage_check_enabled($cfg, $sid, undef, 1);
 
        my $scfg = $ids->{$sid};
        my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});