Source: lxc Severity: wishlist Tags: patch upstream Hi maintainer, by using different virtualization system one get used to call "destroy" the action of stopping a vm. In lxc context destroy really means to remove the container.
It would be nice to actually requiring something like -y to really remove the container. I known this kind of change can break scripts and may not be easy accepted, but I think it can avoid some headaches. I've attached a proposted patch Regards -- System Information: Debian Release: jessie/sid APT prefers unstable APT policy: (500, 'unstable') Architecture: amd64 (x86_64) Kernel: Linux 3.2.0-4-amd64 (SMP w/8 CPU cores) Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) Shell: /bin/sh linked to /bin/bash
--- /usr/bin/lxc-destroy.orig 2013-11-05 01:16:06.326585022 +0100 +++ /usr/bin/lxc-destroy 2013-11-05 01:18:41.422587740 +0100 @@ -26,7 +26,7 @@ # usage() { - echo "usage: $(basename $0) -n NAME [-f]" >&2 + echo "usage: $(basename $0) -n NAME [-f] -y" >&2 } help() { @@ -37,6 +37,7 @@ echo "Options:" >&2 echo " -n NAME specify the name of the container" >&2 echo " -f stop the container if it is running (rather than abort)" >&2 + echo " -y required to actually remove the container" >&2 } usage_err() { @@ -53,6 +54,7 @@ . /usr/share/lxc/lxc.functions force=0 +really=0 while [ $# -gt 0 ]; do opt="$1" @@ -70,6 +72,9 @@ -f) force=1 ;; + -y) + really=1 + ;; --) break ;; @@ -103,6 +108,11 @@ exit 1 fi +if [ ! $really -eq 1 ]; then + echo "$(basename $0): -y is required to actually delete the container" + exit 1 +fi + # make sure the container is stopped if ! lxc-info -n $lxc_name --state-is "STOPPED"; then if [ $force -eq 1 ]; then