The new `overrule-shutdown` parameter is boolean and defaults to 0. If it is 1, all active `vzshutdown` tasks by the current user for the same CT are aborted before attempting to stop the CT.
Passing `overrule-shutdown=1` is forbidden for HA resources. Signed-off-by: Friedrich Weber <f.we...@proxmox.com> --- src/PVE/API2/LXC/Status.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/PVE/API2/LXC/Status.pm b/src/PVE/API2/LXC/Status.pm index f7e3128..d1d67f4 100644 --- a/src/PVE/API2/LXC/Status.pm +++ b/src/PVE/API2/LXC/Status.pm @@ -221,6 +221,12 @@ __PACKAGE__->register_method({ node => get_standard_option('pve-node'), vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid_running }), skiplock => get_standard_option('skiplock'), + 'overrule-shutdown' => { + description => "Abort any active 'vzshutdown' task by the current user for this CT before stopping", + optional => 1, + type => 'boolean', + default => 0, + } }, }, returns => { @@ -238,10 +244,15 @@ __PACKAGE__->register_method({ raise_param_exc({ skiplock => "Only root may use this option." }) if $skiplock && $authuser ne 'root@pam'; + my $overrule_shutdown = extract_param($param, 'overrule-shutdown'); + die "CT $vmid not running\n" if !PVE::LXC::check_running($vmid); if (PVE::HA::Config::vm_is_ha_managed($vmid) && $rpcenv->{type} ne 'ha') { + raise_param_exc({ 'overrule-shutdown' => "Not applicable for HA resources." }) + if $overrule_shutdown; + my $hacmd = sub { my $upid = shift; @@ -272,6 +283,11 @@ __PACKAGE__->register_method({ return $rpcenv->fork_worker('vzstop', $vmid, $authuser, $realcmd); }; + if ($overrule_shutdown) { + my $overruled_tasks = PVE::GuestHelpers::overrule_tasks('vzshutdown', $authuser, $vmid); + syslog('info', "overruled vzshutdown tasks: " . join(", ", $overruled_tasks->@*) . "\n"); + }; + return PVE::LXC::Config->lock_config($vmid, $lockcmd); } }}); -- 2.30.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel