[pve-devel] [PATCH v2 container] fix #3927: Containers that are already stopped now return 0, like VMs

Daniel Tschlatscher d.tschlatscher at proxmox.com
Thu Mar 17 13:16:51 CET 2022


Signed-off-by: Daniel Tschlatscher <d.tschlatscher at proxmox.com>
---
Fixed indentation and trailing whitespace
 src/PVE/API2/LXC/Status.pm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/LXC/Status.pm b/src/PVE/API2/LXC/Status.pm
index f7e3128..d4e0b66 100644
--- a/src/PVE/API2/LXC/Status.pm
+++ b/src/PVE/API2/LXC/Status.pm
@@ -238,7 +238,11 @@ __PACKAGE__->register_method({
 	raise_param_exc({ skiplock => "Only root may use this option." })
 	    if $skiplock && $authuser ne 'root at pam';
 
-	die "CT $vmid not running\n" if !PVE::LXC::check_running($vmid);
+	# Containers that are already stopped should exit with code 0, like VMs do
+	if (!PVE::LXC::check_running($vmid)) {
+	    print "CT $vmid not running\n";
+	    exit 0;
+	}
 
 	if (PVE::HA::Config::vm_is_ha_managed($vmid) && $rpcenv->{type} ne 'ha') {
 
-- 
2.30.2





More information about the pve-devel mailing list