aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@free.fr>2009-11-13 11:48:29 +0100
committerDaniel Lezcano <dlezcano@fr.ibm.com>2009-11-13 11:48:29 +0100
commitab2d32f88ce27337a1b429e32058f0948cb72bf0 (patch)
treef9c4cd4ea588bae69ef732a8940c6d6c141ab2a1
parentAllows a container to run without previous creation (diff)
downloadlxc-ab2d32f88ce27337a1b429e32058f0948cb72bf0.tar.gz
lxc-ab2d32f88ce27337a1b429e32058f0948cb72bf0.tar.bz2
lxc-ab2d32f88ce27337a1b429e32058f0948cb72bf0.zip
Replace create/destroy by a script
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>
-rw-r--r--configure.ac2
-rw-r--r--src/lxc/Makefile.am10
-rw-r--r--src/lxc/conf.c167
-rw-r--r--src/lxc/conf.h5
-rw-r--r--src/lxc/create.c149
-rw-r--r--src/lxc/destroy.c103
-rw-r--r--src/lxc/lxc-create.in97
-rw-r--r--src/lxc/lxc-destroy.in79
-rw-r--r--src/lxc/lxc.h23
-rw-r--r--src/lxc/lxc_create.c100
-rw-r--r--src/lxc/lxc_destroy.c69
-rw-r--r--src/lxc/start.c9
12 files changed, 182 insertions, 631 deletions
diff --git a/configure.ac b/configure.ac
index a9ca211..75c8fd0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am
index 7b63f18..6840e15 100644
--- a/src/lxc/Makefile.am
+++ b/src/lxc/Makefile.am
@@ -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
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 25204e4..4c74734 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -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];
diff --git a/src/lxc/conf.h b/src/lxc/conf.h
index c6e0496..aeb799c 100644
--- a/src/lxc/conf.h
+++ b/src/lxc/conf.h
@@ -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
index 881caef..0000000
--- a/src/lxc/create.c
+++ /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
index 953e93b..0000000
--- a/src/lxc/destroy.c
+++ /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
index 0000000..115e52d
--- /dev/null
+++ b/src/lxc/lxc-create.in
@@ -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
index 0000000..18d95b8
--- /dev/null
+++ b/src/lxc/lxc-destroy.in
@@ -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
diff --git a/src/lxc/lxc.h b/src/lxc/lxc.h
index 95e2347..1d04b9f 100644
--- a/src/lxc/lxc.h
+++ b/src/lxc/lxc.h
@@ -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
index 39cbaf5..0000000
--- a/src/lxc/lxc_create.c
+++ /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
index 89b7e34..0000000
--- a/src/lxc/lxc_destroy.c
+++ /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;
-}
-
diff --git a/src/lxc/start.c b/src/lxc/start.c
index 9030071..e190406 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -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);
}