[pve-devel] [PATCH storage 1/2] vdisk_list: only scan storages with the correct content type(s)

Fabian Ebner f.ebner at proxmox.com
Fri Jun 18 12:59:35 CEST 2021

The enabled check in the lower loop is now redundant and can be removed.

If storeid is provided, initialize the result hash accordingly, mainly for
backwards compatibility (needed by a caller in pve-manager's Ceph/Pools.pm and
the migration code in pve-container and qemu-server), but it also is less
surprising in general.

Remaining vdisk_list users that do not specify a content type are:
    1. pve-manager's Pool/Ceph.pm, but the content type for RBD can only be
       rootdir and images, so the storage is scanned (if enabled, same as
    2. pve-container migration
    3. qemu-server migration
For the latter two, it's planned to enforce content type, so the change is fine

This also means that for iscsi(direct) plugins with content type 'none', i.e.
"use LUNs directly" does not return the list of images anymore, but that was
rather a bug anyways as they're not virtual disks then:
All of the remaining callers not using content types (see above) are fine with
that change too.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>

Breaks old migration behavior when there are unused/unreferenced/vmstate volumes
on a misconfigured storage!

 PVE/Storage.pm | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index 3aa2100..7312eba 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -936,7 +936,7 @@ sub vdisk_list {
     storage_check_enabled($cfg, $storeid) if ($storeid);
-    my $res = {};
+    my $res = $storeid ? { $storeid => [] } : {};
     # prepare/activate/refresh all storages
@@ -963,12 +963,8 @@ sub vdisk_list {
     activate_storage_list($cfg, $storage_list, $cache);
-    # FIXME PVE 7.0: only scan storages with the correct content types
-    my $scan = defined($ctype) ? $storage_list : [ keys %{$ids} ];
-    foreach my $sid (@{$scan}) {
+    for 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});

More information about the pve-devel mailing list