[pve-devel] [PATCH storage] Fix #1474: Fixes input and output of print_storage

Philip Abernethy p.abernethy at proxmox.com
Thu Aug 10 13:14:52 CEST 2017


Accommodates changes in 44ae567 and d40e27d by
reordering checks to allow for proper filtering
of disabled storages. Also reorders two checks to
prevent autovivification resulting in disabled
storages always showing in output.
---
 PVE/Storage.pm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index 5d0b2ba..9829fbd 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -1011,6 +1011,7 @@ sub storage_info {
 
     my $slist = [];
     foreach my $storeid (keys %$ids) {
+	my $storage_enabled = storage_check_enabled($cfg, $storeid, undef, 1);
 
 	if (defined($content)) {
 	    my $want_ctype = 0;
@@ -1020,7 +1021,7 @@ sub storage_info {
 		    last;
 		}
 	    }
-	    next if !$want_ctype;
+	    next if !$want_ctype || !defined($storage_enabled);
 	}
 
 	my $type = $ids->{$storeid}->{type};
@@ -1033,7 +1034,7 @@ sub storage_info {
 	    shared => $ids->{$storeid}->{shared} ? 1 : 0,
 	    content => PVE::Storage::Plugin::content_hash_to_string($ids->{$storeid}->{content}),
 	    active => 0,
-	    enabled => defined(storage_check_enabled($cfg, $storeid, undef, 1)) ? 1 : 0,
+	    enabled => defined($storage_enabled) ? 1 : 0,
 	};
 
 	push @$slist, $storeid;
@@ -1042,10 +1043,10 @@ sub storage_info {
     my $cache = {};
 
     foreach my $storeid (keys %$ids) {
-	next if !$info->{$storeid}->{enabled};
-
 	my $scfg = $ids->{$storeid};
+
 	next if !$info->{$storeid};
+	next if !$info->{$storeid}->{enabled};
 
 	eval { activate_storage($cfg, $storeid, $cache); };
 	if (my $err = $@) {
-- 
2.11.0





More information about the pve-devel mailing list