]> git.proxmox.com Git - pve-container.git/commitdiff
destroy: check if container is still running
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 4 Nov 2015 10:48:44 +0000 (11:48 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 4 Nov 2015 10:48:44 +0000 (11:48 +0100)
debian/changelog
src/PVE/API2/LXC.pm

index 3f5079fb77c7c41276aba7983d9a2c7918d35736..d9aa3d6c5edf3dae73067d047592ce181f669a19 100644 (file)
@@ -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 <support@proxmox.com>  Wed, 04 Nov 2015 11:23:00 +0100
 
 pve-container (1.0-20) unstable; urgency=medium
index 1e49d890d9aacdebb42e313cd9b216bfce9a7c63..a4e80ec7ac4592f088ef4b6707dd52a9f0f00511 100644 (file)
@@ -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);