]> git.proxmox.com Git - qemu-server.git/commitdiff
use 'system_wakeup' to resume suspended vms
authorDominik Csapak <d.csapak@proxmox.com>
Wed, 13 Jun 2018 09:17:26 +0000 (11:17 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 13 Jun 2018 10:46:01 +0000 (12:46 +0200)
when a vm is suspended (e.g. autosuspend on windows)
we detect that it is not running, display the resume button,
but 'cont' does not wakeup the system from suspend

with this we can wake up suspended vms

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
PVE/QemuServer.pm

index 00e16694c67a1f837d5fb58e4e4e66d7cc47fed9..277bc58309e3ae6d741854448f3169eacc1bee90 100644 (file)
@@ -5170,6 +5170,13 @@ sub vm_resume {
 
     PVE::QemuConfig->lock_config($vmid, sub {
 
 
     PVE::QemuConfig->lock_config($vmid, sub {
 
+       my $res = vm_mon_cmd($vmid, 'query-status');
+       my $resume_cmd = 'cont';
+
+       if ($res->{status} && $res->{status} eq 'suspended') {
+           $resume_cmd = 'system_wakeup';
+       }
+
        if (!$nocheck) {
 
            my $conf = PVE::QemuConfig->load_config($vmid);
        if (!$nocheck) {
 
            my $conf = PVE::QemuConfig->load_config($vmid);
@@ -5177,10 +5184,10 @@ sub vm_resume {
            PVE::QemuConfig->check_lock($conf)
                if !($skiplock || PVE::QemuConfig->has_lock($conf, 'backup'));
 
            PVE::QemuConfig->check_lock($conf)
                if !($skiplock || PVE::QemuConfig->has_lock($conf, 'backup'));
 
-           vm_mon_cmd($vmid, "cont");
+           vm_mon_cmd($vmid, $resume_cmd);
 
        } else {
 
        } else {
-           vm_mon_cmd_nocheck($vmid, "cont");
+           vm_mon_cmd_nocheck($vmid, $resume_cmd);
        }
     });
 }
        }
     });
 }