From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 6DCDC69C44 for ; Fri, 12 Mar 2021 10:50:32 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6C2CD31355 for ; Fri, 12 Mar 2021 10:50:32 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 9B9F43134B for ; Fri, 12 Mar 2021 10:50:31 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 653E6439DD for ; Fri, 12 Mar 2021 10:50:31 +0100 (CET) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Fri, 12 Mar 2021 10:50:26 +0100 Message-Id: <20210312095027.19451-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.002 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com, storage.pm] Subject: [pve-devel] [PATCH storage 1/2] vdisk list: only collect images from storages with an appropriate content type X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Mar 2021 09:50:32 -0000 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 --- Why isn't 'iterand' a word? PVE/Storage.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/PVE/Storage.pm b/PVE/Storage.pm index 8ee2c92..18c03ec 100755 --- a/PVE/Storage.pm +++ b/PVE/Storage.pm @@ -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}); -- 2.20.1