[pve-devel] [PATCH 3/7] add migratedfrom param to start vm with conf file an another node
Alexandre Derumier
aderumier at odiso.com
Tue Aug 21 12:21:51 CEST 2012
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/API2/Qemu.pm | 8 +++++++-
PVE/QemuMigrate.pm | 6 ++++--
PVE/QemuServer.pm | 14 +++++++-------
3 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 072e8cf..2087a75 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 at pam';
+ my $migratedfrom = extract_param($param, 'migratedfrom');
+ raise_param_exc({ migratedfrom => "Only root may use this option." })
+ if $migratedfrom && $authuser ne 'root at 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 83bd9c9..69721fc 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 449de75..c4631bf 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;
--
1.7.2.5
More information about the pve-devel
mailing list