]> git.proxmox.com Git - qemu-server.git/commitdiff
Improve handling and description of migrate with --online
authorFabian Ebner <f.ebner@proxmox.com>
Mon, 23 Sep 2019 07:56:01 +0000 (09:56 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 23 Sep 2019 11:12:08 +0000 (13:12 +0200)
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>
PVE/API2/Qemu.pm

index fd09d501c25a8b157fda2a6783a6dc3d8a0f47bd..fbede123921ddbf1f9251782da76b875c788c67c 100644 (file)
@@ -3314,7 +3314,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 => {
@@ -3375,9 +3375,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';
 
@@ -3398,8 +3395,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}) {