do not allow to migrate VM which uses local resources

But add a --force parameter to overwrite
This commit is contained in:
Dietmar Maurer 2011-09-12 11:01:52 +02:00
parent 34978be308
commit 669963ffbe

View File

@ -71,6 +71,11 @@ __PACKAGE__->register_method({
description => "Use online/live migration.",
optional => 1,
},
force => {
type => 'boolean',
description => "Allow to migrate VMs which use local devices.",
optional => 1,
},
},
},
returns => { type => 'null'},
@ -111,7 +116,7 @@ __PACKAGE__->register_method({
}
my $rhash = {};
eval_int (sub { phase1($conf, $rhash, $running); });
eval_int (sub { phase1($conf, $rhash, $running, $param->{force}); });
my $err = $@;
if ($err) {
@ -278,8 +283,6 @@ sub sync_disks {
my $res = [];
die "implement me";
eval {
my $volhash = {};
@ -471,12 +474,12 @@ sub finish_tunnel {
}
sub phase1 {
my ($conf, $rhash, $running) = @_;
my ($conf, $rhash, $running, $force) = @_;
logmsg('info', "starting migration of VM $vmid to node '$node' ($nodeip)");
if (my $loc_res = PVE::QemuServer::check_local_resources($conf, 1)) {
if ($running) {
if ($running || !$force) {
die "can't migrate VM which uses local devices\n";
} else {
logmsg('info', "migrating VM which uses local devices");