]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage.pm
vdisk list: allow specifying content type
[pve-storage.git] / PVE / Storage.pm
index 22a6ef1c3b3e494810a462dab1051aab33f10f3d..eaa86fbad7768e661760059948b28c8712cd3b8c 100755 (executable)
@@ -758,8 +758,14 @@ sub storage_migrate {
                or die "receive command failed: $!\n";
            close($input);
 
-           my ($ip) = <$info> =~ /^($PVE::Tools::IPRE)$/ or die "no tunnel IP received\n";
-           my ($port) = <$info> =~ /^(\d+)$/ or die "no tunnel port received\n";
+           my $try_ip = <$info> // '';
+           my ($ip) = $try_ip =~ /^($PVE::Tools::IPRE)$/ # untaint
+               or die "no tunnel IP received, got '$try_ip'\n";
+
+           my $try_port = <$info> // '';
+           my ($port) = $try_port =~ /^(\d+)$/ # untaint
+               or die "no tunnel port received, got '$try_port'\n";
+
            my $socket = IO::Socket::IP->new(PeerHost => $ip, PeerPort => $port, Type => SOCK_STREAM)
                or die "failed to connect to tunnel at $ip:$port\n";
            # we won't be reading from the socket
@@ -926,7 +932,7 @@ sub vdisk_free {
 }
 
 sub vdisk_list {
-    my ($cfg, $storeid, $vmid, $vollist) = @_;
+    my ($cfg, $storeid, $vmid, $vollist, $ctype) = @_;
 
     my $ids = $cfg->{ids};
 
@@ -949,6 +955,7 @@ sub vdisk_list {
            next if $storeid && $storeid ne $sid;
            next if !storage_check_enabled($cfg, $sid, undef, 1);
            my $content = $ids->{$sid}->{content};
+           next if defined($ctype) && !$content->{$ctype};
            next if !($content->{rootdir} || $content->{images});
            push @$storage_list, $sid;
        }
@@ -958,7 +965,10 @@ sub vdisk_list {
 
     activate_storage_list($cfg, $storage_list, $cache);
 
-    foreach my $sid (keys %$ids) {
+    # FIXME PVE 7.0: only scan storages with the correct content types
+    my $scan = defined($ctype) ? $storage_list : [ keys %{$ids} ];
+
+    foreach my $sid (@{$scan}) {
        next if $storeid && $storeid ne $sid;
        next if !storage_check_enabled($cfg, $sid, undef, 1);