diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 072e8cf6..2087a753 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -1194,6 +1194,8 @@ __PACKAGE__->register_method({ vmid => get_standard_option('pve-vmid'), skiplock => get_standard_option('skiplock'), stateuri => get_standard_option('pve-qm-stateuri'), + migratedfrom => get_standard_option('pve-node',{ optional => 1 }), + }, }, returns => { @@ -1218,6 +1220,10 @@ __PACKAGE__->register_method({ raise_param_exc({ skiplock => "Only root may use this option." }) if $skiplock && $authuser ne 'root@pam'; + my $migratedfrom = extract_param($param, 'migratedfrom'); + raise_param_exc({ migratedfrom => "Only root may use this option." }) + if $migratedfrom && $authuser ne 'root@pam'; + my $storecfg = PVE::Storage::config(); if (&$vm_is_ha_managed($vmid) && !$stateuri && @@ -1246,7 +1252,7 @@ __PACKAGE__->register_method({ syslog('info', "start VM $vmid: $upid\n"); - PVE::QemuServer::vm_start($storecfg, $vmid, $stateuri, $skiplock); + PVE::QemuServer::vm_start($storecfg, $vmid, $stateuri, $skiplock, $migratedfrom); return; }; diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm index 83bd9c96..69721fc6 100644 --- a/PVE/QemuMigrate.pm +++ b/PVE/QemuMigrate.pm @@ -298,9 +298,11 @@ sub phase2 { my $rport; + my $nodename = PVE::INotify::nodename(); + ## start on remote node - my $cmd = [@{$self->{rem_ssh}}, 'qm', 'start', - $vmid, '--stateuri', 'tcp', '--skiplock']; + my $cmd = [@{$self->{rem_ssh}}, 'qm', 'start', + $vmid, '--stateuri', 'tcp', '--skiplock', '--migratedfrom', $nodename]; PVE::Tools::run_command($cmd, outfunc => sub { my $line = shift; diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 9194bc3a..3b87e895 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -1499,9 +1499,9 @@ sub destroy_vm { } sub load_config { - my ($vmid) = @_; + my ($vmid, $node) = @_; - my $cfspath = cfs_config_path($vmid); + my $cfspath = cfs_config_path($vmid, $node); my $conf = PVE::Cluster::cfs_read_file($cfspath); @@ -1757,9 +1757,9 @@ sub check_cmdline { } sub check_running { - my ($vmid, $nocheck) = @_; + my ($vmid, $nocheck, $node) = @_; - my $filename = config_file($vmid); + my $filename = config_file($vmid, $node); die "unable to find configuration file for VM $vmid - no such machine\n" if !$nocheck && ! -f $filename; @@ -2708,14 +2708,14 @@ sub qemu_block_resize { } sub vm_start { - my ($storecfg, $vmid, $statefile, $skiplock) = @_; + my ($storecfg, $vmid, $statefile, $skiplock, $migratedfrom) = @_; lock_config($vmid, sub { - my $conf = load_config($vmid); + my $conf = load_config($vmid, $migratedfrom); check_lock($conf) if !$skiplock; - die "VM $vmid already running\n" if check_running($vmid); + die "VM $vmid already running\n" if check_running($vmid, undef, $migratedfrom); my $migrate_uri; my $migrate_port = 0;