[pve-devel] [PATCH qemu-server] api/resume: allow to resume 'to-disk suspended' VMs

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Mar 19 13:30:16 CET 2019


On 3/19/19 1:23 PM, Dominik Csapak wrote:
> 
> Reviewed-by: Dominik Csapak <d.csapak at proxmox.com>
> Tested-by: Dominik CSapak <d.csapak at proxmox.com>
> 

thanks, with this tags: applied

> On 19/03/2019 12:58, Thomas Lamprecht wrote:
>> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
>> Cc: Dominik Csapak <d.csapak at proxmox.com>
>> ---
>>   PVE/API2/Qemu.pm | 18 ++++++++++++++++--
>>   1 file changed, 16 insertions(+), 2 deletions(-)
>>
>> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
>> index 3c0ad23..99e37d8 100644
>> --- a/PVE/API2/Qemu.pm
>> +++ b/PVE/API2/Qemu.pm
>> @@ -2444,14 +2444,28 @@ __PACKAGE__->register_method({
>>         my $nocheck = extract_param($param, 'nocheck');
>>   -    die "VM $vmid not running\n" if !PVE::QemuServer::check_running($vmid, $nocheck);
>> +    my $to_disk_suspended;
>> +    eval {
>> +        PVE::QemuConfig->lock_config($vmid, sub {
>> +        my $conf = PVE::QemuConfig->load_config($vmid);
>> +        $to_disk_suspended = PVE::QemuConfig->has_lock($conf, 'suspended');
>> +        });
>> +    };
>> +
>> +    die "VM $vmid not running\n"
>> +        if !$to_disk_suspended && !PVE::QemuServer::check_running($vmid, $nocheck);
>>         my $realcmd = sub {
>>           my $upid = shift;
>>             syslog('info', "resume VM $vmid: $upid\n");
>>   -        PVE::QemuServer::vm_resume($vmid, $skiplock, $nocheck);
>> +        if (!$to_disk_suspended) {
>> +        PVE::QemuServer::vm_resume($vmid, $skiplock, $nocheck);
>> +        } else {
>> +        my $storecfg = PVE::Storage::config();
>> +        PVE::QemuServer::vm_start($storecfg, $vmid, undef, $skiplock);
>> +        }
>>             return;
>>       };
>>





More information about the pve-devel mailing list