]> git.proxmox.com Git - qemu-server.git/commitdiff
migrate: don't accidentally take NBD code paths
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Thu, 30 Apr 2020 07:35:29 +0000 (09:35 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 4 May 2020 15:34:58 +0000 (17:34 +0200)
by avoiding auto-vivification of $self->{online_local_volumes} via
iteration. most code paths don't care whether it's undef or a reference
to an empty list, but this caused the (already) fixed bug of calling
nbd_stop without having started an NBD server in the first place.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
PVE/QemuMigrate.pm

index 76449226cbd77a73f24e409a56173b25e962121f..d9b104c902c6b147cb543067eafaede1e16cb76c 100644 (file)
@@ -713,10 +713,14 @@ sub phase2 {
     $input .= "nbd_protocol_version: $nbd_protocol_version\n";
 
     my $number_of_online_replicated_volumes = 0;
-    foreach my $volid (@{$self->{online_local_volumes}}) {
-       next if !$self->{replicated_volumes}->{$volid};
-       $number_of_online_replicated_volumes++;
-       $input .= "replicated_volume: $volid\n";
+
+    # prevent auto-vivification
+    if ($self->{online_local_volumes}) {
+       foreach my $volid (@{$self->{online_local_volumes}}) {
+           next if !$self->{replicated_volumes}->{$volid};
+           $number_of_online_replicated_volumes++;
+           $input .= "replicated_volume: $volid\n";
+       }
     }
 
     my $target_replicated_volumes = {};