[pve-devel] [PATCH 08/19] phase2: add targetvmid

Alexandre Derumier aderumier at odiso.com
Wed Feb 22 14:33:32 CET 2017


default is targetvmid=vmid, until we create a new one in case of externalcluster

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuMigrate.pm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index b711564..f1d621a 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -470,6 +470,7 @@ sub phase2 {
     my ($self, $vmid) = @_;
 
     my $conf = $self->{vmconf};
+    my $targetvmid = $vmid;
 
     if ($self->{opts}->{externalcluster}) {
 	$self->log('info', "Creating a new VM on remote external node '$self->{node}'");
@@ -482,7 +483,7 @@ sub phase2 {
             my $line = shift;
 
             if ($line =~ m/^vm (\d+) created$/) {
-                $vmid = $1;
+                $targetvmid = $1;
 		$self->{opts}->{targetvmid} = $1;
             }
 	});
@@ -497,7 +498,7 @@ sub phase2 {
         PVE::Tools::run_command($cmdwrite);
     }
 
-    $self->log('info', "starting VM $vmid on remote node '$self->{node}'");
+    $self->log('info', "starting VM $targetvmid on remote node '$self->{node}'");
 
     my $raddr;
     my $rport;
@@ -513,7 +514,7 @@ sub phase2 {
 	$spice_ticket = $res->{ticket};
     }
 
-    push @$cmd , 'qm', 'start', $vmid, '--skiplock', '--migratedfrom', $nodename;
+    push @$cmd , 'qm', 'start', $targetvmid, '--skiplock', '--migratedfrom', $nodename;
 
     # we use TCP only for unsecure migrations as TCP ssh forward tunnels often
     # did appeared to late (they are hard, if not impossible, to check for)
@@ -637,7 +638,7 @@ sub phase2 {
 	foreach my $drive (keys %{$self->{target_drive}}){
 	    my $nbd_uri = $self->{target_drive}->{$drive}->{nbd_uri};
 	    $self->log('info', "$drive: start migration to to $nbd_uri");
-	    PVE::QemuServer::qemu_drive_mirror($vmid, $drive, $nbd_uri, $vmid, undef, $self->{storage_migration_jobs}, 1);
+	    PVE::QemuServer::qemu_drive_mirror($vmid, $drive, $nbd_uri, $targetvmid, undef, $self->{storage_migration_jobs}, 1);
 	}
     }
 
-- 
2.1.4




More information about the pve-devel mailing list