From d607c17d4d1df7e5c2ce75ab6d5a82360f625f8e Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 4 Nov 2015 11:48:44 +0100 Subject: [PATCH] destroy: check if container is still running --- debian/changelog | 2 ++ src/PVE/API2/LXC.pm | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/debian/changelog b/debian/changelog index 3f5079f..d9aa3d6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ pve-container (1.0-21) unstable; urgency=medium * allow debian stretch/sid containers + * destroy: check if container is still running + -- Proxmox Support Team Wed, 04 Nov 2015 11:23:00 +0100 pve-container (1.0-20) unstable; urgency=medium diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm index 1e49d89..a4e80ec 100644 --- a/src/PVE/API2/LXC.pm +++ b/src/PVE/API2/LXC.pm @@ -493,11 +493,17 @@ __PACKAGE__->register_method({ die "unable to remove CT $vmid - used in HA resources\n" if PVE::HA::Config::vm_is_ha_managed($vmid); + my $running_error_msg = "unable to destroy CT $vmid - container is running\n"; + + die $running_error_msg if PVE::LXC::check_running($vmid); # check early + my $code = sub { # reload config after lock $conf = PVE::LXC::load_config($vmid); PVE::LXC::check_lock($conf); + die $running_error_msg if PVE::LXC::check_running($vmid); + PVE::LXC::destroy_lxc_container($storage_cfg, $vmid, $conf); PVE::AccessControl::remove_vm_access($vmid); PVE::Firewall::remove_vmfw_conf($vmid); -- 2.39.2