]> git.proxmox.com Git - qemu-server.git/commitdiff
fix #4228: add start parameter to rollback endpoint for automatic restarting of VM
authorStefan Hanreich <s.hanreich@proxmox.com>
Wed, 14 Sep 2022 08:30:53 +0000 (10:30 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 8 Nov 2022 17:15:49 +0000 (18:15 +0100)
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
PVE/API2/Qemu.pm

index 20fd40af7a32632191d2145a69726bb35eb7e301..a539b5cce363d1f579257ac2a7aa820df86a8165 100644 (file)
@@ -4875,6 +4875,12 @@ __PACKAGE__->register_method({
            node => get_standard_option('pve-node'),
            vmid => get_standard_option('pve-vmid', { completion => \&PVE::QemuServer::complete_vmid }),
            snapname => get_standard_option('pve-snapshot-name'),
+           start => {
+               type => 'boolean',
+               description => "Whether the VM should get started after rolling back successfully",
+               optional => 1,
+               default => 0,
+           },
        },
     },
     returns => {
@@ -4897,6 +4903,10 @@ __PACKAGE__->register_method({
        my $realcmd = sub {
            PVE::Cluster::log_msg('info', $authuser, "rollback snapshot VM $vmid: $snapname");
            PVE::QemuConfig->snapshot_rollback($vmid, $snapname);
+
+           if ($param->{start}) {
+               PVE::API2::Qemu->vm_start({ vmid => $vmid, node => $node });
+           }
        };
 
        my $worker = sub {