[pve-devel] [PATCH v4 qemu-server 2/3] fix local disk migration when no target storage is set

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Dec 20 09:55:11 CET 2018


From: Thomas Lamprecht <t.lamprecht at proxmox.com>

the check for targetstorage in:
if ($self->{running} && $self->{opts}->{targetstorage} && $local_volumes->{$volid}->{ref} eq 'config') {

was obsolete, as we always set the tragetstorage opts variable to '1'
in a broader "use same sid for remote local" check above.
So removing it leads to the same if truthtable but fixes the
check if we should fallback to the volume's SID if targetstorage is
not set, as else it seemed to be always set, and '1' is naturally not
a correct stroage ID.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
Changes to v3:
  We still need to pass '1' to the `qm start` command on the remote end,
  otherwise it'll assume the disks are already available instead of
  expecting a storage migration.

 PVE/QemuMigrate.pm | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 0bae076..b12034f 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -404,10 +404,6 @@ sub sync_disks {
 	    $self->log('warn', "$err");
 	}
 
-	if ($self->{running} && !$sharedvm && !$self->{opts}->{targetstorage}) {
-	    $self->{opts}->{targetstorage} = 1; #use same sid for remote local
-	}
-
 	if ($abort) {
 	    die "can't migrate VM - check log\n";
 	}
@@ -447,7 +443,7 @@ sub sync_disks {
 	foreach my $volid (keys %$local_volumes) {
 	    my ($sid, $volname) = PVE::Storage::parse_volume_id($volid);
 	    my $targetsid = $self->{opts}->{targetstorage} ? $self->{opts}->{targetstorage} : $sid;
-	    if ($self->{running} && $self->{opts}->{targetstorage} && $local_volumes->{$volid}->{ref} eq 'config') {
+	    if ($self->{running} && $local_volumes->{$volid}->{ref} eq 'config') {
 		push @{$self->{online_local_volumes}}, $volid;
 	    } else {
 		next if $rep_volumes->{$volid};
@@ -555,8 +551,8 @@ sub phase2 {
 	push @$cmd, '--machine', $self->{forcemachine};
     }
 
-    if ($self->{opts}->{targetstorage}) {
-	push @$cmd, '--targetstorage', $self->{opts}->{targetstorage};
+    if ($self->{online_local_volumes}) {
+	push @$cmd, '--targetstorage', ($self->{opts}->{targetstorage} // '1');
     }
 
     my $spice_port;
-- 
2.11.0





More information about the pve-devel mailing list