[pve-devel] [PATCH pve-container v3 1/1] fix #4228: add start parameter to rollback endpoint for automatic restarting of CT

Stefan Hanreich s.hanreich at proxmox.com
Wed Sep 14 10:30:52 CEST 2022


Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
---
 src/PVE/API2/LXC/Snapshot.pm | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/PVE/API2/LXC/Snapshot.pm b/src/PVE/API2/LXC/Snapshot.pm
index 4be16ad..0999fbc 100644
--- a/src/PVE/API2/LXC/Snapshot.pm
+++ b/src/PVE/API2/LXC/Snapshot.pm
@@ -272,6 +272,12 @@ __PACKAGE__->register_method({
 	    node => get_standard_option('pve-node'),
 	    vmid => get_standard_option('pve-vmid'),
 	    snapname => get_standard_option('pve-snapshot-name'),
+	    start => {
+		type => 'boolean',
+		description => "Whether the container should get started after rolling back successfully",
+		optional => 1,
+		default => 0,
+	    },
 	},
     },
     returns => {
@@ -294,6 +300,10 @@ __PACKAGE__->register_method({
 	my $realcmd = sub {
 	    PVE::Cluster::log_msg('info', $authuser, "rollback snapshot LXC $vmid: $snapname");
 	    PVE::LXC::Config->snapshot_rollback($vmid, $snapname);
+
+	    if ($param->{start}) {
+		PVE::API2::LXC::Status->vm_start({ vmid => $vmid, node => $node })
+	    }
 	};
 
 	my $worker = sub {
-- 
2.30.2





More information about the pve-devel mailing list