Improve handling and description of migrate with --online

Thanks to Stefan and Thomas for the suggestions.

Changes from v1:
* update parameter description
* warn instead of die

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
(cherry picked from commit 1373938627)
Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
This commit is contained in:
Fabian Ebner 2019-11-18 15:41:15 +01:00 committed by Thomas Lamprecht
parent 2fb78e6cd2
commit 2afc3515c7

View File

@ -3162,7 +3162,7 @@ __PACKAGE__->register_method({
}),
online => {
type => 'boolean',
description => "Use online/live migration.",
description => "Use online/live migration if VM is running. Ignored if VM is stopped.",
optional => 1,
},
force => {
@ -3224,9 +3224,6 @@ __PACKAGE__->register_method({
my $vmid = extract_param($param, 'vmid');
raise_param_exc({ targetstorage => "Live storage migration can only be done online." })
if !$param->{online} && $param->{targetstorage};
raise_param_exc({ force => "Only root may use this option." })
if $param->{force} && $authuser ne 'root@pam';
@ -3247,8 +3244,14 @@ __PACKAGE__->register_method({
if (PVE::QemuServer::check_running($vmid)) {
die "cant migrate running VM without --online\n"
if !$param->{online};
} else {
warn "VM isn't running. Doing offline migration instead." if $param->{online};
$param->{online} = 0;
}
raise_param_exc({ targetstorage => "Live storage migration can only be done online." })
if !$param->{online} && $param->{targetstorage};
my $storecfg = PVE::Storage::config();
if( $param->{targetstorage}) {