From 2afc3515c7cfbc641a9d1dbacb610cb7630720ce Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Mon, 18 Nov 2019 15:41:15 +0100 Subject: [PATCH] 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 (cherry picked from commit 13739386276e14c98580db5fdd264041afec1492) Signed-off-by: Oguz Bektas --- PVE/API2/Qemu.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 248f5665..ae3e67d2 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -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}) {