]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Replace create/destroy by a script
authorDaniel Lezcano <daniel.lezcano@free.fr>
Fri, 13 Nov 2009 10:48:29 +0000 (11:48 +0100)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Fri, 13 Nov 2009 10:48:29 +0000 (11:48 +0100)
The simplification of the container configuration makes
pointless to have so much complexity in the container creation.
Let's remove that and replace by some scripts.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
12 files changed:
configure.ac
src/lxc/Makefile.am
src/lxc/conf.c
src/lxc/conf.h
src/lxc/create.c [deleted file]
src/lxc/destroy.c [deleted file]
src/lxc/lxc-create.in [new file with mode: 0644]
src/lxc/lxc-destroy.in [new file with mode: 0644]
src/lxc/lxc.h
src/lxc/lxc_create.c [deleted file]
src/lxc/lxc_destroy.c [deleted file]
src/lxc/start.c

index a9ca2118c1f5c4f5f1ef0b211d191e99f3ddb7c2..75c8fd0ccbb731bcad68bd2688cf8b128a8d5556 100644 (file)
@@ -100,6 +100,8 @@ AC_CONFIG_FILES([
        src/lxc/lxc-checkconfig
        src/lxc/lxc-setcap
        src/lxc/lxc-version
+       src/lxc/lxc-create
+       src/lxc/lxc-destroy
 
        etc/Makefile
        etc/lxc-macvlan.conf
index 7b63f1890ce9414e03f0c202c2125fe38e03ea43..6840e156e13c1a53abf8b92f1fc0a5f6d165f19a 100644 (file)
@@ -18,8 +18,6 @@ so_PROGRAMS = liblxc.so
 liblxc_so_SOURCES = \
        arguments.c arguments.h \
        commands.c commands.h \
-       create.c \
-       destroy.c \
        start.c \
        stop.c \
        monitor.c monitor.h \
@@ -65,12 +63,12 @@ bin_SCRIPTS = \
        lxc-ls \
        lxc-checkconfig \
        lxc-setcap \
-       lxc-version
+       lxc-version \
+       lxc-create \
+       lxc-destroy
 
 bin_PROGRAMS = \
        lxc-unshare \
-       lxc-create \
-       lxc-destroy \
        lxc-stop \
        lxc-start \
        lxc-execute \
@@ -93,8 +91,6 @@ LDADD=liblxc.so
 lxc_cgroup_SOURCES = lxc_cgroup.c
 lxc_checkpoint_SOURCES = lxc_checkpoint.c
 lxc_console_SOURCES = lxc_console.c
-lxc_create_SOURCES = lxc_create.c
-lxc_destroy_SOURCES = lxc_destroy.c
 lxc_execute_SOURCES = lxc_execute.c
 lxc_freeze_SOURCES = lxc_freeze.c
 lxc_info_SOURCES = lxc_info.c
index 25204e49b899bc3ccf1c5bd91dcbc988066bfcd9..4c74734ab0b78da41a48e0595463ef233c92f400 100644 (file)
@@ -108,17 +108,6 @@ static struct mount_opt mount_opt[] = {
        { NULL,         0, 0              },
 };
 
-static int delete_info(const char *path, const char *file)
-{
-       char info[MAXPATHLEN];
-       int ret;
-
-       snprintf(info, MAXPATHLEN, "%s/%s", path, file);
-       ret = unlink(info);
-
-       return ret;
-}
-
 static int configure_find_fstype_cb(void* buffer, void *data)
 {
        struct cbarg {
@@ -301,136 +290,6 @@ static int configure_rootfs(const char *name, const char *rootfs)
        return -1;
 }
 
-static int unconfigure_ip_addresses(const char *directory)
-{
-       char path[MAXPATHLEN];
-
-       snprintf(path, MAXPATHLEN, "%s/ipv4", directory);
-       delete_info(path, "addresses");
-       rmdir(path);
-
-       snprintf(path, MAXPATHLEN, "%s/ipv6", directory);
-       delete_info(path, "addresses");
-       rmdir(path);
-
-       return 0;
-}
-
-static int unconfigure_network_cb(const char *name, const char *directory,
-                                 const char *file, void *data)
-{
-       char path[MAXPATHLEN];
-
-       snprintf(path, MAXPATHLEN, "%s/%s", directory, file);
-       delete_info(path, "ifindex");
-       delete_info(path, "name");
-       delete_info(path, "addr");
-       delete_info(path, "link");
-       delete_info(path, "hwaddr");
-       delete_info(path, "mtu");
-       delete_info(path, "up");
-       unconfigure_ip_addresses(path);
-       rmdir(path);
-
-       return 0;
-}
-
-static int unconfigure_network(const char *name)
-{
-       char directory[MAXPATHLEN];
-
-       snprintf(directory, MAXPATHLEN, LXCPATH "/%s/network", name);
-       lxc_dir_for_each(name, directory, unconfigure_network_cb, NULL);
-       rmdir(directory);
-
-       return 0;
-}
-
-static int unconfigure_cgroup_cb(const char *name, const char *directory,
-                                 const char *file, void *data)
-{
-       return delete_info(directory, file);
-}
-
-static int unconfigure_cgroup(const char *name)
-{
-       char filename[MAXPATHLEN];
-       struct stat s;
-
-       snprintf(filename, MAXPATHLEN, LXCPATH "/%s/cgroup", name);
-
-       if (stat(filename, &s)) {
-               SYSERROR("failed to stat '%s'", filename);
-               return -1;
-       }
-
-       if (S_ISDIR(s.st_mode)) {
-               /* old cgroup configuration */
-               lxc_dir_for_each(name, filename, unconfigure_cgroup_cb, NULL);
-               rmdir(filename);
-       } else {
-               unlink(filename);
-       }
-
-       return 0;
-}
-
-static int unconfigure_rootfs(const char *name)
-{
-       char path[MAXPATHLEN];
-
-       snprintf(path, MAXPATHLEN, LXCPATH "/%s/rootfs", name);
-
-#warning deprecated code to be removed in the next version
-
-       /* ugly but for backward compatibily, */
-       delete_info(path, "rootfs");
-       rmdir(path);
-       unlink(path);
-
-       return 0;
-}
-
-static int unconfigure_pts(const char *name)
-{
-       char path[MAXPATHLEN];
-
-       snprintf(path, MAXPATHLEN, LXCPATH "/%s", name);
-       delete_info(path, "pts");
-
-       return 0;
-}
-
-static int unconfigure_tty(const char *name)
-{
-       char path[MAXPATHLEN];
-
-       snprintf(path, MAXPATHLEN, LXCPATH "/%s", name);
-       delete_info(path, "tty");
-
-       return 0;
-}
-
-static int unconfigure_mount(const char *name)
-{
-       char path[MAXPATHLEN];
-
-       snprintf(path, MAXPATHLEN, LXCPATH "/%s", name);
-       delete_info(path, "fstab");
-
-       return 0;
-}
-
-static int unconfigure_utsname(const char *name)
-{
-       char path[MAXPATHLEN];
-
-       snprintf(path, MAXPATHLEN, LXCPATH "/%s", name);
-       delete_info(path, "utsname");
-
-       return 0;
-}
-
 static int setup_utsname(struct utsname *utsname)
 {
        if (!utsname)
@@ -929,32 +788,6 @@ int lxc_conf_init(struct lxc_conf *conf)
        return 0;
 }
 
-int lxc_unconfigure(const char *name)
-{
-       if (conf_has_utsname(name) && unconfigure_utsname(name))
-               ERROR("failed to cleanup utsname");
-
-       if (conf_has_network(name) && unconfigure_network(name))
-               ERROR("failed to cleanup the network");
-
-       if (conf_has_cgroup(name) && unconfigure_cgroup(name))
-               ERROR("failed to cleanup cgroup");
-
-       if (conf_has_tty(name) && unconfigure_tty(name))
-               ERROR("failed to cleanup tty");
-
-       if (conf_has_rootfs(name) && unconfigure_rootfs(name))
-               ERROR("failed to cleanup rootfs");
-
-       if (conf_has_fstab(name) && unconfigure_mount(name))
-               ERROR("failed to cleanup mount");
-
-       if (conf_has_pts(name) && unconfigure_pts(name))
-               ERROR("failed to cleanup pts");
-
-       return 0;
-}
-
 static int instanciate_veth(struct lxc_netdev *netdev)
 {
        char veth1[IFNAMSIZ];
index c6e049663d7d03ef5e7ff195c362344150fc6d67..aeb799c72a811b04bcff832da001d7149b34004f 100644 (file)
@@ -145,11 +145,6 @@ struct lxc_conf {
  */
 extern int lxc_conf_init(struct lxc_conf *conf);
 
-/*
- * Remove the resources created by the configuration
- */
-extern int lxc_unconfigure(const char *name);
-
 extern int lxc_create_network(struct lxc_list *networks);
 extern int lxc_assign_network(struct lxc_list *networks, pid_t pid);
 
diff --git a/src/lxc/create.c b/src/lxc/create.c
deleted file mode 100644 (file)
index 881caef..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * lxc: linux Container library
- *
- * (C) Copyright IBM Corp. 2007, 2008
- *
- * Authors:
- * Daniel Lezcano <dlezcano at fr.ibm.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#define _GNU_SOURCE
-#include <stdio.h>
-#undef _GNU_SOURCE
-#include <stdlib.h>
-#include <string.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include "error.h"
-#include <lxc/lxc.h>
-#include <lxc/log.h>
-
-#include "config.h"
-
-lxc_log_define(lxc_create, lxc);
-
-static int dir_filter(const struct dirent *dirent)
-{
-       if (!strcmp(dirent->d_name, ".") ||
-            !strcmp(dirent->d_name, ".."))
-                return 0;
-        return 1;
-}
-
-static int is_empty_directory(const char *dirname)
-{
-       struct dirent **namelist;
-       int n;
-
-       n = scandir(dirname, &namelist, dir_filter, alphasort);
-       if (n < 0)
-               SYSERROR("failed to scan %s directory", dirname);
-       return n == 0;
-}
-
-static int create_lxc_directory(const char *dirname)
-{
-       char path[MAXPATHLEN];
-
-       if (mkdir(LXCPATH, 0755) && errno != EEXIST) {
-               SYSERROR("failed to create %s directory", LXCPATH);
-               return -1;
-       }
-
-       snprintf(path, MAXPATHLEN, LXCPATH "/%s", dirname);
-
-       if (mkdir(path, 0755)) {
-               SYSERROR("failed to create %s directory", path);
-               return -1;
-       }
-
-       return 0;
-}
-
-static int remove_lxc_directory(const char *dirname)
-{
-       char path[MAXPATHLEN];
-
-       snprintf(path, MAXPATHLEN, LXCPATH "/%s", dirname);
-
-       if (rmdir(path)) {
-               SYSERROR("failed to remove %s directory", path);
-               return -1;
-       }
-
-       if (is_empty_directory(LXCPATH)) {
-               if (rmdir(LXCPATH)) {
-                       SYSERROR("failed to remove %s directory", LXCPATH);
-                       return -1;
-               }
-       }
-
-       return 0;
-}
-
-static int copy_config_file(const char *name, const char *file)
-{
-       char *dst;
-       int ret = -1;
-
-       if (!asprintf(&dst, LXCPATH "/%s/config", name)) {
-               ERROR("failed to allocate memory");
-               return -1;
-       }
-
-       ret = lxc_copy_file(file, dst);
-       if (ret)
-               ERROR("failed to copy '%s' to '%s'", file, dst);
-
-       free(dst);
-
-       return ret;
-}
-
-int lxc_create(const char *name, const char *confile)
-{
-       int err = -1;
-
-       if (create_lxc_directory(name))
-               return err;
-       
-       if (!confile)
-               return 0;
-
-       if (copy_config_file(name, confile)) {
-               ERROR("failed to copy the configuration file");
-               goto err;
-       }
-
-       err = 0;
-out:
-       return err;
-
-err:
-       lxc_unconfigure(name);
-
-       if (lxc_rmstate(name))
-               ERROR("failed to remove state file for %s", name);
-
-       if (remove_lxc_directory(name))
-               ERROR("failed to cleanup lxc directory for %s", name);
-       goto out;
-}
diff --git a/src/lxc/destroy.c b/src/lxc/destroy.c
deleted file mode 100644 (file)
index 953e93b..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * lxc: linux Container library
- *
- * (C) Copyright IBM Corp. 2007, 2008
- *
- * Authors:
- * Daniel Lezcano <dlezcano at fr.ibm.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/param.h>
-
-#include "error.h"
-#include <lxc/lxc.h>
-#include <lxc/log.h>
-
-#include "config.h"
-
-lxc_log_define(lxc_destroy, lxc);
-
-static int remove_lxc_directory(const char *dirname)
-{
-       char path[MAXPATHLEN];
-
-       snprintf(path, MAXPATHLEN, LXCPATH "/%s", dirname);
-
-       if (rmdir(path)) {
-               SYSERROR("failed to remove %s directory", path);
-               return -1;
-       }
-
-       return 0;
-}
-
-static int remove_config_file(const char *name)
-{
-       char path[MAXPATHLEN];
-
-       snprintf(path, MAXPATHLEN, LXCPATH "/%s/config", name);
-
-       /* config file does not exists */
-       if (access(path, F_OK))
-               return 0;
-
-       if (unlink(path)) {
-               ERROR("failed to unlink '%s'", path);
-               return -1;
-       }
-
-       return 0;
-}
-
-int lxc_destroy(const char *name)
-{
-       int ret = -1;
-       char path[MAXPATHLEN];
-
-       if (remove_config_file(name))
-               WARN("failed to remove the configuration file");
-
-       if (lxc_rmstate(name)) {
-               ERROR("failed to remove state file for %s", name);
-               return -1;
-       }
-       
-#warning keep access to LXCPATH/<name> to destroy old created container
-       snprintf(path, MAXPATHLEN, LXCPATH "/%s/init", name);
-       unlink(path);
-
-       snprintf(path, MAXPATHLEN, LXCPATH "/%s/nsgroup", name);
-       unlink(path);
-
-       if (lxc_unconfigure(name)) {
-               ERROR("failed to cleanup %s", name);
-               return -1;
-       }
-
-       if (remove_lxc_directory(name)) {
-               SYSERROR("failed to remove '%s'", name);
-               return -1;
-       }
-
-       return 0;
-}
diff --git a/src/lxc/lxc-create.in b/src/lxc/lxc-create.in
new file mode 100644 (file)
index 0000000..115e52d
--- /dev/null
@@ -0,0 +1,97 @@
+#!/bin/bash
+
+#
+# lxc: linux Container library
+
+# Authors:
+# Daniel Lezcano <daniel.lezcano@free.fr>
+
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#
+# This script allows to set or remove the capabilities on the lxc tools.
+# When the capabilities are set, a non root user can manage the containers.
+#
+
+usage() {
+    echo "usage: $0 -n <name> [-f configuration]"
+}
+
+if [ "$(id -u)" != "0" ]; then
+   echo "This command has to be run as root"
+   exit 1
+fi
+
+shortoptions='n:f:'
+longoptions='name:,config:'
+lxc_path=@LXCPATH@
+
+getopt=$(getopt -o $shortoptions --longoptions  $longoptions -- "$@")
+if [ $? != 0 ]; then
+    usage $0
+    exit 1;
+fi
+
+eval set -- "$getopt"
+
+while true; do
+        case "$1" in
+           -n|--name)
+               shift
+               lxc_name=$1
+               shift
+               ;;
+           -f|--config)
+               shift
+               lxc_config=$1
+               shift
+               ;;
+            --)
+               shift
+               break;;
+            *)
+               echo $1
+               usage $0
+               exit 1
+               ;;
+        esac
+done
+
+if [ ! -r $lxc_path ]; then
+    echo "no configuration path defined !"
+    exit 1
+fi
+
+if [ -z "$lxc_name" ]; then
+    echo "no container name specified"
+    usage $0
+    exit 1
+fi
+
+if [ -f "$lxc_path/$lxc_name" ]; then
+    echo "'$lxc_name' already exists"
+    exit 1
+fi
+
+if [ -z "$lxc_config" ]; then
+    touch $lxc_path/$lxc_name
+else
+    if [ ! -r "$lxc_config" ]; then
+       echo "'$lxc_config' configuration file not found"
+       exit 1
+    fi
+
+    cp $lxc_config $lxc_path/$lxc_name
+fi
\ No newline at end of file
diff --git a/src/lxc/lxc-destroy.in b/src/lxc/lxc-destroy.in
new file mode 100644 (file)
index 0000000..18d95b8
--- /dev/null
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+#
+# lxc: linux Container library
+
+# Authors:
+# Daniel Lezcano <daniel.lezcano@free.fr>
+
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#
+# This script allows to set or remove the capabilities on the lxc tools.
+# When the capabilities are set, a non root user can manage the containers.
+#
+
+usage() {
+    echo "usage: $0 -n <name>"
+}
+
+if [ "$(id -u)" != "0" ]; then
+   echo "This command has to be run as root"
+   exit 1
+fi
+
+shortoptions='n:'
+longoptions='name:'
+lxc_path=@LXCPATH@
+
+getopt=$(getopt -o $shortoptions --longoptions  $longoptions -- "$@")
+if [ $? != 0 ]; then
+    usage $0
+    exit 1;
+fi
+
+eval set -- "$getopt"
+
+while true; do
+        case "$1" in
+           -n|--name)
+               shift
+               lxc_name=$1
+               shift
+               ;;
+            --)
+               shift
+               break;;
+            *)
+               echo $1
+               usage $0
+               exit 1
+               ;;
+        esac
+done
+
+if [ -z "$lxc_name" ]; then
+    echo "no container name specified"
+    usage $0
+    exit 1
+fi
+
+if [ ! -f "$lxc_path/$lxc_name" ]; then
+    echo "'$lxc_name' does not exist"
+    exit 1
+fi
+
+# recursively remove the container to remove old container configuration
+rm -rf --preserve-root $lxc_path/$lxc_name
index 95e2347ba122588c8c4440594188292224b9c3ac..1d04b9f2e9d98b951689a1d50b997fb8b4bd625b 100644 (file)
@@ -45,28 +45,7 @@ extern "C" {
 #include <lxc/start.h>
 
 /*
- * Create the container object. Creates the /lxc/<name> directory
- * and fills it with the files corresponding to the configuration
- * structure passed as parameter.
- * The first container will create the /lxc directory.
- * @name : the name of the container
- * @conf : the configuration data for the container
- * Returns 0 on success, < 0 otherwise
- */
-extern int lxc_create(const char *name, const char *confile);
-
-/*
- * Destroy the container object. Removes the files into the /lxc/<name>
- * directory and removes the <name> directory.
- * The last container will remove the /lxc directory.
- * @name : the name of the container to be detroyed
- * Returns 0 on success, < 0 otherwise
- */
-extern int lxc_destroy(const char *name);
-
-/*
- * Start the specified command inside a container which has
- * been created before with lxc_create.
+ * Start the specified command inside a container
  * @name     : the name of the container
  * @argv     : an array of char * corresponding to the commande line
  * Returns 0 on sucess, < 0 otherwise
diff --git a/src/lxc/lxc_create.c b/src/lxc/lxc_create.c
deleted file mode 100644 (file)
index 39cbaf5..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * lxc: linux Container library
- *
- * (C) Copyright IBM Corp. 2007, 2008
- *
- * Authors:
- * Daniel Lezcano <dlezcano at fr.ibm.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <libgen.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/param.h>
-#include <sys/utsname.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <net/if.h>
-
-#include <lxc/lxc.h>
-#include "confile.h"
-#include "arguments.h"
-
-lxc_log_define(lxc_create, lxc);
-
-static int my_parser(struct lxc_arguments* args, int c, char* arg)
-{
-       switch (c) {
-       case 'f': args->rcfile = arg; break;
-       }
-       return 0;
-}
-
-static const struct option my_longopts[] = {
-       {"rcfile", required_argument, 0, 'f'},
-       LXC_COMMON_OPTIONS
-};
-
-static struct lxc_arguments my_args = {
-       .progname = "lxc-create",
-       .help     = "\
---name=NAME\n\
-\n\
-lxc-create creates a container with the identifier NAME\n\
-\n\
-Options :\n\
-  -n, --name=NAME      NAME for name of the container\n\
-  -f, --rcfile=FILE    Load configuration file FILE\n",
-       .options  = my_longopts,
-       .parser   = my_parser,
-       .checker  = NULL,
-};
-
-int main(int argc, char *argv[])
-{
-       struct lxc_conf lxc_conf;
-       int ret;
-
-       ret = lxc_arguments_parse(&my_args, argc, argv);
-       if (ret)
-               return -1;
-
-       if (lxc_log_init(my_args.log_file, my_args.log_priority,
-                        my_args.progname, my_args.quiet))
-               return -1;
-
-       if (lxc_conf_init(&lxc_conf))
-               return -1;
-
-       if (my_args.rcfile && lxc_config_read(my_args.rcfile, &lxc_conf)) {
-               ERROR("failed to read the configuration file");
-               return -1;
-       }
-
-       if (lxc_create(my_args.name, my_args.rcfile)) {
-               ERROR("failed to create the container");
-               return -1;
-       }
-
-       INFO("'%s' created", my_args.name);
-
-       return 0;
-}
-
diff --git a/src/lxc/lxc_destroy.c b/src/lxc/lxc_destroy.c
deleted file mode 100644 (file)
index 89b7e34..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * lxc: linux Container library
- *
- * (C) Copyright IBM Corp. 2007, 2008
- *
- * Authors:
- * Daniel Lezcano <dlezcano at fr.ibm.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/types.h>
-
-#include <lxc/lxc.h>
-#include "arguments.h"
-
-lxc_log_define(lxc_destroy, lxc);
-
-static const struct option my_longopts[] = {
-       LXC_COMMON_OPTIONS
-};
-
-static struct lxc_arguments my_args = {
-       .progname = "lxc-destroy",
-       .help     = "\
---name=NAME\n\
-\n\
-lxc-destroy destroy a container with the identifier NAME\n\
-\n\
-Options :\n\
-  -n, --name=NAME   NAME for name of the container\n",
-       .options  = my_longopts,
-       .parser   = NULL,
-       .checker  = NULL,
-};
-
-int main(int argc, char *argv[])
-{
-       if (lxc_arguments_parse(&my_args, argc, argv))
-               return -1;
-
-       if (lxc_log_init(my_args.log_file, my_args.log_priority,
-                        my_args.progname, my_args.quiet))
-               return -1;
-
-       if (lxc_destroy(my_args.name)) {
-               ERROR("failed to destroy the container");
-               return -1;
-       }
-
-       INFO("'%s' destroyed", my_args.name);
-
-       return 0;
-}
-
index 90300719cdb12e57ba7614c662135b9366481686..e190406a12bbb1a93dcc1d2a30b8ad2a1fe9a562 100644 (file)
@@ -183,14 +183,6 @@ out_sigfd:
        goto out;
 }
 
-static void remove_init_pid(const char *name, pid_t pid)
-{
-       char init[MAXPATHLEN];
-
-       snprintf(init, MAXPATHLEN, LXCPATH "/%s/init", name);
-       unlink(init);
-}
-
 static int fdname(int fd, char *name, size_t size)
 {
        char path[MAXPATHLEN];
@@ -317,7 +309,6 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
        lxc_unlink_nsgroup(name);
 
        if (handler) {
-               remove_init_pid(name, handler->pid);
                lxc_delete_tty(&handler->conf.tty_info);
                free(handler);
        }