[lxc-devel] [lxc/master] tree-wide: rm {lua, python3} bindings, rm deprecated binaries, add --{disable, enable}-{commands, tools} flag

brauner on Github lxc-bot at linuxcontainers.org
Wed Feb 14 10:57:17 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180214/0d1f5c86/attachment.bin>
-------------- next part --------------
From 468b8c51108083b85c400f4a87c43a68b88c015b Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 14 Feb 2018 11:33:33 +0100
Subject: [PATCH 1/4] autotools: add --{enable,disable}-{commands,tools}

This allows users to only compile the shared libray without having to compile
any of the command line tools or command helpers for the shared library.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 configure.ac        | 45 +++++++++++++++++++++++++++++++++
 doc/Makefile.am     | 73 +++++++++++++++++++++++++----------------------------
 src/lxc/Makefile.am | 23 +++++++++++++++--
 3 files changed, 100 insertions(+), 41 deletions(-)

diff --git a/configure.ac b/configure.ac
index 224e1f15e..9868ffe3f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -477,6 +477,18 @@ AM_COND_IF([ENABLE_BASH],
 	AC_SUBST(bashcompdir)
 	])
 
+# Build the command line tools
+AC_ARG_ENABLE([tools],
+	[AC_HELP_STRING([--enable-tools], [build the command line tools [default=yes]])],
+	[], [enable_tools=yes])
+AM_CONDITIONAL([ENABLE_TOOLS], [test "x$enable_tools" = "xyes"])
+
+# Build the liblxc commands
+AC_ARG_ENABLE([commands],
+	[AC_HELP_STRING([--enable-commands], [build the liblxc commands [default=yes]])],
+	[], [enable_commands=yes])
+AM_CONDITIONAL([ENABLE_COMMANDS], [test "x$enable_commands" = "xyes"])
+
 # Optional test binaries
 AC_ARG_ENABLE([tests],
 	[AC_HELP_STRING([--enable-tests], [build test/example binaries [default=no]])],
@@ -912,6 +924,39 @@ AC_OUTPUT
 cat << EOF
 
 ----------------------------
+Binaries
+ - Command Line Tools:
+   - lxc-attach:     $enable_tools
+   - lxc-autostart:  $enable_tools
+   - lxc-cgroup:     $enable_tools
+   - lxc-checkpoint: $enable_tools
+   - lxc-config:     $enable_tools
+   - lxc-console:    $enable_tools
+   - lxc-copy:       $enable_tools
+   - lxc-create:     $enable_tools
+   - lxc-destroy:    $enable_tools
+   - lxc-device:     $enable_tools
+   - lxc-execute:    $enable_tools
+   - lxc-freeze:     $enable_tools
+   - lxc-info:       $enable_tools
+   - lxc-ls:         $enable_tools
+   - lxc-monitor:    $enable_tools
+   - lxc-snapshot:   $enable_tools
+   - lxc-start:      $enable_tools
+   - lxc-stop:       $enable_tools
+   - lxc-top:        $enable_tools
+   - lxc-unfreeze:   $enable_tools
+   - lxc-unshare:    $enable_tools
+   - lxc-wait:       $enable_tools
+
+ - liblxc Commands:
+   - lxc-checkconfig:   $enable_commands
+   - lxc-update-config: $enable_commands
+   - lxc-init:          $enable_commands
+   - lxc-monitord:      $enable_commands
+   - lxc-user-nic:      $enable_commands
+   - lxc-usernsexec:    $enable_commands
+
 Environment:
  - compiler: $CC
  - distribution: $with_distro
diff --git a/doc/Makefile.am b/doc/Makefile.am
index ae023e411..2bf92a0a8 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -15,46 +15,41 @@ EXTRA_DIST = \
 	FAQ.txt
 
 if ENABLE_DOCBOOK
-man_MANS = \
-	lxc-attach.1 \
-	lxc-autostart.1 \
-	lxc-cgroup.1 \
-	lxc-checkconfig.1 \
-	lxc-checkpoint.1 \
-	lxc-config.1 \
-	lxc-console.1 \
-	lxc-copy.1 \
-	lxc-create.1 \
-	lxc-destroy.1 \
-	lxc-device.1 \
-	lxc-execute.1 \
-	lxc-freeze.1 \
-	lxc-info.1 \
-	lxc-ls.1 \
-	lxc-monitor.1 \
-	lxc-snapshot.1 \
-	lxc-start.1 \
-	lxc-stop.1 \
-	lxc-top.1 \
-	lxc-unfreeze.1 \
-	lxc-unshare.1 \
-	lxc-update-config.1 \
-	lxc-user-nic.1 \
-	lxc-usernsexec.1 \
-	lxc-wait.1 \
-	\
-	lxc.conf.5 \
-	lxc.container.conf.5 \
-	lxc.system.conf.5 \
-	lxc-usernet.5 \
-	\
-	lxc.7
-
-if ENABLE_DEPRECATED
-    man_MANS += lxc-clone.1
-if ENABLE_PYTHON
-    man_MANS += lxc-start-ephemeral.1
+man_MANS = lxc.conf.5 \
+	   lxc.container.conf.5 \
+	   lxc.system.conf.5 \
+	   lxc-usernet.5 \
+	   lxc.7
+if ENABLE_TOOLS
+man_MANS += lxc-attach.1 \
+	    lxc-autostart.1 \
+	    lxc-cgroup.1 \
+	    lxc-checkconfig.1 \
+	    lxc-checkpoint.1 \
+	    lxc-config.1 \
+	    lxc-console.1 \
+	    lxc-copy.1 \
+	    lxc-create.1 \
+	    lxc-destroy.1 \
+	    lxc-device.1 \
+	    lxc-execute.1 \
+	    lxc-freeze.1 \
+	    lxc-info.1 \
+	    lxc-ls.1 \
+	    lxc-monitor.1 \
+	    lxc-snapshot.1 \
+	    lxc-start.1 \
+	    lxc-stop.1 \
+	    lxc-top.1 \
+	    lxc-unfreeze.1 \
+	    lxc-unshare.1 \
+	    lxc-wait.1
 endif
+
+if ENABLE_COMMANDS
+man_MANS += lxc-update-config.1 \
+	    lxc-user-nic.1 \
+	    lxc-usernsexec.1
 endif
 
 %.1 : %.sgml
diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am
index 1cc986275..7f029de1f 100644
--- a/src/lxc/Makefile.am
+++ b/src/lxc/Makefile.am
@@ -201,9 +201,14 @@ liblxc_la_LDFLAGS = \
 
 liblxc_la_LIBADD = $(CAP_LIBS) $(SELINUX_LIBS) $(SECCOMP_LIBS)
 
-bin_SCRIPTS = cmd/lxc-checkconfig \
-	      cmd/lxc-update-config
+bin_SCRIPTS=
 
+if ENABLE_COMMANDS
+bin_SCRIPTS += cmd/lxc-checkconfig \
+	       cmd/lxc-update-config
+endif
+
+if ENABLE_TOOLS
 EXTRA_DIST = \
 	tools/lxc-top.lua
 
@@ -212,7 +217,9 @@ if ENABLE_PYTHON
 bin_SCRIPTS += tools/lxc-start-ephemeral
 endif
 endif
+endif
 
+if ENABLE_TOOLS
 bin_PROGRAMS = \
 	lxc-attach \
 	lxc-autostart \
@@ -241,11 +248,14 @@ bin_PROGRAMS = \
 if ENABLE_DEPRECATED
 bin_PROGRAMS += lxc-clone
 endif
+endif
 
+if ENABLE_COMMANDS
 sbin_PROGRAMS = init.lxc
 pkglibexec_PROGRAMS = \
 	lxc-monitord \
 	lxc-user-nic
+endif
 
 AM_LDFLAGS = -Wl,-E
 if ENABLE_RPATH
@@ -253,6 +263,7 @@ AM_LDFLAGS += -Wl,-rpath -Wl,$(libdir)
 endif
 LDADD=liblxc.la @CAP_LIBS@ @SELINUX_LIBS@ @SECCOMP_LIBS@
 
+if ENABLE_TOOLS
 lxc_attach_SOURCES = tools/lxc_attach.c tools/arguments.c tools/tool_utils.c
 lxc_autostart_SOURCES = tools/lxc_autostart.c tools/arguments.c tools/tool_utils.c
 lxc_cgroup_SOURCES = tools/lxc_cgroup.c tools/arguments.c tools/tool_utils.c
@@ -275,13 +286,18 @@ lxc_wait_SOURCES = tools/lxc_wait.c tools/arguments.c tools/tool_utils.c
 lxc_create_SOURCES = tools/lxc_create.c tools/arguments.c tools/tool_utils.c
 lxc_snapshot_SOURCES = tools/lxc_snapshot.c tools/arguments.c tools/tool_utils.c
 lxc_checkpoint_SOURCES = tools/lxc_checkpoint.c tools/arguments.c tools/tool_utils.c
+endif
 
+if ENABLE_COMMANDS
 # Binaries shipping with liblxc
 init_lxc_SOURCES = cmd/lxc_init.c
 lxc_monitord_SOURCES = cmd/lxc_monitord.c
 lxc_user_nic_SOURCES = cmd/lxc_user_nic.c namespace.c network.c
 lxc_usernsexec_SOURCES = cmd/lxc_usernsexec.c
+endif
+
 
+if ENABLE_TOOLS
 if ENABLE_DEPRECATED
 lxc_clone_SOURCES = tools/lxc_clone.c tools/arguments.c
 endif
@@ -289,7 +305,9 @@ endif
 if !HAVE_GETSUBOPT
 lxc_copy_SOURCES += tools/include/getsubopt.c tools/include/getsubopt.h
 endif
+endif
 
+if ENABLE_COMMANDS
 if HAVE_STATIC_LIBCAP
 sbin_PROGRAMS += init.lxc.static
 
@@ -305,6 +323,7 @@ init_lxc_static_LDFLAGS = -all-static
 init_lxc_static_LDADD = @CAP_LIBS@
 init_lxc_static_CFLAGS = $(AM_CFLAGS) -DNO_LXC_CONF
 endif
+endif
 
 install-exec-local: install-libLTLIBRARIES
 	mkdir -p $(DESTDIR)$(datadir)/lxc

From 95a0e4f25878243a2ff59145753adca3c2c5fb5e Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 14 Feb 2018 11:45:09 +0100
Subject: [PATCH 2/4] tree-wide: cleanup

- remove legacy binaries
- conditionalize creation of docs and tests for the command line tools and the
  shared library helper commands

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 .gitignore                                   |   2 -
 config/apparmor/abstractions/start-container |   2 +-
 config/bash/lxc.in                           |   1 -
 configure.ac                                 |   7 -
 doc/ja/Makefile.am                           |   7 -
 doc/ja/lxc-clone.sgml.in                     | 386 -------------------------
 doc/ja/lxc-start-ephemeral.sgml.in           | 316 --------------------
 doc/ko/lxc-clone.sgml.in                     | 377 ------------------------
 doc/ko/lxc-start-ephemeral.sgml.in           | 318 --------------------
 doc/lxc-clone.sgml.in                        | 310 --------------------
 doc/lxc-copy.sgml.in                         |   3 +-
 doc/lxc-start-ephemeral.sgml.in              | 261 -----------------
 doc/lxc.container.conf.sgml.in               |   9 +-
 src/lxc/Makefile.am                          |  19 --
 src/lxc/tools/lxc-start-ephemeral.in         | 418 ---------------------------
 src/lxc/tools/lxc-top.lua                    | 243 ----------------
 src/lxc/tools/lxc_clone.c                    | 246 ----------------
 src/tests/Makefile.am                        |   5 +-
 18 files changed, 10 insertions(+), 2920 deletions(-)
 delete mode 100644 doc/ja/lxc-clone.sgml.in
 delete mode 100644 doc/ja/lxc-start-ephemeral.sgml.in
 delete mode 100644 doc/ko/lxc-clone.sgml.in
 delete mode 100644 doc/ko/lxc-start-ephemeral.sgml.in
 delete mode 100644 doc/lxc-clone.sgml.in
 delete mode 100644 doc/lxc-start-ephemeral.sgml.in
 delete mode 100644 src/lxc/tools/lxc-start-ephemeral.in
 delete mode 100755 src/lxc/tools/lxc-top.lua
 delete mode 100644 src/lxc/tools/lxc_clone.c

diff --git a/.gitignore b/.gitignore
index 3410daa38..d48daf2cc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,7 +39,6 @@ src/lxc/lxc-cgroup
 src/lxc/tools/lxc-checkconfig
 src/lxc/tools/lxc-update-config
 src/lxc/lxc-checkpoint
-src/lxc/lxc-clone
 src/lxc/lxc-console
 src/lxc/lxc-config
 src/lxc/lxc-copy
@@ -57,7 +56,6 @@ src/lxc/lxc-monitord
 src/lxc/lxc-shutdown
 src/lxc/lxc-snapshot
 src/lxc/lxc-start
-src/lxc/tools/lxc-start-ephemeral
 src/lxc/lxc-stop
 src/lxc/lxc-top
 src/lxc/lxc-unfreeze
diff --git a/config/apparmor/abstractions/start-container b/config/apparmor/abstractions/start-container
index 508bbf32e..fa64c278c 100644
--- a/config/apparmor/abstractions/start-container
+++ b/config/apparmor/abstractions/start-container
@@ -20,7 +20,7 @@
   # allow pre-mount hooks to stage mounts under /var/lib/lxc/<container>/
   mount -> /var/lib/lxc/{**,},
 
-  # required for some pre-mount hooks (like the new lxc-start-ephemeral)
+  # required for some pre-mount hooks
   mount fstype=overlayfs,
   mount fstype=aufs,
   mount fstype=ecryptfs,
diff --git a/config/bash/lxc.in b/config/bash/lxc.in
index 72d5f0817..43056882f 100644
--- a/config/bash/lxc.in
+++ b/config/bash/lxc.in
@@ -108,5 +108,4 @@ _have lxc-start && {
     complete -o default -F _lxc_generic_t lxc-create
 
     complete -o default -F _lxc_generic_o lxc-copy
-    complete -o default -F _lxc_generic_o lxc-start-ephemeral
 }
diff --git a/configure.ac b/configure.ac
index 9868ffe3f..62f23f80a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -756,7 +756,6 @@ AC_CONFIG_FILES([
 	doc/lxc-cgroup.sgml
 	doc/lxc-checkconfig.sgml
 	doc/lxc-checkpoint.sgml
-	doc/lxc-clone.sgml
 	doc/lxc-config.sgml
 	doc/lxc-console.sgml
 	doc/lxc-copy.sgml
@@ -769,7 +768,6 @@ AC_CONFIG_FILES([
 	doc/lxc-ls.sgml
 	doc/lxc-monitor.sgml
 	doc/lxc-snapshot.sgml
-	doc/lxc-start-ephemeral.sgml
 	doc/lxc-start.sgml
 	doc/lxc-stop.sgml
 	doc/lxc-top.sgml
@@ -805,7 +803,6 @@ AC_CONFIG_FILES([
 	doc/ja/lxc-cgroup.sgml
 	doc/ja/lxc-checkconfig.sgml
 	doc/ja/lxc-checkpoint.sgml
-	doc/ja/lxc-clone.sgml
 	doc/ja/lxc-config.sgml
 	doc/ja/lxc-console.sgml
 	doc/ja/lxc-copy.sgml
@@ -818,7 +815,6 @@ AC_CONFIG_FILES([
 	doc/ja/lxc-ls.sgml
 	doc/ja/lxc-monitor.sgml
 	doc/ja/lxc-snapshot.sgml
-	doc/ja/lxc-start-ephemeral.sgml
 	doc/ja/lxc-start.sgml
 	doc/ja/lxc-stop.sgml
 	doc/ja/lxc-top.sgml
@@ -843,7 +839,6 @@ AC_CONFIG_FILES([
 	doc/ko/lxc-cgroup.sgml
 	doc/ko/lxc-checkconfig.sgml
 	doc/ko/lxc-checkpoint.sgml
-	doc/ko/lxc-clone.sgml
 	doc/ko/lxc-config.sgml
 	doc/ko/lxc-console.sgml
 	doc/ko/lxc-copy.sgml
@@ -856,7 +851,6 @@ AC_CONFIG_FILES([
 	doc/ko/lxc-ls.sgml
 	doc/ko/lxc-monitor.sgml
 	doc/ko/lxc-snapshot.sgml
-	doc/ko/lxc-start-ephemeral.sgml
 	doc/ko/lxc-start.sgml
 	doc/ko/lxc-stop.sgml
 	doc/ko/lxc-top.sgml
@@ -908,7 +902,6 @@ AC_CONFIG_FILES([
 	src/lxc/lxc.functions
 	src/lxc/cmd/lxc-checkconfig
 	src/lxc/cmd/lxc-update-config
-	src/lxc/tools/lxc-start-ephemeral
 	src/lxc/version.h
 	src/python-lxc/Makefile
 
diff --git a/doc/ja/Makefile.am b/doc/ja/Makefile.am
index f30346d3a..89eae5ad5 100644
--- a/doc/ja/Makefile.am
+++ b/doc/ja/Makefile.am
@@ -42,13 +42,6 @@ man_MANS = \
 	\
 	lxc.7
 
-if ENABLE_DEPRECATED
-    man_MANS += lxc-clone.1
-if ENABLE_PYTHON
-    man_MANS += lxc-start-ephemeral.1
-endif
-endif
-
 %.1 : %.sgml
 	$(db2xman) --encoding=UTF-8 $<
 	test "$(shell basename $@)" != "$@" && mv $(shell basename $@) $@ || true
diff --git a/doc/ja/lxc-clone.sgml.in b/doc/ja/lxc-clone.sgml.in
deleted file mode 100644
index 9e68910f7..000000000
--- a/doc/ja/lxc-clone.sgml.in
+++ /dev/null
@@ -1,386 +0,0 @@
-<!--
-
-lxc: linux Container library
-
-(C) Copyright IBM Corp. 2007, 2008
-
-Authors:
-Daniel Lezcano <daniel.lezcano at free.fr>
-Serge Hallyn <serge.hallyn at ubuntu.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Translated into Japanese
-by KATOH Yasufumi <karma at jazz.email.ne.jp>
-
--->
-
-<!DOCTYPE refentry PUBLIC @docdtd@ [
-
-<!ENTITY commonoptions SYSTEM "@builddir@/common_options.sgml">
-<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
-]>
-
-<refentry>
-
-  <docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
-
-  <refmeta>
-    <refentrytitle>lxc-clone</refentrytitle>
-    <manvolnum>1</manvolnum>
-  </refmeta>
-
-  <refnamediv>
-    <refname>lxc-clone</refname>
-
-    <refpurpose>
-      <!--
-      clone a new container from an existing one.
-      -->
-      既存のコンテナからの新しいコンテナのクローン
-    </refpurpose>
-  </refnamediv>
-
-  <refsynopsisdiv>
-    <cmdsynopsis>
-      <command>lxc-clone</command>
-      <arg choice="opt">-s </arg>
-      <arg choice="opt">-K </arg>
-      <arg choice="opt">-M </arg>
-      <arg choice="opt">-H </arg>
-      <arg choice="opt">-B <replaceable>backingstore</replaceable></arg>
-      <arg choice="opt">-L <replaceable>fssize</replaceable></arg>
-      <arg choice="opt">-p <replaceable>lxcpath</replaceable></arg>
-      <arg choice="opt">-P <replaceable>newlxcpath</replaceable></arg>
-      <arg choice="opt">-R </arg>
-      <arg choice="req">-o <replaceable>orig</replaceable></arg>
-      <arg choice="req">-n <replaceable>new</replaceable></arg>
-      <arg choice="opt">-- hook arguments</arg>
-    </cmdsynopsis>
-    <cmdsynopsis>
-      <command>lxc-clone</command>
-      <arg choice="opt">-s </arg>
-      <arg choice="opt">-K </arg>
-      <arg choice="opt">-M </arg>
-      <arg choice="opt">-H </arg>
-      <arg choice="opt">-B <replaceable>backingstore</replaceable></arg>
-      <arg choice="opt">-L <replaceable>fssize</replaceable></arg>
-      <arg choice="opt">-p <replaceable>lxcpath</replaceable></arg>
-      <arg choice="opt">-P <replaceable>newlxcpath</replaceable></arg>
-      <arg choice="opt">-R </arg>
-      <arg choice="req">orig</arg>
-      <arg choice="req">new</arg>
-      <arg choice="opt">-- hook arguments</arg>
-    </cmdsynopsis>
-  </refsynopsisdiv>
-
-  <refsect1>
-    <title><!-- Description -->説明</title>
-
-    <para>
-      <!--
-      <command>lxc-clone</command> Creates a new container as a clone of an existing
-      container.  Two types of clones are supported: copy and snapshot.  A copy
-      clone copies the root filessytem from the original container to the new.  A
-      snapshot filesystem uses the backing store's snapshot functionality to create
-      a very small copy-on-write snapshot of the original container.  Snapshot
-      clones require the new container backing store to support snapshotting.  Currently
-      this includes only aufs, btrfs, lvm, overlayfs and zfs.  LVM devices do not support
-      snapshots of snapshots.
-      -->
-      <command>lxc-clone</command> は、新しいコンテナを既に存在するコンテナのクローンとして作製します。
-      クローンは 2 つのタイプをサポートします: コピーとスナップショットです。
-      コピータイプのクローンは元のコンテナから新しいコンテナへ root ファイルシステムをコピーします。
-      スナップショットファイルシステムは、バッキングストアのスナップショット機能を使い、元のコンテナの非常に小さな copy-on-write でのスナップショットを作製します。
-      スナップショットでのクローンは、新しいコンテナのバッキングストアとしてスナップショット機能のサポートが必要になります。
-      現時点では、このようなバッキングストアとしては aufs, btrfs, lvm, overlayfs, zfs のみをサポートします。
-      LVM デバイスはスナップショットのスナップショットはサポートしていません。
-    </para>
-
-    <para>
-      <!--
-      The backing store of the new container will be the same type as the
-      original container, with one exception, overlay containers.
-      aufs and overlayfs snapshots can be created of directory backed
-      containers.  This can be requested by using (for overlayfs) the
-      <replaceable>-B overlayfs</replaceable> arguments.
-      -->
-      新しいコンテナのバッキングストアは、オーバーレイタイプのコンテナを除いては元のコンテナのタイプと同じになります。
-      ディレクトリバックエンドのコンテナのスナップショットを aufs もしくは overlayfs で作成することは可能です。
-      例えば、overlayfs の場合は <replaceable>-B overlayfs</replaceable> という引数を使って指定することが可能です。
-    </para>
-
-    <para>
-      <!--
-      The names of the original and new container can be given (in that order)
-      after all options, or can be specified with the
-      <replaceable>-o</replaceable> and <replaceable>-n</replaceable> options,
-      respectively.
-      -->
-      元のコンテナと新しいコンテナの名前は、全てのオプションの後に順番に与えることも、<replaceable>-o</replaceable> と <replaceable>-n</replaceable> オプションを使ってそれぞれ指定することも可能です。
-    </para>
-
-  </refsect1>
-
-  <refsect1>
-
-    <title><!-- Options -->オプション</title>
-
-    <variablelist>
-
-      <varlistentry>
-	<term>
-	  <option>-s, --snapshot</option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    The new container's rootfs will be a snapshot of the original. This option can be specified when the backing store is LVM, btrfs or zfs, and must be specified when you want to snapshot using aufs or overlayfs.
-              -->
-	    新しいコンテナの rootfs はオリジナルのスナップショットとなります。
-	    このオプションはバッキングストアが LVM か btrfs か zfs の時に使用できます。
-	    また、スナップショットを aufs か overlayfs で取得したい場合は指定する必要があります。
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-K, --keepname</option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    Do not change the hostname of the container (in the root
-	    filesystem).
-            -->
-            (root ファイルシステム内では) コンテナのホスト名を変更しません。
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-M, --keepmac</option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    Use the same MAC address as the original container, rather than
-	    generating a new random one.
-            -->
-            新しい MAC アドレスをランダムに生成せずに、元のコンテナと同じ MAC アドレスを使用します。
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-H, --copyhooks</option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    Copy all mount hooks into the new container's directory, and
-	    update any lxcpaths and container names as needed.
-            -->
-            全てのマウントフックを新しいコンテナのディレクトリにコピーします。
-            そして、lxcpath とコンテナ名を必要に応じて更新します。
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-L, --fssize <replaceable>fssize</replaceable></option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    In the case of a block device backed container, a size for the new
-	    block device.  By default, the new device will be made the
-	    same size as the original.
-            -->
-            ブロックデバイスのバックエンドのコンテナの場合、新しいブロックデバイスのサイズ。
-            デフォルトでは、新しいデバイスは元のデバイスと同じサイズとなります。
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-p, --lxcpath <replaceable>lxcpath</replaceable></option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    The lxcpath of the original container.  By default, the system
-	    wide configured lxcpath will be used.
-            -->
-            オリジナルのコンテナの lxcpath。デフォルトでは、システム全体で設定された lxcpath が使われます。
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-P, --newpath <replaceable>newlxcpath</replaceable></option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    The lxcpath for the new container.  By default the same lxcpath
-	    as the original will be used.  Note that with btrfs snapshots,
-	    changing lxcpaths may not be possible, as subvolume snapshots
-	    must be in the same btrfs filesystem.
-            -->
-            新しいコンテナの lxcpath。
-            デフォルトでは、オリジナルの lxcpath と同じものが使われます。
-            btrfs のスナップショットの場合は注意が必要で、lxcpath の変更はできない可能性があります。
-            これは subvolume のスナップショットが、同じ btrfs ファイルシステム上に存在しなければならないからです。
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-B, --backingstore <replaceable>backingstore</replaceable></option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    Select a different backing store for the new container.  By
-	    default the same as the original container's is used.  Note that
-	    currently changing the backingstore is only supported for
-	    aufs and overlayfs snapshots of directory backed containers.  Valid
-	    backing stores include dir (directory), aufs, btrfs, lvm, zfs, loop
-	    and overlayfs.
-            -->
-            新しいコンテナで元のコンテナと違うバッキングストアを使う場合のバッキングストアを選択します。
-            デフォルトでは元のコンテナと同じものが使われます。
-            現時点では、バッキングストアの変更は、ディレクトリバックエンドのコンテナに対する aufs と overlayfs のスナップショットに対してのみサポートされます。
-            有効なバッキングストアは dir(directory), aufs, btrfs, lvm, zfs, loop, overlayfs です。
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-R, --rename</option>
-	</term>
-	<listitem>
-	  <para>
-	    <!--
-	    Rename an existing container.
-	    <replaceable>orig</replaceable> is renamed <replaceable>new</replaceable>.
-	    -->
-	    コンテナの名前を変更します。<replaceable>orig</replaceable> を <replaceable>new</replaceable> という名前に変更します。
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-o, --orig <replaceable>orig</replaceable></option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    The name of the original container to clone.
-            -->
-            クローンしたい元のコンテナの名前。
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-n, --new <replaceable>new</replaceable></option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    The name of the new container to create.
-            -->
-            作製する新しいコンテナの名前。
-	  </para>
-	</listitem>
-      </varlistentry>
-
-
-    </variablelist>
-
-  </refsect1>
-
-  <refsect1>
-    <title>Clone hook</title>
-    <para>
-      <!--
-      If the container being cloned has one or more <filename>lxc.hook.clone</filename>
-      specified, then the specified hooks will be called for the new container.  The
-      first 3 arguments passed to the clone hook will be the container name, a section
-      ('lxc'), and the hook type ('clone').  Extra arguments passed
-      <command>lxc-clone</command> will be passed to the hook program starting at
-      argument 4.  The <filename>LXC_ROOTFS_MOUNT</filename> environment variable gives
-      the path under which the container's root filesystem is mounted.  The
-      configuration file pathname is stored in <filename>LXC_CONFIG_FILE</filename>, the
-      new container name in <filename>LXC_NAME</filename>, the old container name in
-      <filename>LXC_SRC_NAME</filename>, and the path or device on which
-      the rootfs is located is in <filename>LXC_ROOTFS_PATH</filename>.
-      -->
-      クローンされるコンテナに 1 つ以上の <filename>lxc.hook.clone</filename> の指定が存在する場合、指定されたフックは新しいコンテナに対して呼ばれます。
-      クローンフックに渡される最初の 3 つの引数は、コンテナ名、セクション ('lxc')、フックタイプ ('clone') となります。
-      <command>lxc-clone</command> に渡される追加の引数は、フックプログラムに渡される引数の 4 番目以降となります。
-      <filename>LXC_ROOTFS_MOUNT</filename> 環境変数には、コンテナの root ファイルシステムがマウントされるパスが与えられます。
-      設定ファイルのパス名は <filename>LXC_CONFIG_FILE</filename> に、新しいコンテナ名は <filename>LXC_NAME</filename>、古いコンテナ名は <filename>LXC_SRC_NAME</filename> に、rootfs のあるパスまたはデバイスは <filename>LXC_ROOTFS_PATH</filename> に保存されます。
-    </para>
-  </refsect1>
-
-  <refsect1>
-    <title><!-- Notes -->注意</title>
-    <para>
-      <!--
-    <command>lxc-clone</command> is deprecated in favor of
-    <command>lxc-copy</command>.
-    -->
-      <command>lxc-clone</command> は <command>lxc-copy</command> に置き換えられ、廃止される予定です。
-    </para>
-  </refsect1>
-
-  &seealso;
-
-  <refsect1>
-    <title><!-- Author -->作者</title>
-    <para>Serge Hallyn <email>serge.hallyn at ubuntu.com</email></para>
-  </refsect1>
-
-</refentry>
-
-<!-- Keep this comment at the end of the file
-Local variables:
-mode: sgml
-sgml-omittag:t
-sgml-shorttag:t
-sgml-minimize-attributes:nil
-sgml-always-quote-attributes:t
-sgml-indent-step:2
-sgml-indent-data:t
-sgml-parent-document:nil
-sgml-default-dtd-file:nil
-sgml-exposed-tags:nil
-sgml-local-catalogs:nil
-sgml-local-ecat-files:nil
-End:
--->
diff --git a/doc/ja/lxc-start-ephemeral.sgml.in b/doc/ja/lxc-start-ephemeral.sgml.in
deleted file mode 100644
index 0124f4895..000000000
--- a/doc/ja/lxc-start-ephemeral.sgml.in
+++ /dev/null
@@ -1,316 +0,0 @@
-
-<!--
-
-(C) Copyright Canonical Ltd. 2013
-
-Authors:
-Stéphane Graber <stgraber at ubuntu.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Translated into Japanese
-by KATOH Yasufumi <karma at jazz.email.ne.jp>
-
--->
-
-<!DOCTYPE refentry PUBLIC @docdtd@ [
-
-<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
-]>
-
-<refentry>
-
-  <docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
-
-  <refmeta>
-    <refentrytitle>lxc-start-ephemeral</refentrytitle>
-    <manvolnum>1</manvolnum>
-  </refmeta>
-
-  <refnamediv>
-    <refname>lxc-start-ephemeral</refname>
-
-    <refpurpose>
-      <!--
-      start an ephemeral copy of an existing container
-      -->
-      存在するコンテナの一時的なコピーを起動
-    </refpurpose>
-  </refnamediv>
-
-  <refsynopsisdiv>
-    <cmdsynopsis>
-      <command>lxc-start-ephemeral</command>
-      <arg choice="opt">-o</arg>
-      <arg choice="opt">-n</arg>
-      <arg choice="opt">-d</arg>
-      <arg choice="opt">--bdir</arg>
-      <arg choice="opt">--user</arg>
-      <arg choice="opt">--key</arg>
-      <arg choice="opt">--storage-type</arg>
-      <arg choice="opt">--union-type</arg>
-      <arg choice="opt">--keep-data</arg>
-      <arg choice="opt">COMMAND</arg>
-    </cmdsynopsis>
-  </refsynopsisdiv>
-
-  <refsect1>
-    <title><!-- Description -->説明</title>
-    <para>
-      <!--
-      <command>lxc-start-ephemeral</command> start an ephemeral copy of an
-      existing container.
-      -->
-      <command>lxc-start-ephemeral</command> は、存在するコンテナの一時的なコピーからコンテナを起動します。
-    </para>
-  </refsect1>
-
-  <refsect1>
-    <title><!-- Options -->オプション</title>
-    <variablelist>
-      <varlistentry>
-        <term>
-          <option>-o, --orig <replaceable>orig</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            Original container name
-            -->
-            コピー元のコンテナ名
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-n, --name <replaceable>name</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            Name of the ephemeral container (defaults to a random suffix).
-            -->
-            一時的なコンテナの名前 (デフォルトではランダムなサフィックスが付与されます)
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-d, --daemon</option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            Start the container in background and print the name and IP.
-            This option can't be used if a command is passed.
-            -->
-            コンテナをバックグラウンドで実行し、名前と IP アドレスを表示します。
-            このオプションはコマンドを実行させたいときには使用することはできません。
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-b, --bdir <replaceable>bdir</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            Directory to bind mount into container.
-            Can be passed multiple times.
-            -->
-            コンテナ内にバインドマウントするためのディレクトリ。
-            複数回指定できます。
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-u, --user <replaceable>user</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            The user to connect to the container as.
-            Used when passing a command to lxc-start-ephemeral.
-            -->
-            コンテナに接続するためのユーザ。
-            lxc-start-ephemeral にコマンドを指定するときに使います。
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-S, --key <replaceable>key</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            Copy the provided SSH public key into the container.
-            -->
-            コンテナ内にコピーする既存の SSH 公開鍵。
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-s, --storage-type <replaceable>storage type</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            Specify the type of storage used by the container. Valid types are tmpfs or dir.
-              -->
-            コンテナが使うストレージのタイプ。tmpfs か dir を指定できます。
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-U, --union-type <replaceable>union type</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            Force a specific union file system.
-            Can be one of: overlayfs aufs
-            -->
-            指定した union ファイルシステムを使用します。
-            overlayfs か aufs のどちらかが使用できます。
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-k, --keep-data</option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            Use a persistent backend instead of tmpfs.
-            With this option, you can lxc-stop and lxc-start the no longer so
-            ephemeral container (it's still an overlay, but a persistent one).
-            -->
-            tmpfs の代わりに永続的なバックエンドを使用します。このオプションを使うことにより、もはや一時的なコンテナではないので、lxc-stop や lxc-start を使用することができます (オーバーレイな状態ですが、永続的です)。
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>COMMAND</option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            Immediately run the provided command in the container.
-            This uses attach if the kernel supports it, otherwise uses ssh.
-            This is incompatible with daemon mode.
-            -->
-            即座に指定したコマンドをコンテナ内で実行します。
-            コマンドを実行する際、カーネルがサポートしている場合は lxc-start-ephemeral は attach を使います。
-            カーネルがサポートしていない場合は ssh を使います。
-          </para>
-        </listitem>
-      </varlistentry>
-    </variablelist>
-  </refsect1>
-
-  <refsect1>
-    <title>See Also</title>
-
-    <simpara>
-      <citerefentry>
-        <refentrytitle>lxc-start</refentrytitle>
-        <manvolnum>1</manvolnum>
-      </citerefentry>,
-    </simpara>
-  </refsect1>
-
-  <refsect1>
-    <title><!-- Examples -->例</title>
-    <variablelist>
-      <varlistentry>
-        <term>lxc-start-ephemeral -o p1</term>
-        <listitem>
-        <para>
-          <!--
-          Simply start an ephemeral container and attach to the console.
-          This container will be based on existing container "p1".
-          -->
-          単に一時的なコンテナを開始させ、コンソールにアタッチします。
-          このコンテナは "p1" という既存のコンテナを基にします。
-        </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>lxc-start-ephemeral -o p1 -n p1-ephemeral -d</term>
-        <listitem>
-        <para>
-          <!--
-          Start an ephemeral container based on p1 called p1-ephemeral and
-          print its IP and name to the console instead of attaching.
-          -->
-          p1 を基にした一時的なコンテナを開始し、コンソールにアタッチする代わりに IP アドレスと名前を表示します。
-        </para>
-        </listitem>
-      </varlistentry>
-    </variablelist>
-  </refsect1>
-
-  <refsect1>
-    <title><!-- Notes -->注意</title>
-    <para>
-      <!--
-    <command>lxc-start-ephemeral</command> is deprecated in favor of
-    <command>lxc-copy</command>.
-    -->
-      <command>lxc-start-ephemeral</command> は <command>lxc-copy</command> に置き換えられ、廃止される予定です。
-    </para>
-  </refsect1>
-
-  &seealso;
-
-  <refsect1>
-    <title><!-- Author -->作者</title>
-    <para>Stéphane Graber <email>stgraber at ubuntu.com</email></para>
-  </refsect1>
-</refentry>
-
-<!-- Keep this comment at the end of the file
-Local variables:
-mode: sgml
-sgml-omittag:t
-sgml-shorttag:t
-sgml-minimize-attributes:nil
-sgml-always-quote-attributes:t
-sgml-indent-step:2
-sgml-indent-data:t
-sgml-parent-document:nil
-sgml-default-dtd-file:nil
-sgml-exposed-tags:nil
-sgml-local-catalogs:nil
-sgml-local-ecat-files:nil
-End:
--->
diff --git a/doc/ko/lxc-clone.sgml.in b/doc/ko/lxc-clone.sgml.in
deleted file mode 100644
index b610119d7..000000000
--- a/doc/ko/lxc-clone.sgml.in
+++ /dev/null
@@ -1,377 +0,0 @@
-<!--
-
-lxc: linux Container library
-
-(C) Copyright IBM Corp. 2007, 2008
-
-Authors:
-Daniel Lezcano <daniel.lezcano at free.fr>
-Serge Hallyn <serge.hallyn at ubuntu.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Translated into Korean
-by Sungbae Yoo <sungbae.yoo at samsung.com>
-
--->
-
-<!DOCTYPE refentry PUBLIC @docdtd@ [
-
-<!ENTITY commonoptions SYSTEM "@builddir@/common_options.sgml">
-<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
-]>
-
-<refentry>
-
-  <docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
-
-  <refmeta>
-    <refentrytitle>lxc-clone</refentrytitle>
-    <manvolnum>1</manvolnum>
-  </refmeta>
-
-  <refnamediv>
-    <refname>lxc-clone</refname>
-
-    <refpurpose>
-      <!--
-      clone a new container from an existing one.
-      -->
-      존재하는 컨테이너를 새로운 컨테이너로 복제
-    </refpurpose>
-  </refnamediv>
-
-  <refsynopsisdiv>
-    <cmdsynopsis>
-      <command>lxc-clone</command>
-      <arg choice="opt">-s </arg>
-      <arg choice="opt">-K </arg>
-      <arg choice="opt">-M </arg>
-      <arg choice="opt">-H </arg>
-      <arg choice="opt">-B <replaceable>backingstore</replaceable></arg>
-      <arg choice="opt">-L <replaceable>fssize</replaceable></arg>
-      <arg choice="opt">-p <replaceable>lxcpath</replaceable></arg>
-      <arg choice="opt">-P <replaceable>newlxcpath</replaceable></arg>
-      <arg choice="opt">-R </arg>
-      <arg choice="req">-o <replaceable>orig</replaceable></arg>
-      <arg choice="req">-n <replaceable>new</replaceable></arg>
-      <arg choice="opt">-- hook arguments</arg>
-    </cmdsynopsis>
-    <cmdsynopsis>
-      <command>lxc-clone</command>
-      <arg choice="opt">-s </arg>
-      <arg choice="opt">-K </arg>
-      <arg choice="opt">-M </arg>
-      <arg choice="opt">-H </arg>
-      <arg choice="opt">-B <replaceable>backingstore</replaceable></arg>
-      <arg choice="opt">-L <replaceable>fssize</replaceable></arg>
-      <arg choice="opt">-p <replaceable>lxcpath</replaceable></arg>
-      <arg choice="opt">-P <replaceable>newlxcpath</replaceable></arg>
-      <arg choice="opt">-R </arg>
-      <arg choice="req">orig</arg>
-      <arg choice="req">new</arg>
-      <arg choice="opt">-- hook arguments</arg>
-    </cmdsynopsis>
-  </refsynopsisdiv>
-
-  <refsect1>
-    <title><!-- Description -->설명</title>
-
-    <para>
-      <!--
-      <command>lxc-clone</command> Creates a new container as a clone of an existing
-      container.  Two types of clones are supported: copy and snapshot.  A copy
-      clone copies the root filessytem from the original container to the new.  A
-      snapshot filesystem uses the backing store's snapshot functionality to create
-      a very small copy-on-write snapshot of the original container.  Snapshot
-      clones require the new container backing store to support snapshotting.  Currently
-      this includes only aufs, btrfs, lvm, overlayfs and zfs.  LVM devices do not support
-      snapshots of snapshots.
-      -->
-      <command>lxc-clone</command>는 존재하는 컨테이너를 복제하여 새로운 컨테이너를 생성한다. 복사, 스냅샷의 두가지 형태의 복제가 지원된다.
-      복사는 원본 컨테이너의 루트 파일시스템을 그대로 새 컨테이너로 복사한다..
-      스냅샷은 저장소의 스냅샷 기능을 이용하여 원본 컨테이너의 copy-on-write 형태로 매우 작은 스냅샷을 생성한다. 스냅샷을 사용하기 위해서는 새 컨테이너의 저장소가 스냅샷 기능을 지원하여야 한다. 현재 스냅샷 기능을 지원하는 것은 aufs, btrfs, lvm, overlayfs, zfs 정도이다. lvm은 스냅샷의 스냅샷은 지원하지 않는다.
-    </para>
-
-    <para>
-      <!--
-      The backing store of the new container will be the same type as the
-      original container, with one exception, overlay containers.
-      aufs and overlayfs snapshots can be created of directory backed
-      containers.  This can be requested by using (for overlayfs) the
-      <replaceable>-B overlayfs</replaceable> arguments.
-      -->
-      오버레이 컨테이너들을 제외하면, 새 컨테이너의 저장소는 원본과 같은 종류를 사용한다.
-      aufs와 overlayfs의 스냅샷은 디렉토리로 구성된 컨테이너로 생성할 수 있다. overlayfs의 경우 <replaceable>-B overlayfs</replaceable> 인수를 통해 이를 지정할 수 있다.
-    </para>
-
-    <para>
-      <!--
-      The names of the original and new container can be given (in that order)
-      after all options, or can be specified with the
-      <replaceable>-o</replaceable> and <replaceable>-n</replaceable> options,
-      respectively.
-      -->
-      원본 컨테이너와 새 컨테이너의 이름은 모든 옵션 뒤에 원본, 새 컨테이너 순으로 지정할 수 있다. 또는 <replaceable>-o</replaceable>과 <replaceable>-n</replaceable> 옵션을 사용하여 지정할 수 있다.
-    </para>
-
-  </refsect1>
-
-  <refsect1>
-
-    <title><!-- Options -->옵션</title>
-
-    <variablelist>
-
-      <varlistentry>
-	<term>
-	  <option>-s, --snapshot</option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    The new container's rootfs will be a snapshot of the original. This option can be specified when the backing store is LVM, btrfs or zfs, and must be specified when you want to snapshot using aufs or overlayfs.
-              -->
-            새로 생성하는 컨테이너의 루트 파일시스템은 원본의 스냅샷으로 한다. 이 옵션은 저장소가 lvm, btrfs, zfs 일때 지정할 수 있다. 또한 aufs나 overlayfs를 이용한 스냅샷을 원할때만 지정해야 한다.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-K, --keepname</option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    Do not change the hostname of the container (in the root
-	    filesystem).
-            -->
-            (루트 파일시스템에서) 컨테이너의 호스트 이름을 변경하지 않는다.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-M, --keepmac</option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    Use the same MAC address as the original container, rather than
-	    generating a new random one.
-            -->
-            새로 무작위한 주소를 만들지 않고, 원본과 같은 MAC 주소를 사용한다.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-H, --copyhooks</option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    Copy all mount hooks into the new container's directory, and
-	    update any lxcpaths and container names as needed.
-            -->
-            모든 마운트 훅들을 새 컨테이너의 디렉토리로 복사한다. 그리고 lxcpath와 컨테이너 이름을 필요에 따라 갱신한다.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-L, --fssize <replaceable>fssize</replaceable></option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    In the case of a block device backed container, a size for the new
-	    block device.  By default, the new device will be made the
-	    same size as the original.
-            -->
-            블록장치로 구성된 컨테이너의 경우, 새로운 블록 장치의 크기.
-            기본으로 새 디바이스는 원본과 같은 크기로 만들어진다.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-p, --lxcpath <replaceable>lxcpath</replaceable></option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    The lxcpath of the original container.  By default, the system
-	    wide configured lxcpath will be used.
-            -->
-            원본 컨테이너의 lxcpath. 기본값은 시스템 전역으로 설정되어 잇는 lxcpath를 사용한다.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-P, --newpath <replaceable>newlxcpath</replaceable></option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    The lxcpath for the new container.  By default the same lxcpath
-	    as the original will be used.  Note that with btrfs snapshots,
-	    changing lxcpaths may not be possible, as subvolume snapshots
-	    must be in the same btrfs filesystem.
-            -->
-            새로 생성될 컨테이너의 lxcpath.
-            기본값은 원본 컨테이너의 lxcpath와 같다.
-            btrfs의 스냅샷의 경우 lxcpath 변경이 불가능 할 수 있음을 주의해야 한다. 왜냐하면 서브볼륨 스냅샷이 같은 btrfs 파일시스템 내에 있어야 하기 때문이다.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-B, --backingstore <replaceable>backingstore</replaceable></option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    Select a different backing store for the new container.  By
-	    default the same as the original container's is used.  Note that
-	    currently changing the backingstore is only supported for
-	    aufs and overlayfs snapshots of directory backed containers.  Valid
-	    backing stores include dir (directory), aufs, btrfs, lvm, zfs, loop
-	    and overlayfs.
-            -->
-            새 컨테이너의 저장소를 선택한다.
-            기본 값은 원본 컨테이너가 쓰던 것과 같은 것으로 되어 있다.
-            현재 저장소를 다른 것으로 변경하는 것은 디렉토리로 구성된 컨테이너의 aufs와 overlayfs 스냅샷에서만 지원된다.
-            가능한 값은 dir(디렉토리), aufs, btrfs, lvm zfs, loop 그리고 ovelayfs 이다.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-R, --rename</option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    Rename an existing container.
-            <replaceable>orig</replaceable> is renamed <replaceable>new</replaceable>.
-            -->
-            컨테이너의 이름을 변경한다. <replaceable>orig</replaceable>를 <replaceable>new</replaceable>로 이름을 바꾼다.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-
-	  <option>-o, --orig <replaceable>orig</replaceable></option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    The name of the original container to clone.
-            -->
-            복제할 원본 컨테이너의 이름.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-n, --new <replaceable>new</replaceable></option>
-	</term>
-	<listitem>
-	  <para>
-            <!--
-	    The name of the new container to create.
-            -->
-            생성할 새 컨테이너의 이름.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-
-    </variablelist>
-
-  </refsect1>
-
-  <refsect1>
-    <title>Clone hook</title>
-    <para>
-      <!--
-      If the container being cloned has one or more <filename>lxc.hook.clone</filename>
-      specified, then the specified hooks will be called for the new container.  The
-      first 3 arguments passed to the clone hook will be the container name, a section
-      ('lxc'), and the hook type ('clone').  Extra arguments passed
-      <command>lxc-clone</command> will be passed to the hook program starting at
-      argument 4.  The <filename>LXC_ROOTFS_MOUNT</filename> environment variable gives
-      the path under which the container's root filesystem is mounted.  The
-      configuration file pathname is stored in <filename>LXC_CONFIG_FILE</filename>, the
-      new container name in <filename>LXC_NAME</filename>, the old container name in
-      <filename>LXC_SRC_NAME</filename>, and the path or device on which
-      the rootfs is located is in <filename>LXC_ROOTFS_PATH</filename>.
-      -->
-      만약 복제되는 컨테이너가 1개 이상의 <filename>lxc.hook.clone</filename>을 지정했다면, 지정된 훅은 새 컨테이너가 생성될 때 실행될 것이다.
-      먼저 컨테이너 이름, 섹션('lxc'), 훅 종류('clone') 3개의 인수가 복제 훅에 전달 된다. 그리고 4번째 인수 부터는 <command>lxc-clone</command>로 넘겨줄 수 있다.
-      <filename>LXC_ROOTFS_MOUNT</filename> 환경변수는 컨테이너의 루트 파일시스템이 마운트되어 있는 경로를 넘겨준다.
-      새 컨테이너의 이름은 <filename>LXC_NAME</filename> 변수에, 이전 컨테이너의 이름은 <filename>LXC_SRC_NAME</filename> 환경변수에 담겨 있다. 그리고 루트 파일시스템이 위치하고 있는 곳은 <filename>LXC_ROOTFS_PATH</filename>로 넘겨준다.
-    </para>
-  </refsect1>
-
-  <refsect1>
-    <title><!-- Notes -->주의</title>
-    <para>
-      <!--
-      <command>lxc-clone</command> is deprecated in favor of
-      <command>lxc-copy</command>.
-      -->
-      <command>lxc-clone</command>는 <command>lxc-copy</command>로 대체되었으며, 제거될 예정이다.
-    </para>
-  </refsect1>
-
-  &seealso;
-
-  <refsect1>
-    <title><!-- Author -->저자</title>
-    <para>Serge Hallyn <email>serge.hallyn at ubuntu.com</email></para>
-  </refsect1>
-
-</refentry>
-
-<!-- Keep this comment at the end of the file
-Local variables:
-mode: sgml
-sgml-omittag:t
-sgml-shorttag:t
-sgml-minimize-attributes:nil
-sgml-always-quote-attributes:t
-sgml-indent-step:2
-sgml-indent-data:t
-sgml-parent-document:nil
-sgml-default-dtd-file:nil
-sgml-exposed-tags:nil
-sgml-local-catalogs:nil
-sgml-local-ecat-files:nil
-End:
--->
diff --git a/doc/ko/lxc-start-ephemeral.sgml.in b/doc/ko/lxc-start-ephemeral.sgml.in
deleted file mode 100644
index 48947f646..000000000
--- a/doc/ko/lxc-start-ephemeral.sgml.in
+++ /dev/null
@@ -1,318 +0,0 @@
-
-<!--
-
-(C) Copyright Canonical Ltd. 2013
-
-Authors:
-Stéphane Graber <stgraber at ubuntu.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Translated into Korean
-by Sungbae Yoo <sungbae.yoo at samsung.com>
-
--->
-
-<!DOCTYPE refentry PUBLIC @docdtd@ [
-
-<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
-]>
-
-<refentry>
-
-  <docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
-
-  <refmeta>
-    <refentrytitle>lxc-start-ephemeral</refentrytitle>
-    <manvolnum>1</manvolnum>
-  </refmeta>
-
-  <refnamediv>
-    <refname>lxc-start-ephemeral</refname>
-
-    <refpurpose>
-      <!--
-      start an ephemeral copy of an existing container
-      -->
-      존재하는 컨테이너를 임시 복사본으로 시작
-    </refpurpose>
-  </refnamediv>
-
-  <refsynopsisdiv>
-    <cmdsynopsis>
-      <command>lxc-start-ephemeral</command>
-      <arg choice="opt">-o</arg>
-      <arg choice="opt">-n</arg>
-      <arg choice="opt">-d</arg>
-      <arg choice="opt">--bdir</arg>
-      <arg choice="opt">--user</arg>
-      <arg choice="opt">--key</arg>
-      <arg choice="opt">--storage-type</arg>
-      <arg choice="opt">--union-type</arg>
-      <arg choice="opt">--keep-data</arg>
-      <arg choice="opt">COMMAND</arg>
-    </cmdsynopsis>
-  </refsynopsisdiv>
-
-  <refsect1>
-    <title><!-- Description -->설명</title>
-    <para>
-      <!--
-      <command>lxc-start-ephemeral</command> start an ephemeral copy of an
-      existing container.
-      -->
-      <command>lxc-start-ephemeral</command>는 존재하는 컨테이너를 임시 복사본으로 시작시킨다.
-    </para>
-  </refsect1>
-
-  <refsect1>
-    <title><!-- Options -->옵션</title>
-    <variablelist>
-      <varlistentry>
-        <term>
-          <option>-o, --orig <replaceable>orig</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            Original container name
-            -->
-            원본 컨테이너 이름
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-n, --name <replaceable>name</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            Name of the ephemeral container (defaults to a random suffix).
-            -->
-            임시 컨테이너의 이름 (기본값은 무작위한 접미사를 붙이는 것)
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-d, --daemon</option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            Start the container in background and print the name and IP.
-            This option can't be used if a command is passed.
-            -->
-            컨테이너를 백그라운드로 시작한다. 그리고 이름과 IP를 표시한다.
-            옵션으로 명령어를 넘길 경우, 이 옵션은 사용하지 못한다.
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-b, --bdir <replaceable>bdir</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            Directory to bind mount into container.
-            Can be passed multiple times.
-            -->
-            컨테이너로 바인드 마운트할 디렉토리.
-            여러번 인자로 넘겨줄 수 있다.
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-u, --user <replaceable>user</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            The user to connect to the container as.
-            Used when passing a command to lxc-start-ephemeral.
-            -->
-            컨테이너에 연결할 사용자.
-            lxc-start-ephemeral로 명령어를 넘길때 사용한다.
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-S, --key <replaceable>key</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            Copy the provided SSH public key into the container.
-            -->
-            컨테이너 안으로 지정한 SSH 공개키를 복사한다.
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-s, --storage-type <replaceable>storage type</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            Specify the type of storage used by the container. Valid types are tmpfs or dir.
-              -->
-            컨테이너가 사용하는 저장소 형태를 지정한다. 가능한 형태는 tmpfs, dir이다.
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-U, --union-type <replaceable>union type</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            Force a specific union file system.
-            Can be one of: overlayfs aufs
-            -->
-            지정한 union 파일시스템을 사용한다.
-            가능한 파일시스템은  overlayfs, aufs이다.
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-k, --keep-data</option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            Use a persistent backend instead of tmpfs.
-            With this option, you can lxc-stop and lxc-start the no longer so
-            ephemeral container (it's still an overlay, but a persistent one).
-            -->
-            tmpfs 대신 영구적인 백엔드를 사용한다.
-            이 옵션을 사용하면, 더이상 임시 컨테이너가 아니기 때문에 lxc-stop이나 lxc-start를 사용할 수 있게 된다. (여전히 오버레이 상태이지만 영구적이다)
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>COMMAND</option>
-        </term>
-        <listitem>
-          <para>
-            <!--
-            Immediately run the provided command in the container.
-            This uses attach if the kernel supports it, otherwise uses ssh.
-            This is incompatible with daemon mode.
-            -->
-            지정한 명령어를 컨테이너 안에서 바로 실행한다.
-            커널이 attach를 지원하면 attach를 사용하고, 지원하지 않으면 ssh를 사용한다.
-            이 옵션은 데몬 모드와 같이 사용할 수 없다.
-          </para>
-        </listitem>
-      </varlistentry>
-    </variablelist>
-  </refsect1>
-
-  <refsect1>
-    <title><!-- See Also -->참조</title>
-
-    <simpara>
-      <citerefentry>
-        <refentrytitle>lxc-start</refentrytitle>
-        <manvolnum>1</manvolnum>
-      </citerefentry>,
-    </simpara>
-  </refsect1>
-
-  <refsect1>
-    <title><!-- Examples -->예제</title>
-    <variablelist>
-      <varlistentry>
-        <term>lxc-start-ephemeral -o p1</term>
-        <listitem>
-        <para>
-          <!--
-          Simply start an ephemeral container and attach to the console.
-          This container will be based on existing container "p1".
-          -->
-          단순히 임시 복사본 컨테이너를 시작하고, console에 연결한다.
-          임시 컨테이너는 컨테이너 p1을 기반으로 한다.
-        </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>lxc-start-ephemeral -o p1 -n p1-ephemeral -d</term>
-        <listitem>
-        <para>
-          <!--
-          Start an ephemeral container based on p1 called p1-ephemeral and
-          print its IP and name to the console instead of attaching.
-          -->
-          컨테이너 p1을 기반으로 임시 컨테이너 p1-ephemeral을 시작한다.
-          console에 연결하지 않고, 컨테이너의 IP와 이름을 출력한다.
-        </para>
-        </listitem>
-      </varlistentry>
-    </variablelist>
-  </refsect1>
-
-  <refsect1>
-    <title><!-- Notes -->주의</title>
-    <para>
-      <!--
-      <command>lxc-start-ephemeral</command> is deprecated in favor of
-      <command>lxc-copy</command>.
-      -->
-      <command>lxc-start-ephemeral</command>는 <command>lxc-copy</command>로 대체되었으며, 제거될 예정이다.
-    </para>
-  </refsect1>
-
-  &seealso;
-
-  <refsect1>
-    <title><!-- Author -->저자</title>
-    <para>Stéphane Graber <email>stgraber at ubuntu.com</email></para>
-  </refsect1>
-</refentry>
-
-<!-- Keep this comment at the end of the file
-Local variables:
-mode: sgml
-sgml-omittag:t
-sgml-shorttag:t
-sgml-minimize-attributes:nil
-sgml-always-quote-attributes:t
-sgml-indent-step:2
-sgml-indent-data:t
-sgml-parent-document:nil
-sgml-default-dtd-file:nil
-sgml-exposed-tags:nil
-sgml-local-catalogs:nil
-sgml-local-ecat-files:nil
-End:
--->
diff --git a/doc/lxc-clone.sgml.in b/doc/lxc-clone.sgml.in
deleted file mode 100644
index f134b8000..000000000
--- a/doc/lxc-clone.sgml.in
+++ /dev/null
@@ -1,310 +0,0 @@
-<!--
-
-lxc: linux Container library
-
-(C) Copyright IBM Corp. 2007, 2008
-
-Authors:
-Daniel Lezcano <daniel.lezcano at free.fr>
-Serge Hallyn <serge.hallyn at ubuntu.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
--->
-
-<!DOCTYPE refentry PUBLIC @docdtd@ [
-
-<!ENTITY commonoptions SYSTEM "@builddir@/common_options.sgml">
-<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
-]>
-
-<refentry>
-
-  <docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
-
-  <refmeta>
-    <refentrytitle>lxc-clone</refentrytitle>
-    <manvolnum>1</manvolnum>
-  </refmeta>
-
-  <refnamediv>
-    <refname>lxc-clone</refname>
-
-    <refpurpose>
-      clone a new container from an existing one.
-    </refpurpose>
-  </refnamediv>
-
-  <refsynopsisdiv>
-    <cmdsynopsis>
-      <command>lxc-clone</command>
-      <arg choice="opt">-s </arg>
-      <arg choice="opt">-K </arg>
-      <arg choice="opt">-M </arg>
-      <arg choice="opt">-H </arg>
-      <arg choice="opt">-B <replaceable>backingstore</replaceable></arg>
-      <arg choice="opt">-L <replaceable>fssize</replaceable></arg>
-      <arg choice="opt">-p <replaceable>lxcpath</replaceable></arg>
-      <arg choice="opt">-P <replaceable>newlxcpath</replaceable></arg>
-      <arg choice="opt">-R </arg>
-      <arg choice="req">-o <replaceable>orig</replaceable></arg>
-      <arg choice="req">-n <replaceable>new</replaceable></arg>
-      <arg choice="opt">-- hook arguments</arg>
-    </cmdsynopsis>
-    <cmdsynopsis>
-      <command>lxc-clone</command>
-      <arg choice="opt">-s </arg>
-      <arg choice="opt">-K </arg>
-      <arg choice="opt">-M </arg>
-      <arg choice="opt">-H </arg>
-      <arg choice="opt">-B <replaceable>backingstore</replaceable></arg>
-      <arg choice="opt">-L <replaceable>fssize</replaceable></arg>
-      <arg choice="opt">-p <replaceable>lxcpath</replaceable></arg>
-      <arg choice="opt">-P <replaceable>newlxcpath</replaceable></arg>
-      <arg choice="opt">-R </arg>
-      <arg choice="req">orig</arg>
-      <arg choice="req">new</arg>
-      <arg choice="opt">-- hook arguments</arg>
-    </cmdsynopsis>
-  </refsynopsisdiv>
-
-  <refsect1>
-    <title>Description</title>
-
-    <para>
-      <command>lxc-clone</command> Creates a new container as a clone of an existing
-      container.  Two types of clones are supported: copy and snapshot.  A copy
-      clone copies the root filessytem from the original container to the new.  A
-      snapshot filesystem uses the backing store's snapshot functionality to create
-      a very small copy-on-write snapshot of the original container.  Snapshot
-      clones require the new container backing store to support snapshotting.  Currently
-      this includes only aufs, btrfs, lvm, overlayfs and zfs.  LVM devices do not support
-      snapshots of snapshots.
-    </para>
-
-    <para>
-      The backing store of the new container will be the same type as the
-      original container, with one exception, overlay containers.
-      aufs and overlayfs snapshots can be created of directory backed
-      containers.  This can be requested by using (for overlayfs) the
-      <replaceable>-B overlayfs</replaceable> arguments.
-    </para>
-
-    <para>
-      The names of the original and new container can be given (in that order)
-      after all options, or can be specified with the
-      <replaceable>-o</replaceable> and <replaceable>-n</replaceable> options,
-      respectively.
-    </para>
-
-  </refsect1>
-
-  <refsect1>
-
-    <title>Options</title>
-
-    <variablelist>
-
-      <varlistentry>
-	<term>
-	  <option>-s, --snapshot</option>
-	</term>
-	<listitem>
-	  <para>
-	    The new container's rootfs will be a snapshot of the original. This option can be specified when the backing store is LVM, btrfs or zfs, and must be specified when you want to snapshot using aufs or overlayfs.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-K, --keepname</option>
-	</term>
-	<listitem>
-	  <para>
-	    Do not change the hostname of the container (in the root
-	    filesystem).
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-M, --keepmac</option>
-	</term>
-	<listitem>
-	  <para>
-	    Use the same MAC address as the original container, rather than
-	    generating a new random one.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-H, --copyhooks</option>
-	</term>
-	<listitem>
-	  <para>
-	    Copy all mount hooks into the new container's directory, and
-	    update any lxcpaths and container names as needed.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-L, --fssize <replaceable>fssize</replaceable></option>
-	</term>
-	<listitem>
-	  <para>
-	    In the case of a block device backed container, a size for the new
-	    block device.  By default, the new device will be made the
-	    same size as the original.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-p, --lxcpath <replaceable>lxcpath</replaceable></option>
-	</term>
-	<listitem>
-	  <para>
-	    The lxcpath of the original container.  By default, the system
-	    wide configured lxcpath will be used.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-P, --newpath <replaceable>newlxcpath</replaceable></option>
-	</term>
-	<listitem>
-	  <para>
-	    The lxcpath for the new container.  By default the same lxcpath
-	    as the original will be used.  Note that with btrfs snapshots,
-	    changing lxcpaths may not be possible, as subvolume snapshots
-	    must be in the same btrfs filesystem.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-B, --backingstore <replaceable>backingstore</replaceable></option>
-	</term>
-	<listitem>
-	  <para>
-	    Select a different backing store for the new container.  By
-	    default the same as the original container's is used.  Note that
-	    currently changing the backingstore is only supported for
-	    aufs and overlayfs snapshots of directory backed containers.  Valid
-	    backing stores include dir (directory), aufs, btrfs, lvm, zfs, loop
-	    and overlayfs.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-R, --rename</option>
-	</term>
-	<listitem>
-	  <para>
-	    Rename an existing container.
-	    <replaceable>orig</replaceable> is renamed <replaceable>new</replaceable>.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-o, --orig <replaceable>orig</replaceable></option>
-	</term>
-	<listitem>
-	  <para>
-	    The name of the original container to clone.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
-	<term>
-	  <option>-n, --new <replaceable>new</replaceable></option>
-	</term>
-	<listitem>
-	  <para>
-	    The name of the new container to create.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-
-    </variablelist>
-
-  </refsect1>
-
-  <refsect1>
-    <title>Clone hook</title>
-    <para>
-      If the container being cloned has one or more <filename>lxc.hook.clone</filename>
-      specified, then the specified hooks will be called for the new container.  The
-      first 3 arguments passed to the clone hook will be the container name, a section
-      ('lxc'), and the hook type ('clone').  Extra arguments passed
-      <command>lxc-clone</command> will be passed to the hook program starting at
-      argument 4.  The <filename>LXC_ROOTFS_MOUNT</filename> environment variable gives
-      the path under which the container's root filesystem is mounted.  The
-      configuration file pathname is stored in <filename>LXC_CONFIG_FILE</filename>, the
-      new container name in <filename>LXC_NAME</filename>, the old container name in
-      <filename>LXC_SRC_NAME</filename>, and the path or device on which
-      the rootfs is located is in <filename>LXC_ROOTFS_PATH</filename>.
-    </para>
-  </refsect1>
-
-  <refsect1>
-    <title>Notes</title>
-    <para>
-    <command>lxc-clone</command> is deprecated in favor of
-    <command>lxc-copy</command>.
-    </para>
-  </refsect1>
-
-  &seealso;
-
-  <refsect1>
-    <title>Author</title>
-    <para>Serge Hallyn <email>serge.hallyn at ubuntu.com</email></para>
-  </refsect1>
-
-</refentry>
-
-<!-- Keep this comment at the end of the file
-Local variables:
-mode: sgml
-sgml-omittag:t
-sgml-shorttag:t
-sgml-minimize-attributes:nil
-sgml-always-quote-attributes:t
-sgml-indent-step:2
-sgml-indent-data:t
-sgml-parent-document:nil
-sgml-default-dtd-file:nil
-sgml-exposed-tags:nil
-sgml-local-catalogs:nil
-sgml-local-ecat-files:nil
-End:
--->
diff --git a/doc/lxc-copy.sgml.in b/doc/lxc-copy.sgml.in
index 475feb05b..467af116a 100644
--- a/doc/lxc-copy.sgml.in
+++ b/doc/lxc-copy.sgml.in
@@ -105,8 +105,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
     <para>
       <command>lxc-copy</command> creates and optionally starts (ephemeral or
-      non-ephemeral) copies of existing containers. It replaces
-      <command>lxc-clone</command> and <command>lxc-start-ephemeral</command>.
+      non-ephemeral) copies of existing containers.
     </para>
     <para>
       <command>lxc-copy</command> creates copies of existing containers. Copies
diff --git a/doc/lxc-start-ephemeral.sgml.in b/doc/lxc-start-ephemeral.sgml.in
deleted file mode 100644
index 683157871..000000000
--- a/doc/lxc-start-ephemeral.sgml.in
+++ /dev/null
@@ -1,261 +0,0 @@
-
-<!--
-
-(C) Copyright Canonical Ltd. 2013
-
-Authors:
-Stéphane Graber <stgraber at ubuntu.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
--->
-
-<!DOCTYPE refentry PUBLIC @docdtd@ [
-
-<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
-]>
-
-<refentry>
-
-  <docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
-
-  <refmeta>
-    <refentrytitle>lxc-start-ephemeral</refentrytitle>
-    <manvolnum>1</manvolnum>
-  </refmeta>
-
-  <refnamediv>
-    <refname>lxc-start-ephemeral</refname>
-
-    <refpurpose>
-      start an ephemeral copy of an existing container
-    </refpurpose>
-  </refnamediv>
-
-  <refsynopsisdiv>
-    <cmdsynopsis>
-      <command>lxc-start-ephemeral</command>
-      <arg choice="opt">-o</arg>
-      <arg choice="opt">-n</arg>
-      <arg choice="opt">-d</arg>
-      <arg choice="opt">--bdir</arg>
-      <arg choice="opt">--user</arg>
-      <arg choice="opt">--key</arg>
-      <arg choice="opt">--storage-type</arg>
-      <arg choice="opt">--union-type</arg>
-      <arg choice="opt">--keep-data</arg>
-      <arg choice="opt">COMMAND</arg>
-    </cmdsynopsis>
-  </refsynopsisdiv>
-
-  <refsect1>
-    <title>Description</title>
-    <para>
-      <command>lxc-start-ephemeral</command> start an ephemeral copy of an
-      existing container.
-    </para>
-  </refsect1>
-
-  <refsect1>
-    <title>Options</title>
-    <variablelist>
-      <varlistentry>
-        <term>
-          <option>-o, --orig <replaceable>orig</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            Original container name
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-n, --name <replaceable>name</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            Name of the ephemeral container (defaults to a random suffix).
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-d, --daemon</option>
-        </term>
-        <listitem>
-          <para>
-            Start the container in background and print the name and IP.
-            This option can't be used if a command is passed.
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-b, --bdir <replaceable>bdir</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            Directory to bind mount into container.
-            Can be passed multiple times.
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-u, --user <replaceable>user</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            The user to connect to the container as.
-            Used when passing a command to lxc-start-ephemeral.
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-S, --key <replaceable>key</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            Copy the provided SSH public key into the container.
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-s, --storage-type <replaceable>storage type</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            Specify the type of storage used by the container. Valid types are tmpfs or dir.
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-U, --union-type <replaceable>union type</replaceable></option>
-        </term>
-        <listitem>
-          <para>
-            Force a specific union file system.
-            Can be one of: overlayfs aufs
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>-k, --keep-data</option>
-        </term>
-        <listitem>
-          <para>
-            Use a persistent backend instead of tmpfs.
-            With this option, you can lxc-stop and lxc-start the no longer so
-            ephemeral container (it's still an overlay, but a persistent one).
-          </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>
-          <option>COMMAND</option>
-        </term>
-        <listitem>
-          <para>
-            Immediately run the provided command in the container.
-            This uses attach if the kernel supports it, otherwise uses ssh.
-            This is incompatible with daemon mode.
-          </para>
-        </listitem>
-      </varlistentry>
-    </variablelist>
-  </refsect1>
-
-  <refsect1>
-    <title>See Also</title>
-
-    <simpara>
-      <citerefentry>
-        <refentrytitle>lxc-start</refentrytitle>
-        <manvolnum>1</manvolnum>
-      </citerefentry>,
-    </simpara>
-  </refsect1>
-
-  <refsect1>
-    <title>Examples</title>
-    <variablelist>
-      <varlistentry>
-        <term>lxc-start-ephemeral -o p1</term>
-        <listitem>
-        <para>
-          Simply start an ephemeral container and attach to the console.
-          This container will be based on existing container "p1".
-        </para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term>lxc-start-ephemeral -o p1 -n p1-ephemeral -d</term>
-        <listitem>
-        <para>
-          Start an ephemeral container based on p1 called p1-ephemeral and
-          print its IP and name to the console instead of attaching.
-        </para>
-        </listitem>
-      </varlistentry>
-    </variablelist>
-  </refsect1>
-
-  <refsect1>
-    <title>Notes</title>
-    <para>
-    <command>lxc-start-ephemeral</command> is deprecated in favor of
-    <command>lxc-copy</command>.
-    </para>
-  </refsect1>
-
-  &seealso;
-
-  <refsect1>
-    <title>Author</title>
-    <para>Stéphane Graber <email>stgraber at ubuntu.com</email></para>
-  </refsect1>
-</refentry>
-
-<!-- Keep this comment at the end of the file
-Local variables:
-mode: sgml
-sgml-omittag:t
-sgml-shorttag:t
-sgml-minimize-attributes:nil
-sgml-always-quote-attributes:t
-sgml-indent-step:2
-sgml-indent-data:t
-sgml-parent-document:nil
-sgml-default-dtd-file:nil
-sgml-exposed-tags:nil
-sgml-local-catalogs:nil
-sgml-local-ecat-files:nil
-End:
--->
diff --git a/doc/lxc.container.conf.sgml.in b/doc/lxc.container.conf.sgml.in
index 34b8117bb..31db7df8c 100644
--- a/doc/lxc.container.conf.sgml.in
+++ b/doc/lxc.container.conf.sgml.in
@@ -1809,11 +1809,10 @@ dev/null proc/kcore none bind,relative 0 0
           <listitem><para> Section (always 'lxc'). </para></listitem>
           <listitem><para> The hook type (i.e. 'clone' or 'pre-mount'). </para></listitem>
           <listitem><para> Additional arguments. In the
-          case of the clone hook, any extra arguments passed to
-          lxc-clone will appear as further arguments to the hook.
-          In the case of the stop hook, paths to filedescriptors
-          for each of the container's namespaces along with their types
-          are passed. </para></listitem>
+          case of the clone hook, any extra arguments passed will appear as
+          further arguments to the hook.  In the case of the stop hook, paths to
+          filedescriptors for each of the container's namespaces along with
+          their types are passed. </para></listitem>
         </itemizedlist>
         The following environment variables are set:
         <itemizedlist>
diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am
index 7f029de1f..4f0473c57 100644
--- a/src/lxc/Makefile.am
+++ b/src/lxc/Makefile.am
@@ -208,17 +208,6 @@ bin_SCRIPTS += cmd/lxc-checkconfig \
 	       cmd/lxc-update-config
 endif
 
-if ENABLE_TOOLS
-EXTRA_DIST = \
-	tools/lxc-top.lua
-
-if ENABLE_DEPRECATED
-if ENABLE_PYTHON
-bin_SCRIPTS += tools/lxc-start-ephemeral
-endif
-endif
-endif
-
 if ENABLE_TOOLS
 bin_PROGRAMS = \
 	lxc-attach \
@@ -244,10 +233,6 @@ bin_PROGRAMS = \
 	lxc-unshare \
 	lxc-usernsexec \
 	lxc-wait
-
-if ENABLE_DEPRECATED
-bin_PROGRAMS += lxc-clone
-endif
 endif
 
 if ENABLE_COMMANDS
@@ -298,10 +283,6 @@ endif
 
 
 if ENABLE_TOOLS
-if ENABLE_DEPRECATED
-lxc_clone_SOURCES = tools/lxc_clone.c tools/arguments.c
-endif
-
 if !HAVE_GETSUBOPT
 lxc_copy_SOURCES += tools/include/getsubopt.c tools/include/getsubopt.h
 endif
diff --git a/src/lxc/tools/lxc-start-ephemeral.in b/src/lxc/tools/lxc-start-ephemeral.in
deleted file mode 100644
index 90d5f6f02..000000000
--- a/src/lxc/tools/lxc-start-ephemeral.in
+++ /dev/null
@@ -1,418 +0,0 @@
-#!/usr/bin/env python3
-#
-# lxc-start-ephemeral: Start a copy of a container using an overlay
-#
-# This python implementation is based on the work done in the original
-# shell implementation done by Serge Hallyn in Ubuntu (and other contributors)
-#
-# (C) Copyright Canonical Ltd. 2012
-#
-# Authors:
-# Stéphane Graber <stgraber at ubuntu.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-
-import argparse
-import gettext
-import lxc
-import locale
-import os
-import sys
-import subprocess
-import tempfile
-
-_ = gettext.gettext
-gettext.textdomain("lxc-start-ephemeral")
-
-# Other functions
-
-
-def printstderr(*args):
-    print("lxc-start-ephemeral is deprecated in favor of lxc-copy\n",
-          *args, file=sys.stderr)
-
-
-def randomMAC():
-    import random
-
-    mac = [0x00, 0x16, 0x3e,
-           random.randint(0x00, 0x7f),
-           random.randint(0x00, 0xff),
-           random.randint(0x00, 0xff)]
-    return ':'.join(map(lambda x: "%02x" % x, mac))
-
-
-def get_rundir():
-    if os.geteuid() == 0:
-        return "@RUNTIME_PATH@"
-
-    if "XDG_RUNTIME_DIR" in os.environ:
-        return os.environ["XDG_RUNTIME_DIR"]
-
-    if "HOME" in os.environ:
-        return "%s/.cache/lxc/run/" % os.environ["HOME"]
-
-    raise Exception("Unable to find a runtime directory")
-
-
-# Inform that lxc-start-ephemeral is deprecated
-printstderr()
-
-# Begin parsing the command line
-parser = argparse.ArgumentParser(description=_(
-                                 "LXC: Start an ephemeral container"),
-                                 formatter_class=argparse.RawTextHelpFormatter,
-                                 epilog=_("If a COMMAND is given, then the "
-                                          """container will run only as long
-as the command runs.
-If no COMMAND is given, this command will attach to tty1 and stop the
-container when exiting (with ctrl-a-q).
-
-If no COMMAND is given and -d is used, the name and IP addresses of the
-container will be printed to the console."""))
-
-parser.add_argument("--lxcpath", "-P", dest="lxcpath", metavar="PATH",
-                    help=_("Use specified container path"), default=None)
-
-parser.add_argument("--orig", "-o", type=str, required=True,
-                    help=_("name of the original container"))
-
-parser.add_argument("--name", "-n", type=str,
-                    help=_("name of the target container"))
-
-parser.add_argument("--bdir", "-b", type=str, action="append", default=[],
-                    help=_("directory to bind mount into container, "
-                           "either --bdir=/src-path or --bdir=/src-path:/dst-path"))
-
-parser.add_argument("--cdir", "-c", type=str, action="append", default=[],
-                    help=_("directory to cow mount into container"))
-
-parser.add_argument("--user", "-u", type=str,
-                    help=_("the user to run the command as"))
-
-parser.add_argument("--key", "-S", type=str,
-                    help=_("the path to the key to use to connect "
-                           "(when using ssh)"))
-
-parser.add_argument("--daemon", "-d", action="store_true",
-                    help=_("run in the background"))
-
-parser.add_argument("--storage-type", "-s", type=str, default=None,
-                    choices=("tmpfs", "dir"),
-                    help=("type of storage use by the container"))
-
-parser.add_argument("--union-type", "-U", type=str, default="overlayfs",
-                    choices=("overlayfs", "aufs"),
-                    help=_("type of union (overlayfs or aufs), "
-                           "defaults to overlayfs."))
-
-parser.add_argument("--keep-data", "-k", action="store_true",
-                    help=_("don't wipe everything clean at the end"))
-
-parser.add_argument("command", metavar='CMD', type=str, nargs="*",
-                    help=_("Run specific command in container "
-                           "(command as argument)"))
-
-parser.add_argument("--version", action="version", version=lxc.version)
-
-args = parser.parse_args()
-
-# Check that -d and CMD aren't used at the same time
-if args.command and args.daemon:
-    parser.error(_("You can't use -d and a command at the same time."))
-
-# Check that -k isn't used with -s tmpfs
-if not args.storage_type:
-    if args.keep_data:
-        args.storage_type = "dir"
-    else:
-        args.storage_type = "tmpfs"
-
-if args.keep_data and args.storage_type == "tmpfs":
-    parser.error(_("You can't use -k with the tmpfs storage type."))
-
-# Load the orig container
-orig = lxc.Container(args.orig, args.lxcpath)
-if not orig.defined:
-    parser.error(_("Source container '%s' doesn't exist." % args.orig))
-
-# Create the new container paths
-if not args.lxcpath:
-    lxc_path = lxc.default_config_path
-else:
-    lxc_path = args.lxcpath
-
-if args.name:
-    if os.path.exists("%s/%s" % (lxc_path, args.name)):
-        parser.error(_("A container named '%s' already exists." % args.name))
-    dest_path = "%s/%s" % (lxc_path, args.name)
-    os.mkdir(dest_path)
-else:
-    dest_path = tempfile.mkdtemp(prefix="%s-" % args.orig, dir=lxc_path)
-os.mkdir(os.path.join(dest_path, "rootfs"))
-os.chmod(dest_path, 0o770)
-
-# Setup the new container's configuration
-dest = lxc.Container(os.path.basename(dest_path), args.lxcpath)
-dest.load_config(orig.config_file_name)
-dest.set_config_item("lxc.utsname", dest.name)
-dest.set_config_item("lxc.rootfs", os.path.join(dest_path, "rootfs"))
-print("setting rootfs to .%s.", os.path.join(dest_path, "rootfs"))
-for nic in dest.network:
-    if hasattr(nic, 'hwaddr'):
-        nic.hwaddr = randomMAC()
-
-overlay_dirs = [(orig.get_config_item("lxc.rootfs"), "%s/rootfs/" % dest_path)]
-
-# Generate a new fstab
-if orig.get_config_item("lxc.mount"):
-    dest.set_config_item("lxc.mount", os.path.join(dest_path, "fstab"))
-    with open(orig.get_config_item("lxc.mount"), "r") as orig_fd:
-        with open(dest.get_config_item("lxc.mount"), "w+") as dest_fd:
-            for line in orig_fd.read().split("\n"):
-                # Start by replacing any reference to the container rootfs
-                line.replace(orig.get_config_item("lxc.rootfs"),
-                             dest.get_config_item("lxc.rootfs"))
-
-                fields = line.split()
-
-                # Skip invalid entries
-                if len(fields) < 4:
-                    continue
-
-                # Non-bind mounts are kept as-is
-                if "bind" not in fields[3]:
-                    dest_fd.write("%s\n" % line)
-                    continue
-
-                # Bind mounts of virtual filesystems are also kept as-is
-                src_path = fields[0].split("/")
-                if len(src_path) > 1 and src_path[1] in ("proc", "sys"):
-                    dest_fd.write("%s\n" % line)
-                    continue
-
-                # Skip invalid mount points
-                dest_mount = os.path.abspath(os.path.join("%s/rootfs/" % (
-                                             dest_path), fields[1]))
-
-                if "%s/rootfs/" % dest_path not in dest_mount:
-                    print(_("Skipping mount entry '%s' as it's outside "
-                            "of the container rootfs.") % line)
-
-                # Setup an overlay for anything remaining
-                overlay_dirs += [(fields[0], dest_mount)]
-
-for entry in args.cdir:
-    if not os.path.exists(entry):
-        print(_("Path '%s' doesn't exist, won't be cow-mounted.") %
-              entry)
-    else:
-        src_path = os.path.abspath(entry)
-        dst_path = "%s/rootfs/%s" % (dest_path, src_path)
-        overlay_dirs += [(src_path, dst_path)]
-
-# do we have the new overlay fs which requires workdir, or the older
-# overlayfs which does not?
-have_new_overlay = False
-with open("/proc/filesystems", "r") as fd:
-    for line in fd:
-        if line == "nodev\toverlay\n":
-            have_new_overlay = True
-
-# Generate pre-mount script
-with open(os.path.join(dest_path, "pre-mount"), "w+") as fd:
-    os.fchmod(fd.fileno(), 0o755)
-    fd.write("""#!/bin/sh
-LXC_DIR="%s"
-LXC_BASE="%s"
-LXC_NAME="%s"
-""" % (dest_path, orig.name, dest.name))
-
-    count = 0
-    for entry in overlay_dirs:
-        tmpdir = "%s/tmpfs" % dest_path
-        fd.write("mkdir -p %s\n" % (tmpdir))
-        if args.storage_type == "tmpfs":
-            fd.write("mount -n -t tmpfs -o mode=0755 none %s\n" % (tmpdir))
-        deltdir = "%s/delta%s" % (tmpdir, count)
-        workdir = "%s/work%s" % (tmpdir, count)
-        fd.write("mkdir -p %s %s\n" % (deltdir, entry[1]))
-        if have_new_overlay:
-            fd.write("mkdir -p %s\n" % workdir)
-
-        fd.write("getfacl -a %s | setfacl --set-file=- %s || true\n" %
-                 (entry[0], deltdir))
-        fd.write("getfacl -a %s | setfacl --set-file=- %s || true\n" %
-                 (entry[0], entry[1]))
-
-        if args.union_type == "overlayfs":
-            if have_new_overlay:
-                fd.write("mount -n -t overlay"
-                         " -oupperdir=%s,lowerdir=%s,workdir=%s none %s\n" % (
-                             deltdir,
-                             entry[0],
-                             workdir,
-                             entry[1]))
-            else:
-                fd.write("mount -n -t overlayfs"
-                         " -oupperdir=%s,lowerdir=%s none %s\n" % (
-                             deltdir,
-                             entry[0],
-                             entry[1]))
-        elif args.union_type == "aufs":
-            xino_path = "/dev/shm/aufs.xino"
-            if not os.path.exists(os.path.basename(xino_path)):
-                os.makedirs(os.path.basename(xino_path))
-
-            fd.write("mount -n -t aufs "
-                     "-o br=%s=rw:%s=ro,noplink,xino=%s none %s\n" % (
-                         deltdir,
-                         entry[0],
-                         xino_path,
-                         entry[1]))
-        count += 1
-
-    for entry in args.bdir:
-        if ':' in entry:
-            src_path, dst_path = entry.split(":")
-        else:
-            src_path = entry
-            dst_path = os.path.abspath(entry)
-
-        if not os.path.exists(src_path):
-            print(_("Path '%s' doesn't exist, won't be bind-mounted.") %
-                  src_path)
-        else:
-            src_path = os.path.abspath(src_path)
-            dst_path = "%s/rootfs/%s" % (dest_path, dst_path)
-            fd.write("mkdir -p %s\nmount -n --bind %s %s\n" % (
-                     dst_path, src_path, dst_path))
-
-    fd.write("""
-[ -e $LXC_DIR/configured ] && exit 0
-for file in $LXC_DIR/rootfs/etc/hostname \\
-            $LXC_DIR/rootfs/etc/hosts \\
-            $LXC_DIR/rootfs/etc/sysconfig/network \\
-            $LXC_DIR/rootfs/etc/sysconfig/network-scripts/ifcfg-eth0; do
-        [ -f "$file" ] && sed -i -e "s/$LXC_BASE/$LXC_NAME/" $file
-done
-touch $LXC_DIR/configured
-""")
-
-dest.set_config_item("lxc.hook.pre-mount",
-                     os.path.join(dest_path, "pre-mount"))
-
-if not args.keep_data:
-    dest.set_config_item("lxc.ephemeral", "1")
-
-dest.save_config()
-
-# Start the container
-if not dest.start() or not dest.wait("RUNNING", timeout=5):
-    print(_("The container '%s' failed to start.") % dest.name)
-    dest.stop()
-    if dest.defined:
-        dest.destroy()
-    sys.exit(1)
-
-# Deal with the case where we just attach to the container's console
-if not args.command and not args.daemon:
-    dest.console()
-    if not dest.shutdown(timeout=5):
-        dest.stop()
-    sys.exit(0)
-
-# Try to get the IP addresses
-ips = dest.get_ips(timeout=10)
-
-# Deal with the case where we just print info about the container
-if args.daemon:
-    print(_("""The ephemeral container is now started.
-
-You can enter it from the command line with: lxc-console -n %s
-The following IP addresses have be found in the container:
-%s""") % (dest.name,
-          "\n".join([" - %s" % entry for entry in ips]
-                    or [" - %s" % _("No address could be found")])))
-    sys.exit(0)
-
-# Now deal with the case where we want to run a command in the container
-if not ips:
-    print(_("Failed to get an IP for container '%s'.") % dest.name)
-    dest.stop()
-    if dest.defined:
-        dest.destroy()
-    sys.exit(1)
-
-if os.path.exists("/proc/self/ns/pid"):
-    def attach_as_user(command):
-        try:
-            username = "root"
-            if args.user:
-                username = args.user
-
-            # This should really just use universal_newlines=True, but we do
-            # the decoding by hand instead for compatibility with Python
-            # 3.2; that used locale.getpreferredencoding() internally rather
-            # than locale.getpreferredencoding(False), and the former breaks
-            # here because we can't reload codecs at this point unless the
-            # container has the same version of Python installed.
-            line = subprocess.check_output(["getent", "passwd", username])
-            line = line.decode(locale.getpreferredencoding(False)).rstrip("\n")
-            _, _, pw_uid, pw_gid, _, pw_dir, _ = line.split(":", 6)
-            pw_uid = int(pw_uid)
-            pw_gid = int(pw_gid)
-            os.setgid(pw_gid)
-            os.initgroups(username, pw_gid)
-            os.setuid(pw_uid)
-            os.chdir(pw_dir)
-            os.environ['HOME'] = pw_dir
-        except:
-            print(_("Unable to switch to user: %s" % username))
-            sys.exit(1)
-
-        return lxc.attach_run_command(command)
-
-    retval = dest.attach_wait(attach_as_user, args.command,
-                              env_policy=lxc.LXC_ATTACH_CLEAR_ENV)
-
-else:
-    cmd = ["ssh",
-           "-o", "StrictHostKeyChecking=no",
-           "-o", "UserKnownHostsFile=/dev/null"]
-
-    if args.user:
-        cmd += ["-l", args.user]
-
-    if args.key:
-        cmd += ["-i", args.key]
-
-    for ip in ips:
-        ssh_cmd = cmd + [ip] + args.command
-        retval = subprocess.call(ssh_cmd, universal_newlines=True)
-        if retval == 255:
-            print(_("SSH failed to connect, trying next IP address."))
-            continue
-
-        if retval != 0:
-            print(_("Command returned with non-zero return code: %s") % retval)
-        break
-
-# Shutdown the container
-if not dest.shutdown(timeout=5):
-    dest.stop()
-
-sys.exit(retval)
diff --git a/src/lxc/tools/lxc-top.lua b/src/lxc/tools/lxc-top.lua
deleted file mode 100755
index b5b3a695f..000000000
--- a/src/lxc/tools/lxc-top.lua
+++ /dev/null
@@ -1,243 +0,0 @@
-#!/usr/bin/env lua
---
--- top(1) like monitor for lxc containers
---
--- Copyright © 2012 Oracle.
---
--- Authors:
--- Dwight Engen <dwight.engen at oracle.com>
---
--- This library is free software; you can redistribute it and/or modify
--- it under the terms of the GNU General Public License version 2, as
--- published by the Free Software Foundation.
---
--- This program 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 General Public License for more details.
---
--- You should have received a copy of the GNU General Public License along
--- with this program; if not, write to the Free Software Foundation, Inc.,
--- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
---
-
-local lxc    = require("lxc")
-local core   = require("lxc.core")
-local getopt = require("alt_getopt")
-
-local USER_HZ   = 100
-local ESC       = string.format("%c", 27)
-local TERMCLEAR = ESC.."[H"..ESC.."[J"
-local TERMNORM  = ESC.."[0m"
-local TERMBOLD  = ESC.."[1m"
-local TERMRVRS  = ESC.."[7m"
-
-local containers = {}
-local stats = {}
-local stats_total = {}
-local max_containers
-
-function printf(...)
-    local function wrapper(...) io.write(string.format(...)) end
-    local status, result = pcall(wrapper, ...)
-    if not status then
-	error(result, 2)
-    end
-end
-
-function string:split(delim, max_cols)
-    local cols = {}
-    local start = 1
-    local nextc
-    repeat
-	nextc = string.find(self, delim, start)
-	if (nextc and #cols ~= max_cols - 1) then
-	    table.insert(cols, string.sub(self, start, nextc-1))
-	    start = nextc + #delim
-	else
-	    table.insert(cols, string.sub(self, start, string.len(self)))
-	    nextc = nil
-	end
-    until nextc == nil or start > #self
-    return cols
-end
-
-function strsisize(size, width)
-    local KiB = 1024
-    local MiB = 1048576
-    local GiB = 1073741824
-    local TiB = 1099511627776
-    local PiB = 1125899906842624
-    local EiB = 1152921504606846976
-    local ZiB = 1180591620717411303424
-
-    if (size >= ZiB) then
-	return string.format("%d.%2.2d ZB", size / ZiB, (math.floor(size % ZiB) * 100) / ZiB)
-    end
-    if (size >= EiB) then
-	return string.format("%d.%2.2d EB", size / EiB, (math.floor(size % EiB) * 100) / EiB)
-    end
-    if (size >= PiB) then
-	return string.format("%d.%2.2d PB", size / PiB, (math.floor(size % PiB) * 100) / PiB)
-    end
-    if (size >= TiB) then
-	return string.format("%d.%2.2d TB", size / TiB, (math.floor(size % TiB) * 100) / TiB)
-    end
-    if (size >= GiB) then
-	return string.format("%d.%2.2d GB", size / GiB, (math.floor(size % GiB) * 100) / GiB)
-    end
-    if (size >= MiB) then
-	return string.format("%d.%2.2d MB", size / MiB, (math.floor(size % MiB) * 1000) / (MiB * 10))
-    end
-    if (size >= KiB) then
-	return string.format("%d.%2.2d KB", size / KiB, (math.floor(size % KiB) * 1000) / (KiB * 10))
-    end
-    return string.format("%3d.00   ", size)
-end
-
-function tty_lines()
-    local rows = 25
-    local f = assert(io.popen("stty -a | head -n 1"))
-    for line in f:lines() do
-	local stty_rows
-	_,_,stty_rows = string.find(line, "rows (%d+)")
-	if (stty_rows ~= nil) then
-	    rows = stty_rows
-	    break
-	end
-    end
-    f:close()
-    return rows
-end
-
-function container_sort(a, b)
-    if (optarg["r"]) then
-	if     (optarg["s"] == "n") then return (a > b)
-	elseif (optarg["s"] == "c") then return (stats[a].cpu_use_nanos < stats[b].cpu_use_nanos)
-	elseif (optarg["s"] == "d") then return (stats[a].blkio < stats[b].blkio)
-	elseif (optarg["s"] == "m") then return (stats[a].mem_used < stats[b].mem_used)
-	elseif (optarg["s"] == "k") then return (stats[a].kmem_used < stats[b].kmem_used)
-	end
-    else
-	if     (optarg["s"] == "n") then return (a < b)
-	elseif (optarg["s"] == "c") then return (stats[a].cpu_use_nanos > stats[b].cpu_use_nanos)
-	elseif (optarg["s"] == "d") then return (stats[a].blkio > stats[b].blkio)
-	elseif (optarg["s"] == "m") then return (stats[a].mem_used > stats[b].mem_used)
-	elseif (optarg["s"] == "k") then return (stats[a].kmem_used > stats[b].kmem_used)
-	end
-    end
-end
-
-function container_list_update()
-    local now_running
-
-    now_running = lxc.containers_running(true)
-
-    -- check for newly started containers
-    for _,v in ipairs(now_running) do
-	if (containers[v] == nil) then
-	    local ct = lxc.container:new(v)
-	    -- note, this is a "mixed" table, ie both dictionary and list
-	    containers[v] = ct
-	    table.insert(containers, v)
-	end
-    end
-
-    -- check for newly stopped containers
-    local indx = 1
-    while (indx <= #containers) do
-	local ctname = containers[indx]
-	if (now_running[ctname] == nil) then
-	    containers[ctname] = nil
-	    stats[ctname] = nil
-	    table.remove(containers, indx)
-	else
-	    indx = indx + 1
-	end
-    end
-
-    -- get stats for all current containers and resort the list
-    lxc.stats_clear(stats_total)
-    for _,ctname in ipairs(containers) do
-	stats[ctname] = containers[ctname]:stats_get(stats_total)
-    end
-    table.sort(containers, container_sort)
-end
-
-function stats_print_header(stats_total)
-    printf(TERMRVRS .. TERMBOLD)
-    printf("%-15s %8s %8s %8s %10s %10s", "Container", "CPU",  "CPU",  "CPU",  "BlkIO", "Mem")
-    if (stats_total.kmem_used > 0) then printf(" %10s", "KMem") end
-    printf("\n")
-
-    printf("%-15s %8s %8s %8s %10s %10s", "Name",      "Used", "Sys",  "User", "Total", "Used")
-    if (stats_total.kmem_used > 0) then printf(" %10s", "Used") end
-    printf("\n")
-    printf(TERMNORM)
-end
-
-function stats_print(name, stats, stats_total)
-    printf("%-15s %8.2f %8.2f %8.2f %10s %10s",
-	   name,
-	   stats.cpu_use_nanos / 1000000000,
-	   stats.cpu_use_sys  / USER_HZ,
-	   stats.cpu_use_user / USER_HZ,
-	   strsisize(stats.blkio),
-	   strsisize(stats.mem_used))
-    if (stats_total.kmem_used > 0) then
-	printf(" %10s", strsisize(stats.kmem_used))
-    end
-end
-
-function usage()
-    printf("Usage: lxc-top [options]\n" ..
-	"  -h|--help      print this help message\n" ..
-	"  -m|--max       display maximum number of containers\n" ..
-	"  -d|--delay     delay in seconds between refreshes (default: 3.0)\n" ..
-	"  -s|--sort      sort by [n,c,d,m] (default: n) where\n" ..
-	"                 n = Name\n" ..
-	"                 c = CPU use\n" ..
-	"                 d = Disk I/O use\n" ..
-	"                 m = Memory use\n" ..
-	"                 k = Kernel memory use\n" ..
-	"  -r|--reverse   sort in reverse (descending) order\n"
-    )
-    os.exit(1)
-end
-
-local long_opts = {
-    help      = "h",
-    delay     = "d",
-    max       = "m",
-    reverse   = "r",
-    sort      = "s",
-}
-
-optarg,optind = alt_getopt.get_opts (arg, "hd:m:rs:", long_opts)
-optarg["d"] = tonumber(optarg["d"]) or 3.0
-optarg["m"] = tonumber(optarg["m"]) or tonumber(tty_lines() - 3)
-optarg["r"] = optarg["r"] or false
-optarg["s"] = optarg["s"] or "n"
-if (optarg["h"] ~= nil) then
-    usage()
-end
-
-while true
-do
-    container_list_update()
-    -- if some terminal we care about doesn't support the simple escapes, we
-    -- may fall back to this, or ncurses. ug.
-    --os.execute("tput clear")
-    printf(TERMCLEAR)
-    stats_print_header(stats_total)
-    for index,ctname in ipairs(containers) do
-	stats_print(ctname, stats[ctname], stats_total)
-	printf("\n")
-	if (index >= optarg["m"]) then
-	    break
-	end
-    end
-    stats_print(string.format("TOTAL (%-2d)", #containers), stats_total, stats_total)
-    io.flush()
-    core.usleep(optarg["d"] * 1000000)
-end
diff --git a/src/lxc/tools/lxc_clone.c b/src/lxc/tools/lxc_clone.c
deleted file mode 100644
index b76d8669f..000000000
--- a/src/lxc/tools/lxc_clone.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- *
- * Copyright © 2013 Serge Hallyn <serge.hallyn at ubuntu.com>.
- * Copyright © 2013 Canonical Ltd.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2, as
- * published by the Free Software Foundation.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <ctype.h>
-#include <errno.h>
-#include <getopt.h>
-#include <signal.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#include <lxc/lxccontainer.h>
-
-/* we pass fssize in bytes */
-static uint64_t get_fssize(char *s)
-{
-	uint64_t ret;
-	char *end;
-
-	ret = strtoull(s, &end, 0);
-	if (end == s) {
-		fprintf(stderr,
-			"Invalid blockdev size '%s', using default size\n", s);
-		return 0;
-	}
-
-	while (isblank(*end))
-		end++;
-	if (*end == '\0') {
-		ret *= 1024ULL * 1024ULL; /* MB by default */
-	} else if (*end == 'b' || *end == 'B') {
-		ret *= 1ULL;
-	} else if (*end == 'k' || *end == 'K') {
-		ret *= 1024ULL;
-	} else if (*end == 'm' || *end == 'M') {
-		ret *= 1024ULL * 1024ULL;
-	} else if (*end == 'g' || *end == 'G') {
-		ret *= 1024ULL * 1024ULL * 1024ULL;
-	} else if (*end == 't' || *end == 'T') {
-		ret *= 1024ULL * 1024ULL * 1024ULL * 1024ULL;
-	} else {
-		fprintf(stderr, "Invalid blockdev unit size '%c' in '%s', "
-				"using default size\n",
-			*end, s);
-		return 0;
-	}
-
-	return ret;
-}
-
-static void usage(const char *me)
-{
-	printf("Usage: %s [-s] [-B backingstore] [-L size[unit]] [-K] [-M] [-H]\n", me);
-	printf("          [-p lxcpath] [-P newlxcpath] orig new\n");
-	printf("\n");
-	printf("  -s: snapshot rather than copy\n");
-	printf("  -B: use specified new backingstore.  Default is the same as\n");
-	printf("      the original.  Options include aufs, btrfs, lvm, overlayfs, \n");
-	printf("      dir and loop\n");
-	printf("  -L: for blockdev-backed backingstore, use specified size * specified\n");
-	printf("      unit. Default size is the size of the source blockdev, default\n");
-	printf("      unit is MB\n");
-	printf("  -K: Keep name - do not change the container name\n");
-	printf("  -M: Keep macaddr - do not choose a random new mac address\n");
-	printf("  -p: use container orig from custom lxcpath\n");
-	printf("  -P: create container new in custom lxcpath\n");
-	printf("  -R: rename existing container\n");
-	exit(EXIT_SUCCESS);
-}
-
-static struct option options[] = {
-	{ "snapshot", no_argument, 0, 's'},
-	{ "backingstore", required_argument, 0, 'B'},
-	{ "size", required_argument, 0, 'L'},
-	{ "orig", required_argument, 0, 'o'},
-	{ "new", required_argument, 0, 'n'},
-	{ "vgname", required_argument, 0, 'v'},
-	{ "rename", no_argument, 0, 'R'},
-	{ "keepname", no_argument, 0, 'K'},
-	{ "keepmac", no_argument, 0, 'M'},
-	{ "lxcpath", required_argument, 0, 'p'},
-	{ "newpath", required_argument, 0, 'P'},
-	{ "fstype", required_argument, 0, 't'},
-	{ "help", no_argument, 0, 'h'},
-	{ 0, 0, 0, 0 },
-};
-
-int main(int argc, char *argv[])
-{
-	struct lxc_container *c1 = NULL, *c2 = NULL;
-	int snapshot = 0, keepname = 0, keepmac = 0, rename = 0;
-	int flags = 0, option_index;
-	uint64_t newsize = 0;
-	char *bdevtype = NULL, *lxcpath = NULL, *newpath = NULL, *fstype = NULL;
-	char *orig = NULL, *new = NULL, *vgname = NULL;
-	char **args = NULL;
-	int c;
-	bool ret;
-
-	fprintf(stderr, "lxc-clone is deprecated in favor of lxc-copy.\n\n");
-
-	if (argc < 3)
-		usage(argv[0]);
-
-	while (true) {
-		c = getopt_long(argc, argv, "sB:L:o:n:v:KMHp:P:Rt:h", options,
-				&option_index);
-		if (c == -1)
-			break;
-		switch (c) {
-		case 's':
-			snapshot = 1;
-			break;
-		case 'B':
-			bdevtype = optarg;
-			break;
-		case 'L':
-			newsize = get_fssize(optarg);
-			break;
-		case 'o':
-			orig = optarg;
-			break;
-		case 'n':
-			new = optarg;
-			break;
-		case 'v':
-			vgname = optarg;
-			break;
-		case 'K':
-			keepname = 1;
-			break;
-		case 'M':
-			keepmac = 1;
-			break;
-		case 'p':
-			lxcpath = optarg;
-			break;
-		case 'P':
-			newpath = optarg;
-			break;
-		case 'R':
-			rename = 1;
-			break;
-		case 't':
-			fstype = optarg;
-			break;
-		case 'h':
-			usage(argv[0]);
-		default:
-			break;
-		}
-	}
-
-	if (optind < argc && !orig)
-		orig = argv[optind++];
-
-	if (optind < argc && !new)
-		new = argv[optind++];
-
-	/* arguments for the clone hook */
-	if (optind < argc)
-		args = &argv[optind];
-
-	if (!new || !orig) {
-		printf("Error: you must provide orig and new names\n");
-		usage(argv[0]);
-	}
-
-	if (snapshot)
-		flags |= LXC_CLONE_SNAPSHOT;
-	if (keepname)
-		flags |= LXC_CLONE_KEEPNAME;
-	if (keepmac)
-		flags |= LXC_CLONE_KEEPMACADDR;
-
-	/* vgname and fstype could be supported by sending them through the
-	 * bdevdata.  However, they currently are not yet.  I'm not convinced
-	 * they are worthwhile.
-	 */
-	if (vgname) {
-		printf("Error: vgname not supported\n");
-		usage(argv[0]);
-	}
-	if (fstype) {
-		printf("Error: fstype not supported\n");
-		usage(argv[0]);
-	}
-
-	c1 = lxc_container_new(orig, lxcpath);
-	if (!c1)
-		exit(EXIT_FAILURE);
-
-	if (!c1->may_control(c1)) {
-		fprintf(stderr, "Insufficent privileges to control %s\n", orig);
-		lxc_container_put(c1);
-		exit(EXIT_FAILURE);
-	}
-
-	if (!c1->is_defined(c1)) {
-		fprintf(stderr, "Error: container %s is not defined\n", orig);
-		lxc_container_put(c1);
-		exit(EXIT_FAILURE);
-	}
-	if (rename) {
-		ret = c1->rename(c1, new);
-		if (!ret) {
-			fprintf(stderr,
-				"Error: Renaming container %s to %s failed\n",
-				c1->name, new);
-			lxc_container_put(c1);
-			exit(EXIT_FAILURE);
-		}
-	} else {
-		c2 = c1->clone(c1, new, newpath, flags, bdevtype, NULL, newsize, args);
-		if (c2 == NULL) {
-			lxc_container_put(c1);
-			fprintf(stderr, "clone failed\n");
-			exit(EXIT_FAILURE);
-		}
-		printf("Created container %s as %s of %s\n", new,
-		       snapshot ? "snapshot" : "copy", orig);
-		lxc_container_put(c2);
-	}
-	lxc_container_put(c1);
-
-	exit(EXIT_SUCCESS);
-}
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index 602f5a1a6..e6dd7fec1 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -65,7 +65,9 @@ bin_PROGRAMS = lxc-test-containertests lxc-test-locktests lxc-test-startone \
 	lxc-test-api-reboot lxc-test-state-server lxc-test-share-ns \
 	lxc-test-criu-check-feature lxc-test-raw-clone
 
-bin_SCRIPTS = lxc-test-automount \
+bin_SCRIPTS =
+if ENABLE_TOOLS
+bin_SCRIPTS += lxc-test-automount \
 	      lxc-test-autostart \
 	      lxc-test-cloneconfig \
 	      lxc-test-createconfig \
@@ -83,6 +85,7 @@ bin_SCRIPTS += \
 	lxc-test-unpriv \
 	lxc-test-usernic
 endif
+endif
 
 endif
 

From b1ae1a511c338b48975d9f1a6cf2ddb5e0d0206e Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 14 Feb 2018 11:48:20 +0100
Subject: [PATCH 3/4] tree-wide: remove lua bindings

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 .travis.yml                  |   2 +-
 Makefile.am                  |   4 -
 configure.ac                 |  51 ----
 lxc.spec.in                  |  21 --
 src/Makefile.am              |   2 +-
 src/lua-lxc/Makefile.am      |  38 ---
 src/lua-lxc/core.c           | 614 -------------------------------------------
 src/lua-lxc/lxc.lua          | 421 -----------------------------
 src/lua-lxc/test/apitest.lua | 353 -------------------------
 9 files changed, 2 insertions(+), 1504 deletions(-)
 delete mode 100644 src/lua-lxc/Makefile.am
 delete mode 100644 src/lua-lxc/core.c
 delete mode 100755 src/lua-lxc/lxc.lua
 delete mode 100755 src/lua-lxc/test/apitest.lua

diff --git a/.travis.yml b/.travis.yml
index d078b0222..ca354ccc0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,7 +18,7 @@ before_install:
  - echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-
  - sudo add-apt-repository ppa:ubuntu-lxc/daily -y
  - sudo apt-get update -qq
- - sudo apt-get install -qq libapparmor-dev libcap-dev libseccomp-dev python3-dev python3-setuptools docbook2x libgnutls-dev liblua5.2-dev libselinux1-dev
+ - sudo apt-get install -qq libapparmor-dev libcap-dev libseccomp-dev python3-dev python3-setuptools docbook2x libgnutls-dev libselinux1-dev
 script:
  - ./autogen.sh
  - rm -Rf build
diff --git a/Makefile.am b/Makefile.am
index 4071ec929..14712bc43 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,10 +13,6 @@ EXTRA_DIST = \
 
 RPMARGS =
 
-if ENABLE_LUA
-RPMARGS += --with lua
-endif
-
 if ENABLE_PYTHON
 RPMARGS += --with python
 endif
diff --git a/configure.ac b/configure.ac
index 62f23f80a..a1bf65614 100644
--- a/configure.ac
+++ b/configure.ac
@@ -416,53 +416,6 @@ m4_ifdef([PKG_CHECK_VAR], [],
     ])# PKG_CHECK_VAR
 ])
 
-# Lua module and scripts
-AC_ARG_ENABLE([lua],
-	[AC_HELP_STRING([--enable-lua], [enable lua binding [default=auto]])],
-	[], [enable_lua=auto])
-
-AC_ARG_WITH([lua-pc],
-	[AS_HELP_STRING(
-		[--with-lua-pc=PKG],
-		[Specify pkg-config package name for lua]
-	)], [], [with_lua_pc=no])
-
-if test "x$enable_lua" = "xyes" -a "x$with_lua_pc" != "xno"; then
-	# exit with error if not found
-	PKG_CHECK_MODULES([LUA], [$with_lua_pc], [LUAPKGCONFIG=$with_lua_pc])
-fi
-
-if test "x$enable_lua" = "xauto" -a "x$with_lua_pc" != "xno"; then
-	PKG_CHECK_MODULES([LUA], [$with_lua_pc],
-		[LUAPKGCONFIG=$with_lua_pc
-		enable_lua=yes],
-		[enable_lua=no])
-fi
-
-if test "x$enable_lua" != "xno"; then
-	PKG_CHECK_MODULES([LUA], [lua], [LUAPKGCONFIG=lua],
-		[PKG_CHECK_MODULES([LUA], [lua5.2], [LUAPKGCONFIG=lua5.2],
-			[PKG_CHECK_MODULES([LUA], [lua5.1], [LUAPKGCONFIG=lua5.1],
-				[AS_IF([test "x$enable_lua" = "xyes"],
-					[AC_MSG_ERROR([Lua not found. Please use --with-lua-pc=PKG])],
-					[enable_lua=no])]
-			)]
-		)])
-	AS_IF([test "x$LUAPKGCONFIG" != "x"], [enable_lua=yes])
-fi
-
-AM_CONDITIONAL([ENABLE_LUA],
-	[test "x$enable_lua" = "xyes"])
-
-AM_COND_IF([ENABLE_LUA],
-	[AC_MSG_CHECKING([Lua version])
-	PKG_CHECK_VAR([LUA_VERSION], [$LUAPKGCONFIG], [V],,
-		[PKG_CHECK_VAR([LUA_VERSION], [$LUAPKGCONFIG], [major_version])])
-	AC_MSG_RESULT([$LUA_VERSION])
-	AC_SUBST([LUA_LIBDIR], [$libdir/lua/$LUA_VERSION])
-	AC_SUBST([LUA_SHAREDIR], [$datadir/lua/$LUA_VERSION])
-	])
-
 # Optional bash integration
 AC_ARG_ENABLE([bash],
 	[AC_HELP_STRING([--enable-bash], [build bash integration [default=yes]])],
@@ -905,8 +858,6 @@ AC_CONFIG_FILES([
 	src/lxc/version.h
 	src/python-lxc/Makefile
 
-	src/lua-lxc/Makefile
-
 	src/tests/Makefile
 	src/tests/lxc-test-usernic
 ])
@@ -963,9 +914,7 @@ Security features:
  - Linux capabilities: $enable_capabilities
  - seccomp: $enable_seccomp
  - SELinux: $enable_selinux
-
 Bindings:
- - lua: $enable_lua
  - python3: $enable_python
 
 Documentation:
diff --git a/lxc.spec.in b/lxc.spec.in
index 9aa7dd4c8..f750b1e18 100644
--- a/lxc.spec.in
+++ b/lxc.spec.in
@@ -21,7 +21,6 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 %global with_python %{?_with_python: 1} %{?!_with_python: 0}
-%global with_lua %{?_with_lua: 1} %{?!_with_lua: 0}
 
 # Set with_systemd on distros that use it, so we can install the service
 # file, otherwise the sysvinit script will be installed
@@ -124,23 +123,10 @@ Requires:	%{name} = %{version}-%{release}, pkgconfig
 The %{name}-devel package contains header files and library needed for
 development of the Linux containers.
 
-%if %{with_lua}
-%package	lua
-Summary:	Lua bindings for %{name}
-Group:		System Environment/Libraries
-Requires:	lua-filesystem lua-alt-getopt
-BuildRequires:	lua-devel
-%description	lua
-The %{name}-lua package contains %{name} bindings for lua.
-%endif
-
 %prep
 %setup -q -n %{name}-%{version}%{?beta_dot}
 %build
 PATH=$PATH:/usr/sbin:/sbin %configure $args \
-%if %{with_lua}
-  --enable-lua \
-%endif
 %if %{with_python}
   --enable-python \
 %endif
@@ -284,13 +270,6 @@ fi
 %{python3_sitearch}/*
 %endif
 
-%if %{with_lua}
-%files lua
-%defattr(-,root,root)
-%{_datadir}/lua
-%{_libdir}/lua
-%endif
-
 %files devel
 %defattr(-,root,root)
 %{_includedir}/%{name}/*
diff --git a/src/Makefile.am b/src/Makefile.am
index c96cbe79f..4e4d66b5e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1 +1 @@
-SUBDIRS = lxc tests python-lxc lua-lxc
+SUBDIRS = lxc tests python-lxc
diff --git a/src/lua-lxc/Makefile.am b/src/lua-lxc/Makefile.am
deleted file mode 100644
index 348de8d38..000000000
--- a/src/lua-lxc/Makefile.am
+++ /dev/null
@@ -1,38 +0,0 @@
-if ENABLE_LUA
-
-luasharedir=$(LUA_SHAREDIR)
-lualibdir=$(LUA_LIBDIR)
-luadir=$(luasharedir)
-sodir=$(lualibdir)/lxc
-
-lua_DATA=lxc.lua
-
-lib_LTLIBRARIES = libcore.la
-libcore_la_SOURCES = core.c
-
-AM_CFLAGS=-I$(top_builddir)/src -I$(top_srcdir)/src $(LUA_CFLAGS) -DVERSION=\"$(VERSION)\" -DLXCPATH=\"$(LXCPATH)\"
-
-libcore_la_CFLAGS = -fPIC -DPIC $(AM_CFLAGS)
-
-libcore_la_LDFLAGS = \
-	-shared \
-	-L$(top_builddir)/src/lxc \
-	-Wl,-soname,core.so.$(firstword $(subst ., ,$(VERSION)))
-
-libcore_la_LIBADD = -llxc
-
-install-exec-local: install-libLTLIBRARIES
-	mkdir -p $(DESTDIR)$(lualibdir)/lxc/
-	mv $(DESTDIR)$(libdir)/libcore.so.0.0.0 $(DESTDIR)$(lualibdir)/lxc/core.so
-	rm $(DESTDIR)$(libdir)/libcore.*
-
-uninstall-local:
-	$(RM) $(DESTDIR)$(lualibdir)/lxc/core.so*
-
-lxc.lua:
-
-endif
-
-EXTRA_DIST= \
-	lxc.lua \
-	test/apitest.lua
diff --git a/src/lua-lxc/core.c b/src/lua-lxc/core.c
deleted file mode 100644
index 3fb915ba4..000000000
--- a/src/lua-lxc/core.c
+++ /dev/null
@@ -1,614 +0,0 @@
-/*
- * lua-lxc: lua bindings for lxc
- *
- * Copyright © 2012 Oracle.
- *
- * Authors:
- * Dwight Engen <dwight.engen at oracle.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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#define LUA_LIB
-#define _GNU_SOURCE
-#include <lua.h>
-#include <lauxlib.h>
-#include <assert.h>
-#include <string.h>
-#include <unistd.h>
-#include <libgen.h>
-#include <lxc/lxccontainer.h>
-#include "lxc/commands.h"
-
-#if LUA_VERSION_NUM < 502
-#define luaL_newlib(L,l) (lua_newtable(L), luaL_register(L,NULL,l))
-#define luaL_setfuncs(L,l,n) (assert(n==0), luaL_register(L,NULL,l))
-#define luaL_checkunsigned(L,n) luaL_checknumber(L,n)
-#endif
-
-#if LUA_VERSION_NUM >= 503
-#ifndef luaL_checkunsigned
-#define luaL_checkunsigned(L,n) ((lua_Unsigned)luaL_checkinteger(L,n))
-#endif
-#endif
-
-#ifdef NO_CHECK_UDATA
-#define checkudata(L,i,tname)	lua_touserdata(L, i)
-#else
-#define checkudata(L,i,tname)	luaL_checkudata(L, i, tname)
-#endif
-
-#define lua_boxpointer(L,u) \
-    (*(void **) (lua_newuserdata(L, sizeof(void *))) = (u))
-
-#define lua_unboxpointer(L,i,tname) \
-    (*(void **) (checkudata(L, i, tname)))
-
-#define CONTAINER_TYPENAME	"lxc.container"
-
-/* Max Lua arguments for function */
-#define MAXVARS	200
-
-static int container_new(lua_State *L)
-{
-    struct lxc_container *c;
-    const char *name = luaL_checkstring(L, 1);
-    const char *configpath = NULL;
-    int argc = lua_gettop(L);
-
-    if (argc > 1)
-	configpath = luaL_checkstring(L, 2);
-
-    c = lxc_container_new(name, configpath);
-    if (c) {
-	lua_boxpointer(L, c);
-	luaL_getmetatable(L, CONTAINER_TYPENAME);
-	lua_setmetatable(L, -2);
-    } else {
-	lua_pushnil(L);
-    }
-    return 1;
-}
-
-static int container_gc(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-
-    /* XXX what to do if this fails? */
-    lxc_container_put(c);
-    return 0;
-}
-
-static int container_config_file_name(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    char *config_file_name;
-
-    config_file_name = c->config_file_name(c);
-    lua_pushstring(L, config_file_name);
-    free(config_file_name);
-    return 1;
-}
-
-static int container_defined(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-
-    lua_pushboolean(L, !!c->is_defined(c));
-    return 1;
-}
-
-static int container_name(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-
-    lua_pushstring(L, c->name);
-    return 1;
-}
-
-static int container_create(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    char *template_name = strdupa(luaL_checkstring(L, 2));
-    int argc = lua_gettop(L);
-    char **argv;
-    int i;
-
-    argv = alloca((argc+1) * sizeof(char *));
-    for (i = 0; i < argc-2; i++)
-	argv[i] = strdupa(luaL_checkstring(L, i+3));
-    argv[i] = NULL;
-
-    lua_pushboolean(L, !!c->create(c, template_name, NULL, NULL, 0, argv));
-    return 1;
-}
-
-static int container_destroy(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-
-    lua_pushboolean(L, !!c->destroy(c));
-    return 1;
-}
-
-/* container state */
-static int container_start(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    int argc = lua_gettop(L);
-    char **argv = NULL;
-    int i,j;
-    int useinit = 0;
-
-    if (argc > 1) {
-	argv = alloca((argc+1) * sizeof(char *));
-	for (i = 0, j = 0; i < argc-1; i++) {
-	    const char *arg = luaL_checkstring(L, i+2);
-
-	    if (!strcmp(arg, "useinit"))
-		useinit = 1;
-	    else
-		argv[j++] = strdupa(arg);
-	}
-	argv[j] = NULL;
-    }
-
-    c->want_daemonize(c, true);
-    lua_pushboolean(L, !!c->start(c, useinit, argv));
-    return 1;
-}
-
-static int container_stop(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-
-    lua_pushboolean(L, !!c->stop(c));
-    return 1;
-}
-
-static int container_shutdown(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    int timeout = luaL_checkinteger(L, 2);
-
-    lua_pushboolean(L, !!c->shutdown(c, timeout));
-    return 1;
-}
-
-static int container_wait(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    const char *state = luaL_checkstring(L, 2);
-    int timeout = luaL_checkinteger(L, 3);
-
-    lua_pushboolean(L, !!c->wait(c, state, timeout));
-    return 1;
-}
-
-static int container_rename(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    const char *new_name;
-    int argc = lua_gettop(L);
-
-    if (argc > 1) {
-	new_name = luaL_checkstring(L, 2);
-	lua_pushboolean(L, !!c->rename(c, new_name));
-    } else
-	lua_pushnil(L);
-    return 1;
-}
-
-static int container_freeze(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-
-    lua_pushboolean(L, !!c->freeze(c));
-    return 1;
-}
-
-static int container_unfreeze(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-
-    lua_pushboolean(L, !!c->unfreeze(c));
-    return 1;
-}
-
-static int container_running(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-
-    lua_pushboolean(L, !!c->is_running(c));
-    return 1;
-}
-
-static int container_state(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-
-    lua_pushstring(L, c->state(c));
-    return 1;
-}
-
-static int container_init_pid(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-
-    lua_pushinteger(L, c->init_pid(c));
-    return 1;
-}
-
-/* configuration file methods */
-static int container_load_config(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    int arg_cnt = lua_gettop(L);
-    const char *alt_path = NULL;
-
-    if (arg_cnt > 1)
-	alt_path = luaL_checkstring(L, 2);
-
-    lua_pushboolean(L, !!c->load_config(c, alt_path));
-    return 1;
-}
-
-static int container_save_config(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    int arg_cnt = lua_gettop(L);
-    const char *alt_path = NULL;
-
-    if (arg_cnt > 1)
-	alt_path = luaL_checkstring(L, 2);
-
-    lua_pushboolean(L, !!c->save_config(c, alt_path));
-    return 1;
-}
-
-static int container_get_config_path(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    const char *config_path;
-
-    config_path = c->get_config_path(c);
-    lua_pushstring(L, config_path);
-    return 1;
-}
-
-static int container_set_config_path(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    const char *config_path = luaL_checkstring(L, 2);
-
-    lua_pushboolean(L, !!c->set_config_path(c, config_path));
-    return 1;
-}
-
-static int container_clear_config_item(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    const char *key = luaL_checkstring(L, 2);
-
-    lua_pushboolean(L, !!c->clear_config_item(c, key));
-    return 1;
-}
-
-static int container_get_cgroup_item(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    const char *key = luaL_checkstring(L, 2);
-    int len;
-    char *value;
-
-    len = c->get_cgroup_item(c, key, NULL, 0);
-    if (len <= 0)
-	goto not_found;
-
-    value = alloca(sizeof(char)*len + 1);
-    if (c->get_cgroup_item(c, key, value, len + 1) != len)
-	goto not_found;
-
-    lua_pushstring(L, value);
-    return 1;
-
-not_found:
-    lua_pushnil(L);
-    return 1;
-}
-
-static int container_get_config_item(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    const char *key = luaL_checkstring(L, 2);
-    int len;
-    char *value;
-
-    len = c->get_config_item(c, key, NULL, 0);
-    if (len <= 0)
-	goto not_found;
-
-    value = alloca(sizeof(char)*len + 1);
-    if (c->get_config_item(c, key, value, len + 1) != len)
-	goto not_found;
-
-    lua_pushstring(L, value);
-    return 1;
-
-not_found:
-    lua_pushnil(L);
-    return 1;
-}
-
-static int container_set_cgroup_item(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    const char *key = luaL_checkstring(L, 2);
-    const char *value = luaL_checkstring(L, 3);
-
-    lua_pushboolean(L, !!c->set_cgroup_item(c, key, value));
-    return 1;
-}
-
-static int container_set_config_item(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    const char *key = luaL_checkstring(L, 2);
-    const char *value = luaL_checkstring(L, 3);
-
-    lua_pushboolean(L, !!c->set_config_item(c, key, value));
-    return 1;
-}
-
-static int container_get_keys(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    const char *key = NULL;
-    int len;
-    char *value;
-    int arg_cnt = lua_gettop(L);
-
-    if (arg_cnt > 1)
-	key = luaL_checkstring(L, 2);
-
-    len = c->get_keys(c, key, NULL, 0);
-    if (len <= 0)
-	goto not_found;
-
-    value = alloca(sizeof(char)*len + 1);
-    if (c->get_keys(c, key, value, len + 1) != len)
-	goto not_found;
-
-    lua_pushstring(L, value);
-    return 1;
-
-not_found:
-    lua_pushnil(L);
-    return 1;
-}
-
-static int container_attach(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    int argc = lua_gettop(L);
-    char **argv = NULL;
-    int i;
-
-    if (argc > 1) {
-	argv = alloca((argc+1) * sizeof(char *));
-	for (i = 0; i < argc-1; i++) {
-		const char *arg = luaL_checkstring(L, i+2);
-		argv[i] = strdupa(arg);
-	}
-	argv[i] = NULL;
-    }
-    else
-    {
-    	lua_pushnil(L);
-    	return 1;
-    }
-
-    lua_pushboolean(L, !(c->attach_run_wait(c, NULL, argv[0], (const char**)argv)));
-    return 1;
-}
-
-static int container_get_interfaces(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    char **ifaces;
-    int i;
-
-    ifaces = c->get_interfaces(c);
-
-    if (!ifaces){
-	lua_pushnil(L);
-	return 1;
-    }
-
-    for (i = 0; ifaces[i]; i++);
-
-    /* protect LUA stack form overflow */
-    if (i > MAXVARS || !lua_checkstack(L, i)){
-        for (i = 0; ifaces[i]; i++)
-	    free(ifaces[i]);
-	lua_pushnil(L);
-	return 1;
-    }
-    for (i = 0; ifaces[i]; i++){
-	lua_pushstring(L, ifaces[i]);
-	free(ifaces[i]);
-    }
-    return i;
-}
-
-static int container_get_ips(lua_State *L)
-{
-    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);
-    int argc = lua_gettop(L);
-    char **addresses;
-    char *iface = NULL, *family = NULL;
-    int i, scope = 0;
-
-    if (argc > 1)
-	iface = (char *)luaL_checkstring(L, 2);
-    if (argc > 2)
-	family = (char *)luaL_checkstring(L, 3);
-    if (argc > 3)
-	scope = luaL_checkinteger(L, 4);
-
-    addresses = c->get_ips(c, iface, family, scope);
-
-    if (!addresses){
-	lua_pushnil(L);
-	return 1;
-    }
-
-    for (i = 0; addresses[i]; i++);
-
-    /* protect LUA stack form overflow */
-    if (i > MAXVARS || !lua_checkstack(L, i)){
-        for (i = 0; addresses[i]; i++)
-	    free(addresses[i]);
-	lua_pushnil(L);
-	return 1;
-    }
-    for (i = 0; addresses[i]; i++){
-	lua_pushstring(L, addresses[i]);
-	free(addresses[i]);
-    }
-    return i;
-}
-
-static luaL_Reg lxc_container_methods[] =
-{
-    {"attach",                  container_attach},
-    {"create",			container_create},
-    {"defined",			container_defined},
-    {"destroy",			container_destroy},
-    {"init_pid",		container_init_pid},
-    {"name",			container_name},
-    {"running",			container_running},
-    {"state",			container_state},
-    {"freeze",			container_freeze},
-    {"unfreeze",		container_unfreeze},
-    {"start",			container_start},
-    {"stop",			container_stop},
-    {"shutdown",		container_shutdown},
-    {"wait",			container_wait},
-    {"rename",			container_rename},
-
-    {"config_file_name",	container_config_file_name},
-    {"load_config",		container_load_config},
-    {"save_config",		container_save_config},
-    {"get_cgroup_item",		container_get_cgroup_item},
-    {"set_cgroup_item",		container_set_cgroup_item},
-    {"get_config_path",		container_get_config_path},
-    {"set_config_path",		container_set_config_path},
-    {"get_config_item",		container_get_config_item},
-    {"set_config_item",		container_set_config_item},
-    {"clear_config_item",	container_clear_config_item},
-    {"get_keys",		container_get_keys},
-    {"get_interfaces",		container_get_interfaces},
-    {"get_ips",			container_get_ips},
-    {NULL, NULL}
-};
-
-static int lxc_version_get(lua_State *L) {
-    lua_pushstring(L, VERSION);
-    return 1;
-}
-
-static int lxc_default_config_path_get(lua_State *L) {
-    const char *lxcpath = lxc_get_global_config_item("lxc.lxcpath");
-
-    lua_pushstring(L, lxcpath);
-    return 1;
-}
-
-static int cmd_get_config_item(lua_State *L)
-{
-    int arg_cnt = lua_gettop(L);
-    const char *name = luaL_checkstring(L, 1);
-    const char *key = luaL_checkstring(L, 2);
-    const char *lxcpath = NULL;
-    char *value;
-
-    if (arg_cnt > 2)
-	lxcpath = luaL_checkstring(L, 3);
-
-    value = lxc_cmd_get_config_item(name, key, lxcpath);
-    if (!value)
-	goto not_found;
-
-    lua_pushstring(L, value);
-    return 1;
-
-not_found:
-    lua_pushnil(L);
-    return 1;
-}
-
-/* utility functions */
-static int lxc_util_usleep(lua_State *L) {
-    usleep((useconds_t)luaL_checkunsigned(L, 1));
-    return 0;
-}
-
-static int lxc_util_dirname(lua_State *L) {
-    char *path = strdupa(luaL_checkstring(L, 1));
-    lua_pushstring(L, dirname(path));
-    return 1;
-}
-
-static luaL_Reg lxc_lib_methods[] = {
-    {"version_get",		lxc_version_get},
-    {"default_config_path_get",	lxc_default_config_path_get},
-    {"cmd_get_config_item",	cmd_get_config_item},
-    {"container_new",		container_new},
-    {"usleep",			lxc_util_usleep},
-    {"dirname",			lxc_util_dirname},
-    {NULL, NULL}
-};
-
-static int lxc_lib_uninit(lua_State *L) {
-    (void) L;
-    /* this is where we would fini liblxc.so if we needed to */
-    return 0;
-}
-
-LUALIB_API int luaopen_lxc_core(lua_State *L) {
-    /* this is where we would initialize liblxc.so if we needed to */
-
-    luaL_newlib(L, lxc_lib_methods);
-
-    lua_newuserdata(L, 0);
-    lua_newtable(L);  /* metatable */
-    lua_pushvalue(L, -1);
-    lua_pushliteral(L, "__gc");
-    lua_pushcfunction(L, lxc_lib_uninit);
-    lua_rawset(L, -3);
-    lua_setmetatable(L, -3);
-    lua_rawset(L, -3);
-
-    luaL_newmetatable(L, CONTAINER_TYPENAME);
-    luaL_setfuncs(L, lxc_container_methods, 0);
-    lua_pushvalue(L, -1);  /* push metatable */
-    lua_pushstring(L, "__gc");
-    lua_pushcfunction(L, container_gc);
-    lua_settable(L, -3);
-    lua_setfield(L, -2, "__index");  /* metatable.__index = metatable */
-    lua_pop(L, 1);
-    return 1;
-}
diff --git a/src/lua-lxc/lxc.lua b/src/lua-lxc/lxc.lua
deleted file mode 100755
index 3d1de1014..000000000
--- a/src/lua-lxc/lxc.lua
+++ /dev/null
@@ -1,421 +0,0 @@
---
--- lua lxc module
---
--- Copyright © 2012 Oracle.
---
--- Authors:
--- Dwight Engen <dwight.engen at oracle.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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
---
-
-local core   = require("lxc.core")
-local lfs    = require("lfs")
-local table  = require("table")
-local string = require("string")
-local io     = require("io")
-module("lxc", package.seeall)
-
-local lxc_path
-local log_level = 3
-
--- lua 5.1 compat
-if table.unpack == nil then
-    table.unpack = unpack
-end
-
--- the following two functions can be useful for debugging
-function printf(...)
-    local function wrapper(...) io.write(string.format(...)) end
-    local status, result = pcall(wrapper, ...)
-    if not status then
-	error(result, 2)
-    end
-end
-
-function log(level, ...)
-    if (log_level >= level) then
-	printf(os.date("%Y-%m-%d %T "))
-	printf(...)
-    end
-end
-
-function string:split(delim, max_cols)
-    local cols = {}
-    local start = 1
-    local nextc
-    repeat
-	nextc = string.find(self, delim, start)
-	if (nextc and #cols ~= max_cols - 1) then
-	    table.insert(cols, string.sub(self, start, nextc-1))
-	    start = nextc + #delim
-	else
-	    table.insert(cols, string.sub(self, start, string.len(self)))
-	    nextc = nil
-	end
-    until nextc == nil or start > #self
-    return cols
-end
-
--- container class
-container = {}
-container_mt = {}
-container_mt.__index = container
-
-function container:new(lname, config)
-    local lcore
-    local lnetcfg = {}
-    local lstats = {}
-
-    if lname then
-	if config then
-	    lcore = core.container_new(lname, config)
-	else
-	    lcore = core.container_new(lname)
-	end
-    end
-
-    return setmetatable({ctname = lname, core = lcore, netcfg = lnetcfg, stats = lstats}, container_mt)
-end
-
--- methods interfacing to core functionality
-function container:attach(what, ...)
-    return self.core:attach(what, ...)
-end
-
-function container:config_file_name()
-    return self.core:config_file_name()
-end
-
-function container:defined()
-    return self.core:defined()
-end
-
-function container:init_pid()
-    return self.core:init_pid()
-end
-
-function container:name()
-    return self.core:name()
-end
-
-function container:start()
-    return self.core:start()
-end
-
-function container:stop()
-    return self.core:stop()
-end
-
-function container:shutdown(timeout)
-    return self.core:shutdown(timeout)
-end
-
-function container:wait(state, timeout)
-    return self.core:wait(state, timeout)
-end
-
-function container:freeze()
-    return self.core:freeze()
-end
-
-function container:unfreeze()
-    return self.core:unfreeze()
-end
-
-function container:running()
-    return self.core:running()
-end
-
-function container:state()
-    return self.core:state()
-end
-
-function container:create(template, ...)
-    return self.core:create(template, ...)
-end
-
-function container:destroy()
-    return self.core:destroy()
-end
-
--- return nil if name missing
-function container:rename(name)
-    return self.core:rename(name)
-end
-
-function container:get_config_path()
-    return self.core:get_config_path()
-end
-
-function container:set_config_path(path)
-    return self.core:set_config_path(path)
-end
-
-function container:append_config_item(key, value)
-    return self.core:set_config_item(key, value)
-end
-
-function container:clear_config_item(key)
-    return self.core:clear_config_item(key)
-end
-
-function container:get_cgroup_item(key)
-    return self.core:get_cgroup_item(key)
-end
-
-function container:get_config_item(key)
-    local value
-    local vals = {}
-
-    value = self.core:get_config_item(key)
-
-    -- check if it is a single item
-    if (not value or not string.find(value, "\n")) then
-	return value
-    end
-
-    -- it must be a list type item, make a table of it
-    vals = value:split("\n", 1000)
-    -- make it a "mixed" table, ie both dictionary and list for ease of use
-    for _,v in ipairs(vals) do
-	vals[v] = true
-    end
-    return vals
-end
-
-function container:set_cgroup_item(key, value)
-    return self.core:set_cgroup_item(key, value)
-end
-
-function container:set_config_item(key, value)
-    return self.core:set_config_item(key, value)
-end
-
-function container:get_keys(base)
-    local ktab = {}
-    local keys
-
-    if (base) then
-	keys = self.core:get_keys(base)
-	base = base .. "."
-    else
-	keys = self.core:get_keys()
-	base = ""
-    end
-    if (keys == nil) then
-	return nil
-    end
-    keys = keys:split("\n", 1000)
-    for _,v in ipairs(keys) do
-	local config_item = base .. v
-	ktab[v] = self.core:get_config_item(config_item)
-    end
-    return ktab
-end
-
--- return nil or more args
-function container:get_interfaces()
-    return self.core:get_interfaces()
-end
-
--- return nil or more args
-function container:get_ips(...)
-    return self.core:get_ips(...)
-end
-
-function container:load_config(alt_path)
-    if (alt_path) then
-	return self.core:load_config(alt_path)
-    else
-	return self.core:load_config()
-    end
-end
-
-function container:save_config(alt_path)
-    if (alt_path) then
-	return self.core:save_config(alt_path)
-    else
-	return self.core:save_config()
-    end
-end
-
--- methods for stats collection from various cgroup files
--- read integers at given coordinates from a cgroup file
-function container:stat_get_ints(item, coords)
-    local lines = {}
-    local result = {}
-    local flines = self:get_cgroup_item(item)
-
-    if (flines == nil) then
-	for k,c in ipairs(coords) do
-	    table.insert(result, 0)
-	end
-    else
-	for line in flines:gmatch("[^\r\n]+") do
-	    table.insert(lines, line)
-	end
-	for k,c in ipairs(coords) do
-	    local col
-
-	    col = lines[c[1]]:split(" ", 80)
-	    local val = tonumber(col[c[2]])
-	    table.insert(result, val)
-	end
-    end
-    return table.unpack(result)
-end
-
--- read an integer from a cgroup file
-function container:stat_get_int(item)
-    local line = self:get_cgroup_item(item)
-    -- if line is nil (on an error like Operation not supported because
-    -- CONFIG_MEMCG_SWAP_ENABLED isn't enabled) return 0
-    return tonumber(line) or 0
-end
-
-function container:stat_match_get_int(item, match, column)
-    local val
-    local lines = self:get_cgroup_item(item)
-
-    if (lines == nil) then
-       return 0
-    end
-
-    for line in lines:gmatch("[^\r\n]+") do
-	if (string.find(line, match)) then
-	    local col
-
-	    col = line:split(" ", 80)
-	    val = tonumber(col[column]) or 0
-	end
-    end
-
-    return val
-end
-
-function container:stats_get(total)
-    local stat = {}
-    stat.mem_used      = self:stat_get_int("memory.usage_in_bytes")
-    stat.mem_limit     = self:stat_get_int("memory.limit_in_bytes")
-    stat.memsw_used    = self:stat_get_int("memory.memsw.usage_in_bytes")
-    stat.memsw_limit   = self:stat_get_int("memory.memsw.limit_in_bytes")
-    stat.kmem_used     = self:stat_get_int("memory.kmem.usage_in_bytes")
-    stat.kmem_limit    = self:stat_get_int("memory.kmem.limit_in_bytes")
-    stat.cpu_use_nanos = self:stat_get_int("cpuacct.usage")
-    stat.cpu_use_user,
-    stat.cpu_use_sys   = self:stat_get_ints("cpuacct.stat", {{1, 2}, {2, 2}})
-    stat.blkio         = self:stat_match_get_int("blkio.throttle.io_service_bytes", "Total", 2)
-
-    if (total) then
-	total.mem_used      = total.mem_used      + stat.mem_used
-	total.mem_limit     = total.mem_limit     + stat.mem_limit
-	total.memsw_used    = total.memsw_used    + stat.memsw_used
-	total.memsw_limit   = total.memsw_limit   + stat.memsw_limit
-	total.kmem_used     = total.kmem_used     + stat.kmem_used
-	total.kmem_limit    = total.kmem_limit    + stat.kmem_limit
-	total.cpu_use_nanos = total.cpu_use_nanos + stat.cpu_use_nanos
-	total.cpu_use_user  = total.cpu_use_user  + stat.cpu_use_user
-	total.cpu_use_sys   = total.cpu_use_sys   + stat.cpu_use_sys
-	total.blkio         = total.blkio         + stat.blkio
-    end
-    return stat
-end
-
-local M = { container = container }
-
-function M.stats_clear(stat)
-    stat.mem_used      = 0
-    stat.mem_limit     = 0
-    stat.memsw_used    = 0
-    stat.memsw_limit   = 0
-    stat.kmem_used     = 0
-    stat.kmem_limit    = 0
-    stat.cpu_use_nanos = 0
-    stat.cpu_use_user  = 0
-    stat.cpu_use_sys   = 0
-    stat.blkio         = 0
-end
-
--- return configured containers found in LXC_PATH directory
-function M.containers_configured(names_only)
-    local containers = {}
-
-    for dir in lfs.dir(lxc_path) do
-	if (dir ~= "." and dir ~= "..")
-	then
-	    local cfgfile = lxc_path .. "/" .. dir .. "/config"
-	    local cfgattr = lfs.attributes(cfgfile)
-
-	    if (cfgattr and cfgattr.mode == "file") then
-		if (names_only) then
-		    -- note, this is a "mixed" table, ie both dictionary and list
-		    containers[dir] = true
-		    table.insert(containers, dir)
-		else
-		    local ct = container:new(dir)
-		    -- note, this is a "mixed" table, ie both dictionary and list
-		    containers[dir] = ct
-		    table.insert(containers, dir)
-		end
-	    end
-	end
-    end
-    table.sort(containers, function (a,b) return (a < b) end)
-    return containers
-end
-
--- return running containers found in cgroup fs
-function M.containers_running(names_only)
-    local containers = {}
-    local names = M.containers_configured(true)
-
-    for _,name in ipairs(names) do
-	local ct = container:new(name)
-	if ct:running() then
-		-- note, this is a "mixed" table, ie both dictionary and list
-		table.insert(containers, name)
-		if (names_only) then
-		    containers[name] = true
-		    ct = nil
-		else
-		    containers[name] = ct
-		end
-	end
-    end
-
-    table.sort(containers, function (a,b) return (a < b) end)
-    return containers
-end
-
-function M.version_get()
-    return core.version_get()
-end
-
-function M.default_config_path_get()
-    return core.default_config_path_get()
-end
-
-function M.cmd_get_config_item(name, item, lxcpath)
-    if (lxcpath) then
-	return core.cmd_get_config_item(name, item, lxcpath)
-    else
-	return core.cmd_get_config_item(name, item)
-    end
-end
-
-lxc_path = core.default_config_path_get()
-
-return M
diff --git a/src/lua-lxc/test/apitest.lua b/src/lua-lxc/test/apitest.lua
deleted file mode 100755
index 99cded75b..000000000
--- a/src/lua-lxc/test/apitest.lua
+++ /dev/null
@@ -1,353 +0,0 @@
-#!/usr/bin/env lua
---
--- test the lxc lua api
---
--- Copyright © 2012 Oracle.
---
--- Authors:
--- Dwight Engen <dwight.engen at oracle.com>
---
--- This library is free software; you can redistribute it and/or modify
--- it under the terms of the GNU General Public License version 2, as
--- published by the Free Software Foundation.
---
--- This program 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 General Public License for more details.
---
--- You should have received a copy of the GNU General Public License along
--- with this program; if not, write to the Free Software Foundation, Inc.,
--- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
---
-
-local lxc     = require("lxc")
-local lfs     = require("lfs")
-local getopt  = require("alt_getopt")
-
-local LXC_PATH		= lxc.default_config_path_get()
-
-local container
-local cfg_containers	= {}
-local optarg		= {}
-local optind		= {}
-
-function printf(...)
-    local function wrapper(...) io.write(string.format(...)) end
-    local status, result = pcall(wrapper, ...)
-    if not status then
-	error(result, 2)
-    end
-end
-
-function log(level, ...)
-    if (optarg["v"] >= level) then
-	printf(os.date("%Y-%m-%d %T "))
-	printf(...)
-	printf("\n")
-    end
-end
-
-function die(...)
-    printf(...)
-    os.exit(1)
-end
-
-function test_global_info()
-    local cfg_containers
-    local run_containers
-
-    log(0, "%-20s %s", "LXC version:", lxc.version_get())
-    log(0, "%-20s %s", "Container name:", optarg["n"])
-    if (optarg["c"]) then
-	log(0, "%-20s %s", "Creating container:", "yes")
-	log(0, "%-20s %s", "With template:", optarg["t"])
-    end
-    log(0, "%-20s %s", "Containers path:", LXC_PATH)
-
-    cfg_containers = lxc.containers_configured()
-    log(0, "%-20s", "Containers configured:")
-    for _,v in ipairs(cfg_containers) do
-	log(0, "  %s", v)
-    end
-
-    run_containers = lxc.containers_running(true)
-    log(0, "%-20s", "Containers running:")
-    for _,v in ipairs(run_containers) do
-	log(0, "  %s", v)
-    end
-end
-
-function test_container_new()
-    container = lxc.container:new(optarg["n"])
-    assert(container ~= nil)
-    assert(container:config_file_name() == string.format("%s/%s/config", LXC_PATH, optarg["n"]))
-end
-
-function test_container_config_path()
-    local cfgcontainer
-    local cfgpath = "/tmp/" .. optarg["n"]
-    local cfgname = cfgpath .. "/config"
-
-    log(0, "Test container config path...")
-
-    -- create a config file in the new location from container's config
-    assert(lfs.mkdir(cfgpath))
-    assert(container:save_config(cfgname))
-    cfgcontainer = lxc.container:new(optarg["n"], "/tmp")
-    assert(cfgcontainer ~= nil)
-    log(0, "cfgname:%s cfgpath:%s", cfgcontainer:config_file_name(), cfgcontainer:get_config_path())
-    assert(cfgcontainer:config_file_name() == cfgname)
-    assert(cfgcontainer:get_config_path() == "/tmp")
-    assert(cfgcontainer:set_config_path(LXC_PATH))
-    assert(cfgcontainer:get_config_path() == LXC_PATH)
-
-    assert(os.remove(cfgname))
-    assert(lfs.rmdir(cfgpath))
-end
-
-function test_container_create()
-    if (optarg["c"]) then
-	log(0, "%-20s %s", "Destroy existing container:", optarg["n"])
-	container:destroy()
-	assert(container:defined() == false)
-    else
-	local cfg_containers = lxc.containers_configured()
-	if (cfg_containers[optarg["n"]]) then
-	    log(0, "%-20s %s", "Use existing container:", optarg["n"])
-	    return
-	end
-    end
-    log(0, "%-20s %s", "Creating rootfs using:", optarg["t"])
-    assert(container:create(optarg["t"]) == true)
-    assert(container:defined() == true)
-    assert(container:name() == optarg["n"])
-end
-
-function test_container_started()
-    local now_running
-    log(2, "state:%s pid:%d\n", container:state(), container:init_pid())
-    assert(container:init_pid() > 1)
-    assert(container:running() == true)
-    assert(container:state() == "RUNNING")
-    now_running = lxc.containers_running(true)
-    assert(now_running[optarg["n"]] ~= nil)
-    log(1, "%-20s %s", "Running, init pid:", container:init_pid())
-end
-
-function test_container_stopped()
-    local now_running
-    assert(container:init_pid() == -1)
-    assert(container:running() == false)
-    assert(container:state() == "STOPPED")
-    now_running = lxc.containers_running(true)
-    assert(now_running[optarg["n"]] == nil)
-end
-
-function test_container_frozen()
-    local now_running
-    assert(container:init_pid() > 1)
-    assert(container:running() == true)
-    assert(container:state() == "FROZEN")
-    now_running = lxc.containers_running(true)
-    assert(now_running[optarg["n"]] ~= nil)
-end
-
-function test_container_start()
-    log(0, "Starting...")
-    if (not container:start()) then
-	log(1, "Start returned failure, waiting another 10 seconds...")
-	container:wait("RUNNING", 10)
-    end
-    container:wait("RUNNING", 1)
-end
-
-function test_container_stop()
-    log(0, "Stopping...")
-    if (not container:stop()) then
-	log(1, "Stop returned failure, waiting another 10 seconds...")
-	container:wait("STOPPED", 10)
-    end
-    container:wait("STOPPED", 1)
-end
-
-function test_container_freeze()
-    log(0, "Freezing...")
-    if (not container:freeze()) then
-	log(1, "Freeze returned failure, waiting another 10 seconds...")
-	container:wait("FROZEN", 10)
-    end
-end
-
-function test_container_unfreeze()
-    log(0, "Unfreezing...")
-    if (not container:unfreeze()) then
-	log(1, "Unfreeze returned failure, waiting another 10 seconds...")
-	container:wait("RUNNING", 10)
-    end
-end
-
-function test_container_shutdown()
-    log(0, "Shutting down...")
-    container:shutdown(5)
-
-    if (container:running()) then
-	test_container_stop()
-    end
-end
-
-function test_container_in_cfglist(should_find)
-    local cfg_containers = lxc.containers_configured()
-
-    if (should_find) then
-	assert(cfg_containers[container:name()] ~= nil)
-    else
-	assert(cfg_containers[container:name()] == nil)
-    end
-end
-
-function test_container_attach()
-    log(0, "Test attach...")
-    assert(container:running() == true)
-    assert(container:attach("/bin/ps") == true)
-end
-
-function test_container_cgroup()
-    log(0, "Test get/set cgroup items...")
-
-    max_mem = container:get_cgroup_item("memory.max_usage_in_bytes")
-    saved_limit = container:get_cgroup_item("memory.limit_in_bytes")
-    assert(saved_limit ~= max_mem)
-    assert(container:set_cgroup_item("memory.limit_in_bytes", max_mem))
-    assert(container:get_cgroup_item("memory.limit_in_bytes") ~= saved_limit)
-    assert(container:set_cgroup_item("memory.limit_in_bytes", "-1"))
-end
-
-function test_container_cmd()
-    log(0, "Test get config from running container...")
-    veth_pair = lxc.cmd_get_config_item(optarg["n"], "lxc.net.0.veth.pair")
-    log(0, "  veth.pair:%s", veth_pair)
-end
-
-function test_config_items()
-    log(0, "Test set/clear configuration items...")
-
-    -- test setting a 'single type' item
-    assert(container:get_config_item("lxc.uts.name") == optarg["n"])
-    container:set_config_item("lxc.uts.name", "foobar")
-    assert(container:get_config_item("lxc.uts.name") == "foobar")
-    container:set_config_item("lxc.uts.name", optarg["n"])
-    assert(container:get_config_item("lxc.uts.name") == optarg["n"])
-
-    -- test clearing/setting a 'list type' item
-    container:clear_config_item("lxc.cap.drop")
-    container:set_config_item("lxc.cap.drop", "new_cap1")
-    container:set_config_item("lxc.cap.drop", "new_cap2")
-    local cap_drop = container:get_config_item("lxc.cap.drop")
-    assert(cap_drop["new_cap1"] ~= nil)
-    assert(cap_drop["new_cap2"] ~= nil)
-    -- note: clear_config_item only works on list type items
-    container:clear_config_item("lxc.cap.drop")
-    assert(container:get_config_item("lxc.cap.drop") == nil)
-
-    local altname = "/tmp/" .. optarg["n"] .. ".altconfig"
-    log(0, "Test saving to an alternate (%s) config file...", altname)
-    assert(container:save_config(altname))
-    assert(os.remove(altname))
-end
-
-function test_config_mount_entries()
-    local mntents
-
-    -- mount entries are a list type item
-    mntents = container:get_config_item("lxc.mount.entry")
-    log(0, "Mount entries:")
-    for _,v in ipairs(mntents) do
-	log(0, "  %s", v)
-    end
-end
-
-function test_config_keys()
-    local keys
-
-    keys = container:get_keys()
-    log(0, "Top level keys:")
-    for k,v in pairs(keys) do
-	log(0, "  %s = %s", k, v or "")
-    end
-end
-
-function test_config_network(net_nr)
-    log(0, "Test network %d config...", net_nr)
-    local netcfg
-
-    netcfg = container:get_keys("lxc.net." .. net_nr)
-    if (netcfg == nil) then
-	return
-    end
-    for k,v in pairs(netcfg) do
-	log(0, "  %s = %s", k, v or "")
-    end
-    assert(netcfg["flags"] == "up")
-    assert(container:get_config_item("lxc.net."..net_nr..".type") == "veth")
-end
-
-
-function usage()
-    die("Usage: apitest <options>\n" ..
-	"  -v|--verbose        increase verbosity with each -v\n" ..
-	"  -h|--help           print help message\n" ..
-	"  -n|--name           name of container to use for testing\n" ..
-	"  -c|--create         create the test container anew\n" ..
-	"  -l|--login          do interactive login test\n" ..
-	"  -t|--template       template to use when creating test container\n"
-    )
-end
-
-local long_opts = {
-    verbose       = "v",
-    help          = "h",
-    name          = "n",
-    create        = "c",
-    template      = "t",
-}
-
-optarg,optind = alt_getopt.get_opts (arg, "hvn:ct:", long_opts)
-optarg["v"] = tonumber(optarg["v"]) or 0
-optarg["n"] = optarg["n"] or "lua-apitest"
-optarg["c"] = optarg["c"] or nil
-optarg["t"] = optarg["t"] or "busybox"
-if (optarg["h"] ~= nil) then
-    usage()
-end
-
-test_global_info()
-test_container_new()
-test_container_create()
-test_container_stopped()
-test_container_in_cfglist(true)
-test_container_config_path()
-
-test_config_items()
-test_config_keys()
-test_config_mount_entries()
-test_config_network(0)
-
-test_container_start()
-test_container_started()
-
-test_container_attach()
-test_container_cgroup()
-test_container_cmd()
-
-test_container_freeze()
-test_container_frozen()
-test_container_unfreeze()
-test_container_started()
-
-test_container_shutdown()
-test_container_stopped()
-container:destroy()
-test_container_in_cfglist(false)
-
-log(0, "All tests passed")

From cb881fc4164d2f53301743eeb57c2f88d8141de0 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 14 Feb 2018 11:53:18 +0100
Subject: [PATCH 4/4] tree-wide: remove python3 bindings

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 .gitignore                               |    4 -
 Makefile.am                              |    4 -
 configure.ac                             |   26 -
 doc/ko/Makefile.am                       |    7 -
 lxc.spec.in                              |   15 -
 src/Makefile.am                          |    2 +-
 src/python-lxc/Makefile.am               |   35 -
 src/python-lxc/examples/api_test.py      |  207 ---
 src/python-lxc/examples/pyconsole-vte.py |   79 --
 src/python-lxc/examples/pyconsole.py     |   53 -
 src/python-lxc/lxc.c                     | 2031 ------------------------------
 src/python-lxc/lxc/__init__.py           |  510 --------
 src/python-lxc/setup.py                  |   89 --
 13 files changed, 1 insertion(+), 3061 deletions(-)
 delete mode 100644 src/python-lxc/Makefile.am
 delete mode 100755 src/python-lxc/examples/api_test.py
 delete mode 100755 src/python-lxc/examples/pyconsole-vte.py
 delete mode 100755 src/python-lxc/examples/pyconsole.py
 delete mode 100644 src/python-lxc/lxc.c
 delete mode 100644 src/python-lxc/lxc/__init__.py
 delete mode 100644 src/python-lxc/setup.py

diff --git a/.gitignore b/.gitignore
index d48daf2cc..0d266c200 100644
--- a/.gitignore
+++ b/.gitignore
@@ -67,10 +67,6 @@ src/lxc/version.h
 src/lxc/cmd/lxc-checkconfig
 src/lxc/cmd/lxc-update-config
 
-src/python-lxc/build/
-src/python-lxc/lxc/__pycache__/
-src/python-lxc/lxc.egg-info/
-
 src/tests/lxc-test-device-add-remove
 src/tests/lxc-test-attach
 src/tests/lxc-test-apparmor
diff --git a/Makefile.am b/Makefile.am
index 14712bc43..dd892c820 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,10 +13,6 @@ EXTRA_DIST = \
 
 RPMARGS =
 
-if ENABLE_PYTHON
-RPMARGS += --with python
-endif
-
 pcdatadir = $(libdir)/pkgconfig
 pcdata_DATA = lxc.pc
 
diff --git a/configure.ac b/configure.ac
index a1bf65614..fc814998c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -363,29 +363,6 @@ AC_ARG_ENABLE([examples],
 	[], [enable_examples=yes])
 AM_CONDITIONAL([ENABLE_EXAMPLES], [test "x$enable_examples" = "xyes"])
 
-# Python3 module and scripts
-AC_ARG_ENABLE([python],
-	[AC_HELP_STRING([--enable-python], [enable python binding [default=auto]])],
-	[], [enable_python=auto])
-
-if test "x$enable_python" = "xauto"; then
-	PKG_CHECK_MODULES([PYTHONDEV], [python3 >= 3.2],[enable_python=yes],[enable_python=no])
-	if test "$CC" = "clang"; then
-		enable_python=no
-	fi
-fi
-
-if test "x$enable_python" = "xyes" && test "$CC" = "clang"; then
-	AC_MSG_ERROR([Python3 is incompatible with the clang compiler])
-fi
-
-AM_CONDITIONAL([ENABLE_PYTHON], [test "x$enable_python" = "xyes"])
-
-AM_COND_IF([ENABLE_PYTHON],
-	[AM_PATH_PYTHON([3.2], [], [AC_MSG_ERROR([You must install python3])])
-	PKG_CHECK_MODULES([PYTHONDEV], [python3 >= 3.2],[],[AC_MSG_ERROR([You must install python3-dev])])
-	AC_DEFINE_UNQUOTED([ENABLE_PYTHON], 1, [Python3 is available])])
-
 # Enable dumping stack traces
 AC_ARG_ENABLE([mutex-debugging],
 	[AC_HELP_STRING([--enable-mutex-debugging], [Makes mutexes to report error and provide stack trace [default=no]])],
@@ -856,7 +833,6 @@ AC_CONFIG_FILES([
 	src/lxc/cmd/lxc-checkconfig
 	src/lxc/cmd/lxc-update-config
 	src/lxc/version.h
-	src/python-lxc/Makefile
 
 	src/tests/Makefile
 	src/tests/lxc-test-usernic
@@ -914,8 +890,6 @@ Security features:
  - Linux capabilities: $enable_capabilities
  - seccomp: $enable_seccomp
  - SELinux: $enable_selinux
-Bindings:
- - python3: $enable_python
 
 Documentation:
  - examples: $enable_examples
diff --git a/doc/ko/Makefile.am b/doc/ko/Makefile.am
index b4ae2c57b..2b196830a 100644
--- a/doc/ko/Makefile.am
+++ b/doc/ko/Makefile.am
@@ -41,13 +41,6 @@ man_MANS = \
 	\
 	lxc.7
 
-if ENABLE_DEPRECATED
-    man_MANS += lxc-clone.1
-if ENABLE_PYTHON
-    man_MANS += lxc-start-ephemeral.1
-endif
-endif
-
 %.1 : %.sgml
 	$(db2xman) --encoding=UTF-8 $<
 	test "$(shell basename $@)" != "$@" && mv $(shell basename $@) $@ || true
diff --git a/lxc.spec.in b/lxc.spec.in
index f750b1e18..004ced268 100644
--- a/lxc.spec.in
+++ b/lxc.spec.in
@@ -20,8 +20,6 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
-%global with_python %{?_with_python: 1} %{?!_with_python: 0}
-
 # Set with_systemd on distros that use it, so we can install the service
 # file, otherwise the sysvinit script will be installed
 %if 0%{?fedora} >= 14 || 0%{?rhel} >= 7 || 0%{?suse_version} >= 1210
@@ -93,12 +91,6 @@ BuildRequires:  libseccomp-devel
 %endif
 %endif
 
-%if %{with_python}
-Requires: python3
-BuildRequires: python3-devel
-BuildRequires: python3-setuptools
-%endif
-
 %description
 Containers are insulated areas inside a system, which have their own namespace
 for filesystem, network, PID, IPC, CPU and memory allocation and which can be
@@ -127,9 +119,6 @@ development of the Linux containers.
 %setup -q -n %{name}-%{version}%{?beta_dot}
 %build
 PATH=$PATH:/usr/sbin:/sbin %configure $args \
-%if %{with_python}
-  --enable-python \
-%endif
 %if "x%{_unitdir}" != "x"
   --with-systemdsystemunitdir=%{_unitdir} \
 %endif
@@ -266,10 +255,6 @@ fi
 %attr(555,root,root) %{_libexecdir}/%{name}/lxc-containers
 %endif
 
-%if %{with_python}
-%{python3_sitearch}/*
-%endif
-
 %files devel
 %defattr(-,root,root)
 %{_includedir}/%{name}/*
diff --git a/src/Makefile.am b/src/Makefile.am
index 4e4d66b5e..ca3b09203 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1 +1 @@
-SUBDIRS = lxc tests python-lxc
+SUBDIRS = lxc tests
diff --git a/src/python-lxc/Makefile.am b/src/python-lxc/Makefile.am
deleted file mode 100644
index 38b1d62f7..000000000
--- a/src/python-lxc/Makefile.am
+++ /dev/null
@@ -1,35 +0,0 @@
-if ENABLE_PYTHON
-
-if HAVE_DEBIAN
-    DISTSETUPOPTS=--install-layout=deb
-else
-    DISTSETUPOPTS=
-endif
-
-if ENABLE_RPATH
-    RPATHOPTS=-R $(libdir)
-else
-    RPATHOPTS=
-endif
-
-CALL_SETUP_PY := cd @srcdir@ && $(PYTHON) setup.py build -b @abs_builddir@/build egg_info -e @abs_builddir@
-
-all:
-	$(CALL_SETUP_PY) build_ext -I @abs_top_srcdir@/src -L @abs_top_builddir@/src/lxc/.libs/ $(RPATHOPTS) --no-pkg-config
-
-DESTDIR = / # default
-
-install:
-	$(CALL_SETUP_PY) install --prefix=$(prefix) --no-compile $(DISTSETUPOPTS) --root=$(DESTDIR)
-
-clean-local:
-	rm -rf @builddir@/build
-
-endif
-EXTRA_DIST = \
-	setup.py \
-	lxc.c \
-	lxc/__init__.py \
-	examples/api_test.py \
-	examples/pyconsole.py \
-	examples/pyconsole-vte.py
diff --git a/src/python-lxc/examples/api_test.py b/src/python-lxc/examples/api_test.py
deleted file mode 100755
index 1934a238c..000000000
--- a/src/python-lxc/examples/api_test.py
+++ /dev/null
@@ -1,207 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-#
-# api_test.py: Test/demo of the python3-lxc API
-#
-# (C) Copyright Canonical Ltd. 2012
-#
-# Authors:
-# Stéphane Graber <stgraber at ubuntu.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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
-# USA
-#
-
-import lxc
-import uuid
-import os
-import subprocess
-import sys
-import time
-
-# Let's pick a random name, avoiding clashes
-CONTAINER_NAME = str(uuid.uuid1())
-CLONE_NAME = str(uuid.uuid1())
-RENAME_NAME = str(uuid.uuid1())
-
-## Instantiate the container instance
-print("Getting instance for '%s'" % CONTAINER_NAME)
-container = lxc.Container(CONTAINER_NAME)
-
-# A few basic checks of the current state
-assert(container.config_file_name == "%s/%s/config" %
-       (lxc.default_config_path, CONTAINER_NAME))
-assert(not container.defined)
-assert(container.init_pid == -1)
-assert(container.name == CONTAINER_NAME)
-assert(not container.running)
-assert(container.state == "STOPPED")
-
-# Try to get the host architecture for dpkg systems
-arch = "i386"
-try:
-    with open(os.path.devnull, "w") as devnull:
-        dpkg = subprocess.Popen(['dpkg', '--print-architecture'],
-                                stderr=devnull, stdout=subprocess.PIPE,
-                                universal_newlines=True)
-
-        if dpkg.wait() == 0:
-            arch = dpkg.stdout.read().strip()
-except:
-    pass
-
-## Create a rootfs
-print("Creating rootfs using 'download', arch=%s" % arch)
-container.create("download", 0,
-                 {"dist": "ubuntu",
-                  "release": "xenial",
-                  "arch": arch})
-
-assert(container.defined)
-assert(container.name == CONTAINER_NAME
-       == container.get_config_item("lxc.uts.name"))
-assert(container.name in lxc.list_containers())
-
-## Test the config
-print("Testing the configuration")
-capdrop = container.get_config_item("lxc.cap.drop")
-container.clear_config_item("lxc.cap.drop")
-container.set_config_item("lxc.cap.drop", capdrop[:-1])
-container.append_config_item("lxc.cap.drop", capdrop[-1])
-container.save_config()
-
-# A few basic checks of the current state
-assert(isinstance(capdrop, list))
-assert(capdrop == container.get_config_item("lxc.cap.drop"))
-
-## Test the networking
-print("Testing the networking")
-
-# A few basic checks of the current state
-assert("name" in container.get_keys("lxc.net.0"))
-assert(len(container.network) == 1)
-
-## Starting the container
-print("Starting the container")
-container.start()
-container.wait("RUNNING", 3)
-
-# A few basic checks of the current state
-assert(container.init_pid > 1)
-assert(container.running)
-assert(container.state == "RUNNING")
-
-
-## Checking IP address
-print("Getting the interface names")
-assert(set(container.get_interfaces()) == set(('lo', 'eth0')))
-
-## Checking IP address
-print("Getting the IP addresses")
-
-count = 0
-ips = []
-while not ips or count == 10:
-    ips = container.get_ips()
-    time.sleep(1)
-    count += 1
-
-if os.geteuid():
-    container.attach_wait(lxc.attach_run_command, ["ifconfig", "eth0"],
-                          namespaces=(lxc.CLONE_NEWUSER + lxc.CLONE_NEWNET
-                                      + lxc.CLONE_NEWUTS))
-else:
-    container.attach_wait(lxc.attach_run_command, ["ifconfig", "eth0"],
-                          namespaces=(lxc.CLONE_NEWNET + lxc.CLONE_NEWUTS))
-
-# A few basic checks of the current state
-assert(len(ips) > 0)
-
-## Test running config
-assert(container.name == CONTAINER_NAME
-       == container.get_config_item("lxc.uts.name")
-       == container.get_running_config_item("lxc.uts.name"))
-
-## Testing cgroups a bit
-print("Testing cgroup API")
-max_mem = container.get_cgroup_item("memory.max_usage_in_bytes")
-current_limit = container.get_cgroup_item("memory.limit_in_bytes")
-assert(container.set_cgroup_item("memory.limit_in_bytes", max_mem))
-assert(container.get_cgroup_item("memory.limit_in_bytes") != current_limit)
-
-## Freezing the container
-print("Freezing the container")
-container.freeze()
-container.wait("FROZEN", 3)
-
-# A few basic checks of the current state
-assert(container.init_pid > 1)
-assert(container.running)
-assert(container.state == "FROZEN")
-
-## Unfreezing the container
-print("Unfreezing the container")
-container.unfreeze()
-container.wait("RUNNING", 3)
-
-# A few basic checks of the current state
-assert(container.init_pid > 1)
-assert(container.running)
-assert(container.state == "RUNNING")
-
-if len(sys.argv) > 1 and sys.argv[1] == "--with-console":
-    ## Attaching to tty1
-    print("Attaching to tty1")
-    container.console(tty=1)
-
-## Shutting down the container
-print("Shutting down the container")
-if not container.shutdown(3):
-    container.stop()
-
-if container.running:
-    print("Stopping the container")
-    container.stop()
-    container.wait("STOPPED", 3)
-
-# A few basic checks of the current state
-assert(container.init_pid == -1)
-assert(not container.running)
-assert(container.state == "STOPPED")
-
-## Snapshotting the container
-print("Snapshotting the container")
-assert(not container.snapshot_list())
-assert(container.snapshot() == "snap0")
-assert(len(container.snapshot_list()) == 1)
-assert(container.snapshot_restore("snap0") is True)
-assert(container.snapshot_destroy("snap0") is True)
-
-## Cloning the container
-print("Cloning the container as '%s'" % CLONE_NAME)
-clone = container.clone(CLONE_NAME)
-assert(clone is not False)
-
-print ("Renaming the clone to '%s'" % RENAME_NAME)
-rename = clone.rename(RENAME_NAME)
-rename.start()
-rename.stop()
-rename.destroy()
-
-## Destroy the container
-print("Destroying the container")
-container.destroy()
-
-assert(not container.defined)
diff --git a/src/python-lxc/examples/pyconsole-vte.py b/src/python-lxc/examples/pyconsole-vte.py
deleted file mode 100755
index 8a98359af..000000000
--- a/src/python-lxc/examples/pyconsole-vte.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-#
-# pyconsole-vte: Example program showing use of console functions
-#                in the lxc python binding
-#
-# (C) Copyright Oracle. 2013
-#
-# Authors:
-# Dwight Engen <dwight.engen at oracle.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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
-# USA
-#
-
-import gtk
-import vte
-import lxc
-import sys
-
-
-def gtk_exit_cb(terminal):
-    gtk.main_quit()
-
-
-def vte_con(ct, ttynum):
-    print("Doing console in a VTE widget...")
-    masterfd = ct.console_getfd(ttynum)
-    term = vte.Terminal()
-    term.set_cursor_blinks(True)
-    term.set_scrollback_lines(1000)
-    term.connect('eof', gtk_exit_cb)
-
-    term.set_pty(masterfd)
-    term.feed_child('\n')
-    #term.feed_child('ps aux\n')
-
-    vscrollbar = gtk.VScrollbar()
-    vscrollbar.set_adjustment(term.get_adjustment())
-
-    hbox = gtk.HBox()
-    hbox.pack_start(term)
-    hbox.pack_start(vscrollbar)
-
-    window = gtk.Window()
-    window.add(hbox)
-    window.connect('delete-event', lambda window, event: gtk.main_quit())
-    window.show_all()
-    gtk.main()
-    print("Console done")
-
-if __name__ == '__main__':
-    ttynum = -1
-    if len(sys.argv) < 2:
-        sys.exit("Usage: %s container-name [ttynum]" % sys.argv[0])
-    if len(sys.argv) > 2:
-        ttynum = int(sys.argv[2])
-
-    ct = lxc.Container(sys.argv[1])
-
-    print("Container:%s tty:%d" % (ct.name, ttynum))
-    if not ct.defined:
-        sys.exit("Container %s not defined" % ct.name)
-    if not ct.running:
-        sys.exit("Container %s not running" % ct.name)
-
-    vte_con(ct, ttynum)
diff --git a/src/python-lxc/examples/pyconsole.py b/src/python-lxc/examples/pyconsole.py
deleted file mode 100755
index 2b0cd14ab..000000000
--- a/src/python-lxc/examples/pyconsole.py
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-#
-# pyconsole: Example program showing use of console functions
-#            in the lxc python binding
-#
-# (C) Copyright Oracle. 2013
-#
-# Authors:
-# Dwight Engen <dwight.engen at oracle.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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
-# USA
-#
-
-import lxc
-import sys
-import time
-
-if __name__ == '__main__':
-    ttynum = -1
-    escape = 1
-    if len(sys.argv) < 2:
-        sys.exit("Usage: %s container-name [ttynum [escape]]" % sys.argv[0])
-    if len(sys.argv) > 2:
-        ttynum = int(sys.argv[2])
-    if len(sys.argv) > 3:
-        escape = ord(sys.argv[3]) - ord('a') + 1
-
-    ct = lxc.Container(sys.argv[1])
-
-    print("Container:%s tty:%d Ctrl-%c q to quit" %
-          (ct.name, ttynum, ord('a') + escape-1))
-    time.sleep(1)
-    if not ct.defined:
-        sys.exit("Container %s not defined" % ct.name)
-    if not ct.running:
-        sys.exit("Container %s not running" % ct.name)
-
-    ct.console(ttynum, 0, 1, 2, escape)
-    print("Console done")
diff --git a/src/python-lxc/lxc.c b/src/python-lxc/lxc.c
deleted file mode 100644
index 70176cdc6..000000000
--- a/src/python-lxc/lxc.c
+++ /dev/null
@@ -1,2031 +0,0 @@
-/*
- * python-lxc: Python bindings for LXC
- *
- * (C) Copyright Canonical Ltd. 2012-2013
- *
- * Authors:
- * Stéphane Graber <stgraber at ubuntu.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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
- * USA
- */
-
-#include <Python.h>
-#include "structmember.h"
-#include <lxc/lxccontainer.h>
-#include <stdio.h>
-#include <sys/wait.h>
-#include <sched.h>
-
-/*
- * CLONE_* definitions copied from lxc/namespace.h
- */
-#ifndef CLONE_FS
-#  define CLONE_FS                0x00000200
-#endif
-#ifndef CLONE_NEWNS
-#  define CLONE_NEWNS             0x00020000
-#endif
-#ifndef CLONE_NEWCGROUP
-#  define CLONE_NEWCGROUP         0x02000000
-#endif
-#ifndef CLONE_NEWUTS
-#  define CLONE_NEWUTS            0x04000000
-#endif
-#ifndef CLONE_NEWIPC
-#  define CLONE_NEWIPC            0x08000000
-#endif
-#ifndef CLONE_NEWUSER
-#  define CLONE_NEWUSER           0x10000000
-#endif
-#ifndef CLONE_NEWPID
-#  define CLONE_NEWPID            0x20000000
-#endif
-#ifndef CLONE_NEWNET
-#  define CLONE_NEWNET            0x40000000
-#endif
-
-/* From sys/personality.h */
-#define PER_LINUX 0x0000
-#define PER_LINUX32 0x0008
-
-/* Helper functions */
-
-/* Copied from lxc/utils.c */
-static int lxc_wait_for_pid_status(pid_t pid)
-{
-    int status, ret;
-
-again:
-    ret = waitpid(pid, &status, 0);
-    if (ret == -1) {
-        if (errno == EINTR)
-            goto again;
-        return -1;
-    }
-    if (ret != pid)
-        goto again;
-    return status;
-}
-
-/* Copied from lxc/confile.c, with HAVE_SYS_PERSONALITY_H check removed */
-signed long lxc_config_parse_arch(const char *arch)
-{
-    struct per_name {
-        char *name;
-        unsigned long per;
-    } pername[] = {
-        { "x86", PER_LINUX32 },
-        { "linux32", PER_LINUX32 },
-        { "i386", PER_LINUX32 },
-        { "i486", PER_LINUX32 },
-        { "i586", PER_LINUX32 },
-        { "i686", PER_LINUX32 },
-        { "athlon", PER_LINUX32 },
-        { "linux64", PER_LINUX },
-        { "x86_64", PER_LINUX },
-        { "amd64", PER_LINUX },
-    };
-    size_t len = sizeof(pername) / sizeof(pername[0]);
-
-    size_t i;
-
-    for (i = 0; i < len; i++) {
-        if (!strcmp(pername[i].name, arch))
-            return pername[i].per;
-    }
-
-    return -1;
-}
-
-char**
-convert_tuple_to_char_pointer_array(PyObject *argv) {
-    int argc;
-    int i, j;
-    char **result;
-
-    /* not a list or tuple */
-    if (!PyList_Check(argv) && !PyTuple_Check(argv)) {
-        PyErr_SetString(PyExc_TypeError, "Expected list or tuple.");
-        return NULL;
-    }
-
-    argc = PySequence_Fast_GET_SIZE(argv);
-
-    result = (char**) calloc(argc + 1, sizeof(char*));
-
-    if (result == NULL) {
-        PyErr_SetNone(PyExc_MemoryError);
-        return NULL;
-    }
-
-    for (i = 0; i < argc; i++) {
-        char *str = NULL;
-        PyObject *pystr = NULL;
-        PyObject *pyobj = PySequence_Fast_GET_ITEM(argv, i);
-        assert(pyobj != NULL);
-
-        if (!PyUnicode_Check(pyobj)) {
-            PyErr_SetString(PyExc_ValueError, "Expected a string");
-            goto error;
-        }
-
-        pystr = PyUnicode_AsUTF8String(pyobj);
-        if (!pystr) {
-            /* Maybe it wasn't UTF-8 encoded.  An exception is already set. */
-            goto error;
-        }
-
-        str = PyBytes_AsString(pystr);
-        if (!str) {
-            /* Maybe pystr wasn't a valid object. An exception is already set.
-             */
-            Py_DECREF(pystr);
-            goto error;
-        }
-
-        /* We must make a copy of str, because it points into internal memory
-         * which we do not own.  Assume it's NULL terminated, otherwise we'd
-         * have to use PyUnicode_AsUTF8AndSize() and be explicit about copying
-         * the memory.
-         */
-        result[i] = strdup(str);
-
-        /* Do not decref pyobj since we stole a reference by using
-         * PyTuple_GET_ITEM().
-         */
-        Py_DECREF(pystr);
-        if (result[i] == NULL) {
-            PyErr_SetNone(PyExc_MemoryError);
-            goto error;
-        }
-    }
-
-    result[argc] = NULL;
-    return result;
-
-error:
-    /* We can only iterate up to but not including i because malloc() does not
-     * initialize its memory.  Thus if we got here, i points to the index
-     * after the last strdup'd entry in result.
-     */
-    for (j = 0; j < i; j++)
-        free(result[j]);
-    free(result);
-    return NULL;
-}
-
-struct lxc_attach_python_payload {
-    PyObject *fn;
-    PyObject *arg;
-};
-
-static int lxc_attach_python_exec(void* _payload)
-{
-    /* This function is the first one to be called after attaching to a
-     * container. As lxc_attach() calls fork() PyOS_AfterFork should be called
-     * in the new process if the Python interpreter will continue to be used.
-     */
-    PyOS_AfterFork();
-
-    struct lxc_attach_python_payload *payload =
-        (struct lxc_attach_python_payload *)_payload;
-    PyObject *result = PyObject_CallFunctionObjArgs(payload->fn,
-                                                    payload->arg, NULL);
-
-    if (!result) {
-        PyErr_Print();
-        return -1;
-    }
-    if (PyLong_Check(result))
-        return (int)PyLong_AsLong(result);
-    else
-        return -1;
-}
-
-static void lxc_attach_free_options(lxc_attach_options_t *options);
-
-static lxc_attach_options_t *lxc_attach_parse_options(PyObject *kwds)
-{
-    static char *kwlist[] = {"attach_flags", "namespaces", "personality",
-                             "initial_cwd", "uid", "gid", "env_policy",
-                             "extra_env_vars", "extra_keep_env", "stdin",
-                             "stdout", "stderr", NULL};
-    long temp_uid, temp_gid;
-    int temp_env_policy;
-    PyObject *extra_env_vars_obj = NULL;
-    PyObject *extra_keep_env_obj = NULL;
-    PyObject *stdin_obj = NULL;
-    PyObject *stdout_obj = NULL;
-    PyObject *stderr_obj = NULL;
-    PyObject *initial_cwd_obj = NULL;
-    PyObject *dummy = NULL;
-    bool parse_result;
-
-    lxc_attach_options_t default_options = LXC_ATTACH_OPTIONS_DEFAULT;
-    lxc_attach_options_t *options = malloc(sizeof(*options));
-
-    if (!options) {
-        PyErr_SetNone(PyExc_MemoryError);
-        return NULL;
-    }
-    memcpy(options, &default_options, sizeof(*options));
-
-    /* we need some dummy variables because we can't be sure
-     * the data types match completely */
-    temp_uid = -1;
-    temp_gid = -1;
-    temp_env_policy = options->env_policy;
-
-    /* we need a dummy tuple */
-    dummy = PyTuple_New(0);
-
-    parse_result = PyArg_ParseTupleAndKeywords(dummy, kwds, "|iilO&lliOOOOO",
-                                               kwlist, &options->attach_flags,
-                                               &options->namespaces,
-                                               &options->personality,
-                                               PyUnicode_FSConverter,
-                                               &initial_cwd_obj, &temp_uid,
-                                               &temp_gid, &temp_env_policy,
-                                               &extra_env_vars_obj,
-                                               &extra_keep_env_obj,
-                                               &stdin_obj, &stdout_obj,
-                                               &stderr_obj);
-
-    /* immediately get rid of the dummy tuple */
-    Py_DECREF(dummy);
-
-    if (!parse_result) {
-        lxc_attach_free_options(options);
-        return NULL;
-    }
-
-    /* duplicate the string, so we don't depend on some random Python object */
-    if (initial_cwd_obj != NULL) {
-        options->initial_cwd = strndup(PyBytes_AsString(initial_cwd_obj),
-                                       PyBytes_Size(initial_cwd_obj));
-        Py_DECREF(initial_cwd_obj);
-    }
-
-    /* do the type conversion from the types that match the parse string */
-    if (temp_uid != -1) options->uid = (uid_t)temp_uid;
-    if (temp_gid != -1) options->gid = (gid_t)temp_gid;
-    options->env_policy = (lxc_attach_env_policy_t)temp_env_policy;
-
-    if (extra_env_vars_obj)
-        options->extra_env_vars =
-            convert_tuple_to_char_pointer_array(extra_env_vars_obj);
-    if (extra_keep_env_obj)
-        options->extra_keep_env =
-            convert_tuple_to_char_pointer_array(extra_keep_env_obj);
-    if (stdin_obj) {
-        options->stdin_fd = PyObject_AsFileDescriptor(stdin_obj);
-        if (options->stdin_fd < 0) {
-            lxc_attach_free_options(options);
-            return NULL;
-        }
-    }
-    if (stdout_obj) {
-        options->stdout_fd = PyObject_AsFileDescriptor(stdout_obj);
-        if (options->stdout_fd < 0) {
-            lxc_attach_free_options(options);
-            return NULL;
-        }
-    }
-    if (stderr_obj) {
-        options->stderr_fd = PyObject_AsFileDescriptor(stderr_obj);
-        if (options->stderr_fd < 0) {
-            lxc_attach_free_options(options);
-            return NULL;
-        }
-    }
-
-    return options;
-}
-
-void lxc_attach_free_options(lxc_attach_options_t *options)
-{
-    int i;
-    if (!options)
-        return;
-    free(options->initial_cwd);
-    if (options->extra_env_vars) {
-        for (i = 0; options->extra_env_vars[i]; i++)
-            free(options->extra_env_vars[i]);
-        free(options->extra_env_vars);
-    }
-    if (options->extra_keep_env) {
-        for (i = 0; options->extra_keep_env[i]; i++)
-            free(options->extra_keep_env[i]);
-        free(options->extra_keep_env);
-    }
-    free(options);
-}
-
-/* Module functions */
-static PyObject *
-LXC_arch_to_personality(PyObject *self, PyObject *arg)
-{
-    long rv = -1;
-    PyObject *pystr = NULL;
-    char *str;
-
-    if (!PyUnicode_Check(arg)) {
-        PyErr_SetString(PyExc_ValueError, "Expected a string");
-        return NULL;
-    }
-
-    pystr = PyUnicode_AsUTF8String(arg);
-    if (!pystr)
-        return NULL;
-
-    str = PyBytes_AsString(pystr);
-    if (!str)
-        goto out;
-
-    rv = lxc_config_parse_arch(str);
-    if (rv == -1)
-        PyErr_SetString(PyExc_KeyError, "Failed to lookup architecture.");
-
-out:
-    Py_DECREF(pystr);
-    return rv == -1 ? NULL : PyLong_FromLong(rv);
-}
-
-static PyObject *
-LXC_attach_run_command(PyObject *self, PyObject *arg)
-{
-    PyObject *args_obj = NULL;
-    int i, rv;
-    lxc_attach_command_t cmd = {
-        NULL,         /* program */
-        NULL          /* argv[] */
-    };
-
-    if (!PyArg_ParseTuple(arg, "sO", (const char**)&cmd.program, &args_obj))
-        return NULL;
-    if (args_obj && PyList_Check(args_obj)) {
-        cmd.argv = convert_tuple_to_char_pointer_array(args_obj);
-    } else {
-        PyErr_Format(PyExc_TypeError, "Second part of tuple passed to "
-                                      "attach_run_command must be a list.");
-        return NULL;
-    }
-
-    if (!cmd.argv)
-        return NULL;
-
-    rv = lxc_attach_run_command(&cmd);
-
-    for (i = 0; cmd.argv[i]; i++)
-        free(cmd.argv[i]);
-    free(cmd.argv);
-
-    return PyLong_FromLong(rv);
-}
-
-static PyObject *
-LXC_attach_run_shell(PyObject *self, PyObject *arg)
-{
-    int rv;
-
-    rv = lxc_attach_run_shell(NULL);
-
-    return PyLong_FromLong(rv);
-}
-
-static PyObject *
-LXC_get_global_config_item(PyObject *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"key", NULL};
-    char* key = NULL;
-    const char* value = NULL;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|", kwlist,
-                                      &key))
-        return NULL;
-
-    value = lxc_get_global_config_item(key);
-
-    if (!value) {
-        PyErr_SetString(PyExc_KeyError, "Invalid configuration key");
-        return NULL;
-    }
-
-    return PyUnicode_FromString(value);
-}
-
-static PyObject *
-LXC_get_version(PyObject *self, PyObject *args)
-{
-    const char *rv = NULL;
-
-    rv = lxc_get_version();
-    if (!rv) {
-        return PyUnicode_FromString("");
-    }
-
-    return PyUnicode_FromString(rv);
-}
-
-static PyObject *
-LXC_list_containers(PyObject *self, PyObject *args, PyObject *kwds)
-{
-    char **names = NULL;
-    PyObject *list = NULL;
-    int list_count = 0;
-
-    int list_active = 1;
-    int list_defined = 1;
-
-    PyObject *py_list_active = NULL;
-    PyObject *py_list_defined = NULL;
-
-    char* config_path = NULL;
-
-    int i = 0;
-    PyObject *vargs = NULL;
-    static char *kwlist[] = {"active", "defined", "config_path", NULL};
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOs", kwlist,
-                                      &py_list_active,
-                                      &py_list_defined,
-                                      &config_path, &vargs))
-        return NULL;
-
-    /* We default to listing everything */
-    if (py_list_active && py_list_active != Py_True) {
-        list_active = 0;
-    }
-
-    if (py_list_defined && py_list_defined != Py_True) {
-        list_defined = 0;
-    }
-
-    /* Call the right API function based on filters */
-    if (list_active == 1 && list_defined == 1)
-        list_count = list_all_containers(config_path, &names, NULL);
-    else if (list_active == 1)
-        list_count = list_active_containers(config_path, &names, NULL);
-    else if (list_defined == 1)
-        list_count = list_defined_containers(config_path, &names, NULL);
-
-    /* Handle failure */
-    if (list_count < 0) {
-        PyErr_SetString(PyExc_ValueError, "failure to list containers");
-        return NULL;
-    }
-
-    /* Generate the tuple */
-    list = PyTuple_New(list_count);
-    for (i = 0; i < list_count; i++) {
-        if (!names[i]) {
-            continue;
-        }
-
-        PyTuple_SET_ITEM(list, i, PyUnicode_FromString(names[i]));
-        free(names[i]);
-    }
-    free(names);
-
-    return list;
-}
-
-/* Base type and functions for Container */
-typedef struct {
-    PyObject_HEAD
-    struct lxc_container *container;
-} Container;
-
-static void
-Container_dealloc(Container* self)
-{
-    lxc_container_put(self->container);
-    Py_TYPE(self)->tp_free((PyObject*)self);
-}
-
-static int
-Container_init(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"name", "config_path", NULL};
-    char *name = NULL;
-    PyObject *fs_config_path = NULL;
-    char *config_path = NULL;
-
-    if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|O&", kwlist,
-                                      &name,
-                                      PyUnicode_FSConverter, &fs_config_path))
-        return -1;
-
-    if (fs_config_path != NULL) {
-        config_path = PyBytes_AS_STRING(fs_config_path);
-        assert(config_path != NULL);
-    }
-
-    self->container = lxc_container_new(name, config_path);
-    if (!self->container) {
-        Py_XDECREF(fs_config_path);
-
-        PyErr_Format(PyExc_RuntimeError, "%s:%s:%d: error during init for container '%s'.",
-            __FUNCTION__, __FILE__, __LINE__, name);
-        return -1;
-    }
-
-    Py_XDECREF(fs_config_path);
-    return 0;
-}
-
-static PyObject *
-Container_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
-    Container *self;
-
-    self = (Container *)type->tp_alloc(type, 0);
-
-    return (PyObject *)self;
-}
-
-/* Container properties */
-static PyObject *
-Container_config_file_name(Container *self, void *closure)
-{
-    char *rv = NULL;
-
-    rv = self->container->config_file_name(self->container);
-    if (!rv) {
-        return PyUnicode_FromString("");
-    }
-
-    return PyUnicode_FromString(rv);
-}
-
-static PyObject *
-Container_controllable(Container *self, void *closure)
-{
-    if (self->container->may_control(self->container)) {
-        Py_RETURN_TRUE;
-    }
-
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_defined(Container *self, void *closure)
-{
-    if (self->container->is_defined(self->container)) {
-        Py_RETURN_TRUE;
-    }
-
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_init_pid(Container *self, void *closure)
-{
-    return PyLong_FromLong(self->container->init_pid(self->container));
-}
-
-static PyObject *
-Container_name(Container *self, void *closure)
-{
-    if (!self->container->name) {
-        return PyUnicode_FromString("");
-    }
-
-    return PyUnicode_FromString(self->container->name);
-}
-
-static PyObject *
-Container_running(Container *self, void *closure)
-{
-    if (self->container->is_running(self->container)) {
-        Py_RETURN_TRUE;
-    }
-
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_state(Container *self, void *closure)
-{
-    const char *rv = NULL;
-
-    rv = self->container->state(self->container);
-
-    if (!rv) {
-        return PyUnicode_FromString("");
-    }
-
-    return PyUnicode_FromString(rv);
-}
-
-/* Container Functions */
-static PyObject *
-Container_attach_interface(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"src_ifname", "dst_ifname", NULL};
-    char *src_name = NULL;
-    char *dst_name = NULL;
-    PyObject *py_src_name = NULL;
-    PyObject *py_dst_name = NULL;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "O&|O&", kwlist,
-                                      PyUnicode_FSConverter, &py_src_name,
-                                      PyUnicode_FSConverter, &py_dst_name))
-        return NULL;
-
-    if (py_src_name != NULL) {
-        src_name = PyBytes_AS_STRING(py_src_name);
-        assert(src_name != NULL);
-    }
-
-    if (py_dst_name != NULL) {
-        dst_name = PyBytes_AS_STRING(py_dst_name);
-        assert(dst_name != NULL);
-    }
-
-    if (self->container->attach_interface(self->container, src_name, dst_name)) {
-        Py_XDECREF(py_src_name);
-        Py_XDECREF(py_dst_name);
-        Py_RETURN_TRUE;
-    }
-
-    Py_XDECREF(py_src_name);
-    Py_XDECREF(py_dst_name);
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_detach_interface(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"ifname", NULL};
-    char *ifname = NULL;
-    PyObject *py_ifname = NULL;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "O&", kwlist,
-                                      PyUnicode_FSConverter, &py_ifname))
-        return NULL;
-
-    if (py_ifname != NULL) {
-        ifname = PyBytes_AS_STRING(py_ifname);
-        assert(ifname != NULL);
-    }
-
-    if (self->container->detach_interface(self->container, ifname, NULL)) {
-        Py_XDECREF(py_ifname);
-        Py_RETURN_TRUE;
-    }
-
-    Py_XDECREF(py_ifname);
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_add_device_node(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"src_path", "dest_path", NULL};
-    char *src_path = NULL;
-    char *dst_path = NULL;
-    PyObject *py_src_path = NULL;
-    PyObject *py_dst_path = NULL;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "O&|O&", kwlist,
-                                      PyUnicode_FSConverter, &py_src_path,
-                                      PyUnicode_FSConverter, &py_dst_path))
-        return NULL;
-
-    if (py_src_path != NULL) {
-        src_path = PyBytes_AS_STRING(py_src_path);
-        assert(src_path != NULL);
-    }
-
-    if (py_dst_path != NULL) {
-        dst_path = PyBytes_AS_STRING(py_dst_path);
-        assert(dst_path != NULL);
-    }
-
-    if (self->container->add_device_node(self->container, src_path,
-                                         dst_path)) {
-        Py_XDECREF(py_src_path);
-        Py_XDECREF(py_dst_path);
-        Py_RETURN_TRUE;
-    }
-
-    Py_XDECREF(py_src_path);
-    Py_XDECREF(py_dst_path);
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_attach_and_possibly_wait(Container *self, PyObject *args,
-                                   PyObject *kwds, int wait)
-{
-    struct lxc_attach_python_payload payload = { NULL, NULL };
-    lxc_attach_options_t *options = NULL;
-    long ret;
-    pid_t pid;
-
-    if (!PyArg_ParseTuple(args, "O|O", &payload.fn, &payload.arg))
-        return NULL;
-    if (!PyCallable_Check(payload.fn)) {
-        PyErr_Format(PyExc_TypeError, "attach: object not callable");
-        return NULL;
-    }
-
-    options = lxc_attach_parse_options(kwds);
-    if (!options)
-        return NULL;
-
-    ret = self->container->attach(self->container, lxc_attach_python_exec,
-                                  &payload, options, &pid);
-    if (ret < 0)
-        goto out;
-
-    if (wait) {
-        Py_BEGIN_ALLOW_THREADS
-        ret = lxc_wait_for_pid_status(pid);
-        Py_END_ALLOW_THREADS
-        /* handle case where attach fails */
-        if (WIFEXITED(ret) && WEXITSTATUS(ret) == 255)
-            ret = -1;
-    } else {
-        ret = (long)pid;
-    }
-
-out:
-    lxc_attach_free_options(options);
-    return PyLong_FromLong(ret);
-}
-
-static PyObject *
-Container_attach(Container *self, PyObject *args, PyObject *kwds)
-{
-    return Container_attach_and_possibly_wait(self, args, kwds, 0);
-}
-
-static PyObject *
-Container_attach_wait(Container *self, PyObject *args, PyObject *kwds)
-{
-    return Container_attach_and_possibly_wait(self, args, kwds, 1);
-}
-
-static PyObject *
-Container_clear_config(Container *self, PyObject *args, PyObject *kwds)
-{
-    self->container->clear_config(self->container);
-
-    Py_RETURN_NONE;
-}
-
-static PyObject *
-Container_clear_config_item(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"key", NULL};
-    char *key = NULL;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist,
-                                      &key))
-        return NULL;
-
-    if (self->container->clear_config_item(self->container, key)) {
-        Py_RETURN_TRUE;
-    }
-
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_clone(Container *self, PyObject *args, PyObject *kwds)
-{
-    char *newname = NULL;
-    char *config_path = NULL;
-    int flags = 0;
-    char *bdevtype = NULL;
-    char *bdevdata = NULL;
-    unsigned long newsize = 0;
-    char **hookargs = NULL;
-
-    PyObject *py_hookargs = NULL;
-    PyObject *py_config_path = NULL;
-    struct lxc_container *new_container = NULL;
-    int i = 0;
-
-    static char *kwlist[] = {"newname", "config_path", "flags", "bdevtype",
-                             "bdevdata", "newsize", "hookargs", NULL};
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|O&isskO", kwlist,
-                                      &newname,
-                                      PyUnicode_FSConverter, &py_config_path,
-                                      &flags, &bdevtype, &bdevdata, &newsize,
-                                      &py_hookargs))
-        return NULL;
-
-    if (py_hookargs) {
-        if (PyTuple_Check(py_hookargs)) {
-            hookargs = convert_tuple_to_char_pointer_array(py_hookargs);
-            if (!hookargs) {
-                return NULL;
-            }
-        }
-        else {
-            PyErr_SetString(PyExc_ValueError, "hookargs needs to be a tuple");
-            return NULL;
-        }
-    }
-
-    if (py_config_path != NULL) {
-        config_path = PyBytes_AS_STRING(py_config_path);
-        assert(config_path != NULL);
-    }
-
-    new_container = self->container->clone(self->container, newname,
-                                           config_path, flags, bdevtype,
-                                           bdevdata, newsize, hookargs);
-
-    Py_XDECREF(py_config_path);
-
-    if (hookargs) {
-        for (i = 0; i < PyTuple_GET_SIZE(py_hookargs); i++)
-            free(hookargs[i]);
-        free(hookargs);
-    }
-
-    if (new_container == NULL) {
-        Py_RETURN_FALSE;
-    }
-
-    lxc_container_put(new_container);
-
-    Py_RETURN_TRUE;
-}
-
-static PyObject *
-Container_console(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"ttynum", "stdinfd", "stdoutfd", "stderrfd",
-                             "escape", NULL};
-    int ttynum = -1, stdinfd = 0, stdoutfd = 1, stderrfd = 2, escape = 1;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "|iiiii", kwlist,
-                                      &ttynum, &stdinfd, &stdoutfd, &stderrfd,
-                                      &escape))
-        return NULL;
-
-    if (self->container->console(self->container, ttynum,
-            stdinfd, stdoutfd, stderrfd, escape) == 0) {
-        Py_RETURN_TRUE;
-    }
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_console_getfd(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"ttynum", NULL};
-    int ttynum = -1, masterfd;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwlist, &ttynum))
-        return NULL;
-
-    if (self->container->console_getfd(self->container, &ttynum,
-                                       &masterfd) < 0) {
-        PyErr_SetString(PyExc_ValueError, "Unable to allocate tty");
-        return NULL;
-    }
-    return PyLong_FromLong(masterfd);
-}
-
-static PyObject *
-Container_create(Container *self, PyObject *args, PyObject *kwds)
-{
-    char* template_name = NULL;
-    int flags = 0;
-    char** create_args = {NULL};
-    PyObject *retval = NULL;
-    PyObject *vargs = NULL;
-    char *bdevtype = NULL;
-    int i = 0;
-    static char *kwlist[] = {"template", "flags", "bdevtype", "args", NULL};
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "|sisO", kwlist,
-                                      &template_name, &flags, &bdevtype, &vargs))
-        return NULL;
-
-    if (vargs) {
-        if (PyTuple_Check(vargs)) {
-            create_args = convert_tuple_to_char_pointer_array(vargs);
-            if (!create_args) {
-                return NULL;
-            }
-        }
-        else {
-            PyErr_SetString(PyExc_ValueError, "args needs to be a tuple");
-            return NULL;
-        }
-    }
-
-    if (self->container->create(self->container, template_name, bdevtype, NULL,
-                                flags, create_args))
-        retval = Py_True;
-    else
-        retval = Py_False;
-
-    if (vargs) {
-        /* We cannot have gotten here unless vargs was given and create_args
-         * was successfully allocated.
-         */
-        for (i = 0; i < PyTuple_GET_SIZE(vargs); i++)
-            free(create_args[i]);
-        free(create_args);
-    }
-
-    Py_INCREF(retval);
-    return retval;
-}
-
-static PyObject *
-Container_destroy(Container *self, PyObject *args, PyObject *kwds)
-{
-    if (self->container->destroy(self->container)) {
-        Py_RETURN_TRUE;
-    }
-
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_freeze(Container *self, PyObject *args, PyObject *kwds)
-{
-    if (self->container->freeze(self->container)) {
-        Py_RETURN_TRUE;
-    }
-
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_get_cgroup_item(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"key", NULL};
-    char* key = NULL;
-    int len = 0;
-    char* value;
-    PyObject *ret = NULL;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist,
-                                      &key))
-        return NULL;
-
-    len = self->container->get_cgroup_item(self->container, key, NULL, 0);
-
-    if (len < 0) {
-        PyErr_SetString(PyExc_KeyError, "Invalid cgroup entry");
-        return NULL;
-    }
-
-    value = (char*) malloc(sizeof(char)*len + 1);
-    if (value == NULL)
-        return PyErr_NoMemory();
-
-    if (self->container->get_cgroup_item(self->container,
-                                            key, value, len + 1) != len) {
-        PyErr_SetString(PyExc_ValueError, "Unable to read config value");
-        free(value);
-        return NULL;
-    }
-
-    ret = PyUnicode_FromString(value);
-    free(value);
-    return ret;
-}
-
-static PyObject *
-Container_get_config_item(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"key", NULL};
-    char* key = NULL;
-    int len = 0;
-    char* value;
-    PyObject *ret = NULL;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|", kwlist,
-                                      &key))
-        return NULL;
-
-    len = self->container->get_config_item(self->container, key, NULL, 0);
-
-    if (len < 0) {
-        PyErr_SetString(PyExc_KeyError, "Invalid configuration key");
-        return NULL;
-    }
-
-    if (len == 0) {
-        return PyUnicode_FromString("");
-    }
-
-    value = (char*) malloc(sizeof(char)*len + 1);
-    if (value == NULL)
-        return PyErr_NoMemory();
-
-    if (self->container->get_config_item(self->container,
-                                            key, value, len + 1) != len) {
-        PyErr_SetString(PyExc_ValueError, "Unable to read config value");
-        free(value);
-        return NULL;
-    }
-
-    ret = PyUnicode_FromString(value);
-    free(value);
-    return ret;
-}
-
-static PyObject *
-Container_get_config_path(Container *self, PyObject *args, PyObject *kwds)
-{
-    const char *rv = NULL;
-
-    rv = self->container->get_config_path(self->container);
-
-    if (!rv) {
-        return PyUnicode_FromString("");
-    }
-
-    return PyUnicode_FromString(rv);
-}
-
-static PyObject *
-Container_get_keys(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"key", NULL};
-    char* key = NULL;
-    int len = 0;
-    char* value;
-    PyObject *ret = NULL;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "|s", kwlist,
-                                      &key))
-        return NULL;
-
-    len = self->container->get_keys(self->container, key, NULL, 0);
-
-    if (len < 0) {
-        PyErr_SetString(PyExc_KeyError, "Invalid configuration key");
-        return NULL;
-    }
-
-    value = (char*) malloc(sizeof(char)*len + 1);
-    if (value == NULL)
-        return PyErr_NoMemory();
-
-    if (self->container->get_keys(self->container,
-                                    key, value, len + 1) != len) {
-        PyErr_SetString(PyExc_ValueError, "Unable to read config keys");
-        free(value);
-        return NULL;
-    }
-
-    ret = PyUnicode_FromString(value);
-    free(value);
-    return ret;
-}
-
-static PyObject *
-Container_get_interfaces(Container *self)
-{
-    int i = 0;
-    char** interfaces = NULL;
-
-    PyObject* ret;
-
-    /* Get the interfaces */
-    interfaces = self->container->get_interfaces(self->container);
-    if (!interfaces)
-        return PyTuple_New(0);
-
-    /* Count the entries */
-    while (interfaces[i])
-        i++;
-
-    /* Create the new tuple */
-    ret = PyTuple_New(i);
-    if (!ret)
-        return NULL;
-
-    /* Add the entries to the tuple and free the memory */
-    i = 0;
-    while (interfaces[i]) {
-        if (!interfaces[i]) {
-            i++;
-            continue;
-        }
-
-        PyObject *unicode = PyUnicode_FromString(interfaces[i]);
-        if (!unicode) {
-            Py_DECREF(ret);
-            ret = NULL;
-            break;
-        }
-        PyTuple_SET_ITEM(ret, i, unicode);
-        i++;
-    }
-
-    /* Free the list of IPs */
-    i = 0;
-    while (interfaces[i]) {
-        free(interfaces[i]);
-        i++;
-    }
-    free(interfaces);
-
-    return ret;
-}
-
-static PyObject *
-Container_get_ips(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"interface", "family", "scope", NULL};
-    char* interface = NULL;
-    char* family = NULL;
-    int scope = 0;
-
-    int i = 0;
-    char** ips = NULL;
-
-    PyObject* ret;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "|ssi", kwlist,
-                                      &interface, &family, &scope))
-        return NULL;
-
-    /* Get the IPs */
-    ips = self->container->get_ips(self->container, interface, family, scope);
-    if (!ips)
-        return PyTuple_New(0);
-
-    /* Count the entries */
-    while (ips[i])
-        i++;
-
-    /* Create the new tuple */
-    ret = PyTuple_New(i);
-    if (!ret)
-        return NULL;
-
-    /* Add the entries to the tuple and free the memory */
-    i = 0;
-    while (ips[i]) {
-        if (!ips[i]) {
-            i++;
-            continue;
-        }
-
-        PyObject *unicode = PyUnicode_FromString(ips[i]);
-        if (!unicode) {
-            Py_DECREF(ret);
-            ret = NULL;
-            break;
-        }
-        PyTuple_SET_ITEM(ret, i, unicode);
-        i++;
-    }
-
-    /* Free the list of IPs */
-    i = 0;
-    while (ips[i]) {
-        free(ips[i]);
-        i++;
-    }
-    free(ips);
-
-    return ret;
-}
-
-static PyObject *
-Container_get_running_config_item(Container *self, PyObject *args,
-                                  PyObject *kwds)
-{
-    static char *kwlist[] = {"key", NULL};
-    char* key = NULL;
-    char* value = NULL;
-    PyObject *ret = NULL;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|", kwlist,
-                                      &key))
-        return NULL;
-
-    value = self->container->get_running_config_item(self->container, key);
-
-    if (!value)
-        Py_RETURN_NONE;
-
-    ret = PyUnicode_FromString(value);
-    free(value);
-    return ret;
-}
-
-
-static PyObject *
-Container_load_config(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"path", NULL};
-    PyObject *fs_path = NULL;
-    char* path = NULL;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "|O&", kwlist,
-                                      PyUnicode_FSConverter, &fs_path))
-        return NULL;
-
-    if (fs_path != NULL) {
-        path = PyBytes_AS_STRING(fs_path);
-        assert(path != NULL);
-    }
-
-    if (self->container->load_config(self->container, path)) {
-        Py_XDECREF(fs_path);
-        Py_RETURN_TRUE;
-    }
-
-    Py_XDECREF(fs_path);
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_reboot(Container *self, PyObject *args, PyObject *kwds)
-{
-    if (self->container->reboot(self->container)) {
-        Py_RETURN_TRUE;
-    }
-
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_rename(Container *self, PyObject *args, PyObject *kwds)
-{
-    char *new_name = NULL;
-    static char *kwlist[] = {"new_name", NULL};
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|", kwlist,
-                                      &new_name))
-        return NULL;
-
-    if (self->container->rename(self->container, new_name)) {
-        Py_RETURN_TRUE;
-    }
-
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_remove_device_node(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"src_path", "dest_path", NULL};
-    char *src_path = NULL;
-    char *dst_path = NULL;
-    PyObject *py_src_path = NULL;
-    PyObject *py_dst_path = NULL;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "O&|O&", kwlist,
-                                      PyUnicode_FSConverter, &py_src_path,
-                                      PyUnicode_FSConverter, &py_dst_path))
-        return NULL;
-
-    if (py_src_path != NULL) {
-        src_path = PyBytes_AS_STRING(py_src_path);
-        assert(src_path != NULL);
-    }
-
-    if (py_dst_path != NULL) {
-        dst_path = PyBytes_AS_STRING(py_dst_path);
-        assert(dst_path != NULL);
-    }
-
-    if (self->container->remove_device_node(self->container, src_path,
-                                            dst_path)) {
-        Py_XDECREF(py_src_path);
-        Py_XDECREF(py_dst_path);
-        Py_RETURN_TRUE;
-    }
-
-    Py_XDECREF(py_src_path);
-    Py_XDECREF(py_dst_path);
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_save_config(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"path", NULL};
-    PyObject *fs_path = NULL;
-    char* path = NULL;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "|O&", kwlist,
-                                      PyUnicode_FSConverter, &fs_path))
-        return NULL;
-
-    if (fs_path != NULL) {
-        path = PyBytes_AS_STRING(fs_path);
-        assert(path != NULL);
-    }
-
-    if (self->container->save_config(self->container, path)) {
-        Py_XDECREF(fs_path);
-        Py_RETURN_TRUE;
-    }
-
-    Py_XDECREF(fs_path);
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_set_cgroup_item(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"key", "value", NULL};
-    char *key = NULL;
-    char *value = NULL;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "ss", kwlist,
-                                      &key, &value))
-        return NULL;
-
-    if (self->container->set_cgroup_item(self->container, key, value)) {
-        Py_RETURN_TRUE;
-    }
-
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_set_config_item(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"key", "value", NULL};
-    char *key = NULL;
-    char *value = NULL;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "ss", kwlist,
-                                      &key, &value))
-        return NULL;
-
-    if (self->container->set_config_item(self->container, key, value)) {
-        Py_RETURN_TRUE;
-    }
-
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_set_config_path(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"path", NULL};
-    char *path = NULL;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist,
-                                      &path))
-        return NULL;
-
-    if (self->container->set_config_path(self->container, path)) {
-        Py_RETURN_TRUE;
-    }
-
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_shutdown(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"timeout", NULL};
-    int timeout = -1;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwlist,
-                                      &timeout))
-        return NULL;
-
-    if (self->container->shutdown(self->container, timeout)) {
-        Py_RETURN_TRUE;
-    }
-
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_snapshot(Container *self, PyObject *args, PyObject *kwds)
-{
-    char *comment_path = NULL;
-    static char *kwlist[] = {"comment_path", NULL};
-    int retval = 0;
-    int ret = 0;
-    char newname[20];
-    PyObject *py_comment_path = NULL;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "|O&", kwlist,
-                                      PyUnicode_FSConverter, &py_comment_path))
-        return NULL;
-
-    if (py_comment_path != NULL) {
-        comment_path = PyBytes_AS_STRING(py_comment_path);
-        assert(comment_path != NULL);
-    }
-
-    retval = self->container->snapshot(self->container, comment_path);
-
-    Py_XDECREF(py_comment_path);
-
-    if (retval < 0) {
-        Py_RETURN_FALSE;
-    }
-
-    ret = snprintf(newname, 20, "snap%d", retval);
-    if (ret < 0 || ret >= 20)
-        return NULL;
-
-
-    return PyUnicode_FromString(newname);
-}
-
-static PyObject *
-Container_snapshot_destroy(Container *self, PyObject *args, PyObject *kwds)
-{
-    char *name = NULL;
-    static char *kwlist[] = {"name", NULL};
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|", kwlist,
-                                      &name))
-        return NULL;
-
-    if (self->container->snapshot_destroy(self->container, name)) {
-        Py_RETURN_TRUE;
-    }
-
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_snapshot_list(Container *self, PyObject *args, PyObject *kwds)
-{
-    struct lxc_snapshot *snap;
-    int snap_count = 0;
-    PyObject *list = NULL;
-    int i = 0;
-
-    snap_count = self->container->snapshot_list(self->container, &snap);
-
-    if (snap_count < 0) {
-        PyErr_SetString(PyExc_KeyError, "Unable to list snapshots");
-        return NULL;
-    }
-
-    list = PyTuple_New(snap_count);
-    for (i = 0; i < snap_count; i++) {
-        PyObject *list_entry = NULL;
-
-        list_entry = PyTuple_New(4);
-        PyTuple_SET_ITEM(list_entry, 0,
-                         PyUnicode_FromString(snap[i].name));
-        PyTuple_SET_ITEM(list_entry, 1,
-                         PyUnicode_FromString(snap[i].comment_pathname));
-        PyTuple_SET_ITEM(list_entry, 2,
-                         PyUnicode_FromString(snap[i].timestamp));
-        PyTuple_SET_ITEM(list_entry, 3,
-                         PyUnicode_FromString(snap[i].lxcpath));
-
-        snap[i].free(&snap[i]);
-
-        PyTuple_SET_ITEM(list, i, list_entry);
-    }
-
-    return list;
-}
-
-
-static PyObject *
-Container_snapshot_restore(Container *self, PyObject *args, PyObject *kwds)
-{
-    char *name = NULL;
-    char *newname = NULL;
-    static char *kwlist[] = {"name", "newname", NULL};
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|s", kwlist,
-                                      &name, &newname))
-        return NULL;
-
-    if (self->container->snapshot_restore(self->container, name, newname)) {
-        Py_RETURN_TRUE;
-    }
-
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_start(Container *self, PyObject *args, PyObject *kwds)
-{
-    PyObject *useinit = NULL;
-    PyObject *daemonize = NULL;
-    PyObject *close_fds = NULL;
-
-    PyObject *vargs = NULL;
-    char** init_args = {NULL};
-
-    PyObject *retval = NULL;
-    int init_useinit = 0, i = 0;
-    static char *kwlist[] = {"useinit", "daemonize", "close_fds",
-                             "cmd", NULL};
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist,
-                                      &useinit, &daemonize, &close_fds,
-                                      &vargs))
-        return NULL;
-
-    if (useinit && useinit == Py_True) {
-        init_useinit = 1;
-    }
-
-    if (vargs && PyTuple_Check(vargs)) {
-        init_args = convert_tuple_to_char_pointer_array(vargs);
-        if (!init_args) {
-            return NULL;
-        }
-    }
-
-    if (close_fds && close_fds == Py_True) {
-        self->container->want_close_all_fds(self->container, true);
-    }
-    else {
-        self->container->want_close_all_fds(self->container, false);
-    }
-
-    if (!daemonize || daemonize == Py_True) {
-        self->container->want_daemonize(self->container, true);
-    }
-    else {
-        self->container->want_daemonize(self->container, false);
-    }
-
-    if (self->container->start(self->container, init_useinit, init_args))
-        retval = Py_True;
-    else
-        retval = Py_False;
-
-    if (vargs) {
-        /* We cannot have gotten here unless vargs was given and create_args
-         * was successfully allocated.
-         */
-        for (i = 0; i < PyTuple_GET_SIZE(vargs); i++)
-            free(init_args[i]);
-        free(init_args);
-    }
-
-    Py_INCREF(retval);
-    return retval;
-}
-
-static PyObject *
-Container_stop(Container *self, PyObject *args, PyObject *kwds)
-{
-    if (self->container->stop(self->container)) {
-        Py_RETURN_TRUE;
-    }
-
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_unfreeze(Container *self, PyObject *args, PyObject *kwds)
-{
-    if (self->container->unfreeze(self->container)) {
-        Py_RETURN_TRUE;
-    }
-
-    Py_RETURN_FALSE;
-}
-
-static PyObject *
-Container_wait(Container *self, PyObject *args, PyObject *kwds)
-{
-    static char *kwlist[] = {"state", "timeout", NULL};
-    char *state = NULL;
-    int timeout = -1;
-
-    if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|i", kwlist,
-                                      &state, &timeout))
-        return NULL;
-
-    if (self->container->wait(self->container, state, timeout)) {
-        Py_RETURN_TRUE;
-    }
-
-    Py_RETURN_FALSE;
-}
-
-/* Function/Properties list */
-static PyGetSetDef Container_getseters[] = {
-    {"config_file_name",
-     (getter)Container_config_file_name, NULL,
-     "Path to the container configuration",
-     NULL},
-    {"controllable",
-     (getter)Container_controllable, NULL,
-     "Boolean indicating whether the container may be controlled",
-     NULL},
-    {"defined",
-     (getter)Container_defined, NULL,
-     "Boolean indicating whether the container configuration exists",
-     NULL},
-    {"init_pid",
-     (getter)Container_init_pid, NULL,
-     "PID of the container's init process in the host's PID namespace",
-     NULL},
-    {"name",
-     (getter)Container_name, NULL,
-     "Container name",
-     NULL},
-    {"running",
-     (getter)Container_running, NULL,
-     "Boolean indicating whether the container is running or not",
-     NULL},
-    {"state",
-     (getter)Container_state, NULL,
-     "Container state",
-     NULL},
-    {NULL, NULL, NULL, NULL, NULL}
-};
-
-static PyMethodDef Container_methods[] = {
-    {"attach_interface", (PyCFunction)Container_attach_interface,
-     METH_VARARGS|METH_KEYWORDS,
-     "attach_interface(src_ifname, dest_ifname) -> boolean\n"
-     "\n"
-     "Pass a new network device to the container."
-    },
-    {"detach_interface", (PyCFunction)Container_detach_interface,
-     METH_VARARGS|METH_KEYWORDS,
-     "detach_interface(ifname) -> boolean\n"
-     "\n"
-     "detach a network device from the container."
-    },
-    {"add_device_node", (PyCFunction)Container_add_device_node,
-     METH_VARARGS|METH_KEYWORDS,
-     "add_device_node(src_path, dest_path) -> boolean\n"
-     "\n"
-     "Pass a new device to the container."
-    },
-    {"attach", (PyCFunction)Container_attach,
-     METH_VARARGS|METH_KEYWORDS,
-     "attach(run, payload) -> int\n"
-     "\n"
-     "Attach to the container. Returns the pid of the attached process."
-    },
-    {"attach_wait", (PyCFunction)Container_attach_wait,
-     METH_VARARGS|METH_KEYWORDS,
-     "attach(run, payload) -> int\n"
-     "\n"
-     "Attach to the container. Returns the exit code of the process."
-    },
-    {"clear_config", (PyCFunction)Container_clear_config,
-     METH_NOARGS,
-     "clear_config()\n"
-     "\n"
-     "Clear any container configuration."
-    },
-    {"clear_config_item", (PyCFunction)Container_clear_config_item,
-     METH_VARARGS|METH_KEYWORDS,
-     "clear_config_item(key) -> boolean\n"
-     "\n"
-     "Clear the current value of a config key."
-    },
-    {"console", (PyCFunction)Container_console,
-     METH_VARARGS|METH_KEYWORDS,
-     "console(ttynum = -1, stdinfd = 0, stdoutfd = 1, stderrfd = 2, "
-     "escape = 0) -> boolean\n"
-     "\n"
-     "Attach to container's console."
-    },
-    {"console_getfd", (PyCFunction)Container_console_getfd,
-     METH_VARARGS|METH_KEYWORDS,
-     "console(ttynum = -1) -> boolean\n"
-     "\n"
-     "Attach to container's console."
-    },
-    {"clone", (PyCFunction)Container_clone,
-     METH_VARARGS|METH_KEYWORDS,
-     "clone(newname, config_path, flags, bdevtype, bdevdata, newsize, "
-     "hookargs) -> boolean\n"
-     "\n"
-     "Create a new container based on the current one."
-    },
-    {"create", (PyCFunction)Container_create,
-     METH_VARARGS|METH_KEYWORDS,
-     "create(template, args = (,)) -> boolean\n"
-     "\n"
-     "Create a new rootfs for the container, using the given template "
-     "and passing some optional arguments to it."
-    },
-    {"destroy", (PyCFunction)Container_destroy,
-     METH_NOARGS,
-     "destroy() -> boolean\n"
-     "\n"
-     "Destroys the container."
-    },
-    {"freeze", (PyCFunction)Container_freeze,
-     METH_NOARGS,
-     "freeze() -> boolean\n"
-     "\n"
-     "Freezes the container and returns its return code."
-    },
-    {"get_cgroup_item", (PyCFunction)Container_get_cgroup_item,
-     METH_VARARGS|METH_KEYWORDS,
-     "get_cgroup_item(key) -> string\n"
-     "\n"
-     "Get the current value of a cgroup entry."
-    },
-    {"get_config_item", (PyCFunction)Container_get_config_item,
-     METH_VARARGS|METH_KEYWORDS,
-     "get_config_item(key) -> string\n"
-     "\n"
-     "Get the current value of a config key."
-    },
-    {"get_config_path", (PyCFunction)Container_get_config_path,
-     METH_NOARGS,
-     "get_config_path() -> string\n"
-     "\n"
-     "Return the LXC config path (where the containers are stored)."
-    },
-    {"get_keys", (PyCFunction)Container_get_keys,
-     METH_VARARGS|METH_KEYWORDS,
-     "get_keys(key) -> string\n"
-     "\n"
-     "Get a list of valid sub-keys for a key."
-    },
-    {"get_interfaces", (PyCFunction)Container_get_interfaces,
-     METH_NOARGS,
-     "get_interface() -> tuple\n"
-     "\n"
-     "Get a tuple of interfaces for the container."
-    },
-    {"get_ips", (PyCFunction)Container_get_ips,
-     METH_VARARGS|METH_KEYWORDS,
-     "get_ips(interface, family, scope) -> tuple\n"
-     "\n"
-     "Get a tuple of IPs for the container."
-    },
-    {"get_running_config_item", (PyCFunction)Container_get_running_config_item,
-     METH_VARARGS|METH_KEYWORDS,
-     "get_running_config_item(key) -> string\n"
-     "\n"
-     "Get the runtime value of a config key."
-    },
-    {"load_config", (PyCFunction)Container_load_config,
-     METH_VARARGS|METH_KEYWORDS,
-     "load_config(path = DEFAULT) -> boolean\n"
-     "\n"
-     "Read the container configuration from its default "
-     "location or from an alternative location if provided."
-    },
-    {"reboot", (PyCFunction)Container_reboot,
-     METH_NOARGS,
-     "reboot() -> boolean\n"
-     "\n"
-     "Ask the container to reboot."
-    },
-    {"rename", (PyCFunction)Container_rename,
-     METH_VARARGS|METH_KEYWORDS,
-     "rename(new_name) -> boolean\n"
-     "\n"
-     "Rename the container."
-    },
-    {"remove_device_node", (PyCFunction)Container_remove_device_node,
-     METH_VARARGS|METH_KEYWORDS,
-     "remove_device_node(src_path, dest_path) -> boolean\n"
-     "\n"
-     "Remove a device from the container."
-    },
-    {"save_config", (PyCFunction)Container_save_config,
-     METH_VARARGS|METH_KEYWORDS,
-     "save_config(path = DEFAULT) -> boolean\n"
-     "\n"
-     "Save the container configuration to its default "
-     "location or to an alternative location if provided."
-    },
-    {"set_cgroup_item", (PyCFunction)Container_set_cgroup_item,
-     METH_VARARGS|METH_KEYWORDS,
-     "set_cgroup_item(key, value) -> boolean\n"
-     "\n"
-     "Set a cgroup entry to the provided value."
-    },
-    {"set_config_item", (PyCFunction)Container_set_config_item,
-     METH_VARARGS|METH_KEYWORDS,
-     "set_config_item(key, value) -> boolean\n"
-     "\n"
-     "Set a config key to the provided value."
-    },
-    {"set_config_path", (PyCFunction)Container_set_config_path,
-     METH_VARARGS|METH_KEYWORDS,
-     "set_config_path(path) -> boolean\n"
-     "\n"
-     "Set the LXC config path (where the containers are stored)."
-    },
-    {"shutdown", (PyCFunction)Container_shutdown,
-     METH_VARARGS|METH_KEYWORDS,
-     "shutdown(timeout = -1) -> boolean\n"
-     "\n"
-     "Sends SIGPWR to the container and wait for it to shutdown."
-     "-1 means wait forever, 0 means skip waiting."
-    },
-    {"snapshot", (PyCFunction)Container_snapshot,
-     METH_VARARGS|METH_KEYWORDS,
-     "snapshot(comment_path = None) -> string\n"
-     "\n"
-     "Snapshot the container and return the snapshot name "
-     "(or False on error)."
-    },
-    {"snapshot_destroy", (PyCFunction)Container_snapshot_destroy,
-     METH_VARARGS|METH_KEYWORDS,
-     "snapshot_destroy(name) -> boolean\n"
-     "\n"
-     "Destroy a snapshot."
-    },
-    {"snapshot_list", (PyCFunction)Container_snapshot_list,
-     METH_NOARGS,
-     "snapshot_list() -> tuple of snapshot tuples\n"
-     "\n"
-     "List all snapshots for a container."
-    },
-    {"snapshot_restore", (PyCFunction)Container_snapshot_restore,
-     METH_VARARGS|METH_KEYWORDS,
-     "snapshot_restore(name, newname = None) -> boolean\n"
-     "\n"
-     "Restore a container snapshot. If newname is provided a new "
-     "container will be created from the snapshot, otherwise an in-place "
-     "restore will be attempted."
-    },
-    {"start", (PyCFunction)Container_start,
-     METH_VARARGS|METH_KEYWORDS,
-     "start(useinit = False, daemonize=True, close_fds=False, "
-     "cmd = (,)) -> boolean\n"
-     "\n"
-     "Start the container, return True on success.\n"
-     "When set useinit will make LXC use lxc-init to start the container.\n"
-     "The container can be started in the foreground with daemonize=False.\n"
-     "All fds may also be closed by passing close_fds=True."
-    },
-    {"stop", (PyCFunction)Container_stop,
-     METH_NOARGS,
-     "stop() -> boolean\n"
-     "\n"
-     "Stop the container and returns its return code."
-    },
-    {"unfreeze", (PyCFunction)Container_unfreeze,
-     METH_NOARGS,
-     "unfreeze() -> boolean\n"
-     "\n"
-     "Unfreezes the container and returns its return code."
-    },
-    {"wait", (PyCFunction)Container_wait,
-     METH_VARARGS|METH_KEYWORDS,
-     "wait(state, timeout = -1) -> boolean\n"
-     "\n"
-     "Wait for the container to reach a given state or timeout."
-    },
-    {NULL, NULL, 0, NULL}
-};
-
-static PyTypeObject _lxc_ContainerType = {
-PyVarObject_HEAD_INIT(NULL, 0)
-    "lxc.Container",                /* tp_name */
-    sizeof(Container),              /* tp_basicsize */
-    0,                              /* tp_itemsize */
-    (destructor)Container_dealloc,  /* tp_dealloc */
-    0,                              /* tp_print */
-    0,                              /* tp_getattr */
-    0,                              /* tp_setattr */
-    0,                              /* tp_reserved */
-    0,                              /* tp_repr */
-    0,                              /* tp_as_number */
-    0,                              /* tp_as_sequence */
-    0,                              /* tp_as_mapping */
-    0,                              /* tp_hash  */
-    0,                              /* tp_call */
-    0,                              /* tp_str */
-    0,                              /* tp_getattro */
-    0,                              /* tp_setattro */
-    0,                              /* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT |
-        Py_TPFLAGS_BASETYPE,        /* tp_flags */
-    "Container objects",            /* tp_doc */
-    0,                              /* tp_traverse */
-    0,                              /* tp_clear */
-    0,                              /* tp_richcompare */
-    0,                              /* tp_weaklistoffset */
-    0,                              /* tp_iter */
-    0,                              /* tp_iternext */
-    Container_methods,              /* tp_methods */
-    0,                              /* tp_members */
-    Container_getseters,            /* tp_getset */
-    0,                              /* tp_base */
-    0,                              /* tp_dict */
-    0,                              /* tp_descr_get */
-    0,                              /* tp_descr_set */
-    0,                              /* tp_dictoffset */
-    (initproc)Container_init,       /* tp_init */
-    0,                              /* tp_alloc */
-    Container_new,                  /* tp_new */
-};
-
-static PyMethodDef LXC_methods[] = {
-    {"arch_to_personality", (PyCFunction)LXC_arch_to_personality, METH_O,
-     "Returns the process personality of the corresponding architecture"},
-    {"attach_run_command", (PyCFunction)LXC_attach_run_command, METH_O,
-     "Runs a command when attaching, to use as the run parameter for attach "
-     "or attach_wait"},
-    {"attach_run_shell", (PyCFunction)LXC_attach_run_shell, METH_O,
-     "Starts up a shell when attaching, to use as the run parameter for "
-     "attach or attach_wait"},
-    {"get_global_config_item", (PyCFunction)LXC_get_global_config_item,
-     METH_VARARGS|METH_KEYWORDS,
-     "Returns the current LXC config path"},
-    {"get_version", (PyCFunction)LXC_get_version, METH_NOARGS,
-     "Returns the current LXC library version"},
-    {"list_containers", (PyCFunction)LXC_list_containers,
-     METH_VARARGS|METH_KEYWORDS,
-     "Returns a list of container names or objects"},
-    {NULL, NULL, 0, NULL}
-};
-
-static PyModuleDef _lxcmodule = {
-    PyModuleDef_HEAD_INIT,
-    "_lxc",
-    "Binding for liblxc in python",
-    -1,
-    LXC_methods
-};
-
-PyMODINIT_FUNC
-PyInit__lxc(void)
-{
-    PyObject* m;
-    PyObject* d;
-
-    if (PyType_Ready(&_lxc_ContainerType) < 0)
-        return NULL;
-
-    m = PyModule_Create(&_lxcmodule);
-    if (m == NULL)
-        return NULL;
-
-    Py_INCREF(&_lxc_ContainerType);
-    PyModule_AddObject(m, "Container", (PyObject *)&_lxc_ContainerType);
-
-    /* add constants */
-    d = PyModule_GetDict(m);
-
-    #define PYLXC_EXPORT_CONST(c) \
-        PyDict_SetItemString(d, #c, PyLong_FromLong(c))
-
-    /* namespace flags (no other python lib exports this) */
-    PYLXC_EXPORT_CONST(CLONE_NEWUTS);
-    PYLXC_EXPORT_CONST(CLONE_NEWIPC);
-    PYLXC_EXPORT_CONST(CLONE_NEWUSER);
-    PYLXC_EXPORT_CONST(CLONE_NEWPID);
-    PYLXC_EXPORT_CONST(CLONE_NEWNET);
-    PYLXC_EXPORT_CONST(CLONE_NEWNS);
-
-    /* attach: environment variable handling */
-    PYLXC_EXPORT_CONST(LXC_ATTACH_CLEAR_ENV);
-    PYLXC_EXPORT_CONST(LXC_ATTACH_KEEP_ENV);
-
-    /* attach: attach options */
-    PYLXC_EXPORT_CONST(LXC_ATTACH_DEFAULT);
-    PYLXC_EXPORT_CONST(LXC_ATTACH_DROP_CAPABILITIES);
-    PYLXC_EXPORT_CONST(LXC_ATTACH_LSM_EXEC);
-    PYLXC_EXPORT_CONST(LXC_ATTACH_LSM_NOW);
-    PYLXC_EXPORT_CONST(LXC_ATTACH_MOVE_TO_CGROUP);
-    PYLXC_EXPORT_CONST(LXC_ATTACH_REMOUNT_PROC_SYS);
-    PYLXC_EXPORT_CONST(LXC_ATTACH_SET_PERSONALITY);
-
-    /* clone: clone flags */
-    PYLXC_EXPORT_CONST(LXC_CLONE_KEEPBDEVTYPE);
-    PYLXC_EXPORT_CONST(LXC_CLONE_KEEPMACADDR);
-    PYLXC_EXPORT_CONST(LXC_CLONE_KEEPNAME);
-    PYLXC_EXPORT_CONST(LXC_CLONE_MAYBE_SNAPSHOT);
-    PYLXC_EXPORT_CONST(LXC_CLONE_SNAPSHOT);
-
-    /* create: create flags */
-    PYLXC_EXPORT_CONST(LXC_CREATE_QUIET);
-
-    #undef PYLXC_EXPORT_CONST
-
-    return m;
-}
-
-/*
- * kate: space-indent on; indent-width 4; mixedindent off; indent-mode cstyle;
- */
diff --git a/src/python-lxc/lxc/__init__.py b/src/python-lxc/lxc/__init__.py
deleted file mode 100644
index ccc4d18bb..000000000
--- a/src/python-lxc/lxc/__init__.py
+++ /dev/null
@@ -1,510 +0,0 @@
-#
-# -*- coding: utf-8 -*-
-# python-lxc: Python bindings for LXC
-#
-# (C) Copyright Canonical Ltd. 2012
-#
-# Authors:
-# Stéphane Graber <stgraber at ubuntu.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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
-# USA
-#
-
-import _lxc
-import os
-import subprocess
-import time
-
-default_config_path = _lxc.get_global_config_item("lxc.lxcpath")
-get_global_config_item = _lxc.get_global_config_item
-version = _lxc.get_version()
-
-
-class ContainerNetwork(object):
-    props = {}
-
-    def __init__(self, container, index):
-        self.container = container
-        self.index = index
-
-        for key in self.container.get_keys("lxc.net.%s" % self.index):
-            if "." in key:
-                self.props[key.replace(".", "_")] = key
-            else:
-                self.props[key] = key
-
-        if not self.props:
-            return False
-
-    def __delattr__(self, key):
-        if key in ["container", "index", "props"]:
-            return object.__delattr__(self, key)
-
-        if key not in self.props:
-            raise AttributeError("'%s' network has no attribute '%s'" % (
-                                 self.__get_network_item("type"), key))
-
-        return self.__clear_network_item(self.props[key])
-
-    def __dir__(self):
-        return sorted(self.props.keys())
-
-    def __getattr__(self, key):
-        if key in ["container", "index", "props"]:
-            return object.__getattribute__(self, key)
-
-        if key not in self.props:
-            raise AttributeError("'%s' network has no attribute '%s'" % (
-                                 self.__get_network_item("type"), key))
-
-        return self.__get_network_item(self.props[key])
-
-    def __hasattr__(self, key):
-        if key in ["container", "index", "props"]:
-            return object.__hasattr__(self, key)
-
-        if key not in self.props:
-            raise AttributeError("'%s' network has no attribute '%s'" % (
-                                 self.__get_network_item("type"), key))
-
-        return True
-
-    def __repr__(self):
-        return "'%s' network at index '%s'" % (
-            self.__get_network_item("type"), self.index)
-
-    def __setattr__(self, key, value):
-        if key in ["container", "index", "props"]:
-            return object.__setattr__(self, key, value)
-
-        if key not in self.props:
-            raise AttributeError("'%s' network has no attribute '%s'" % (
-                                 self.__get_network_item("type"), key))
-
-        return self.__set_network_item(self.props[key], value)
-
-    def __clear_network_item(self, key):
-        if key in ("ipv4", "ipv6"):
-            return self.container.clear_config_item("lxc.net.%s.%s" % (
-                                                    self.index, key))
-        else:
-            return self.container.set_config_item("lxc.net.%s.%s" % (
-                                                    self.index, key), "")
-
-    def __get_network_item(self, key):
-        return self.container.get_config_item("lxc.net.%s.%s" % (
-                                              self.index, key))
-
-    def __set_network_item(self, key, value):
-        return self.container.set_config_item("lxc.net.%s.%s" % (
-                                              self.index, key), value)
-
-
-class ContainerNetworkList():
-    def __init__(self, container):
-        self.container = container
-
-    def __getitem__(self, index):
-        if index >= len(self):
-            raise IndexError("list index out of range")
-
-        return ContainerNetwork(self.container, index)
-
-    def __len__(self):
-        values = self.container.get_config_item("lxc.net")
-
-        if values:
-            return len(values)
-        else:
-            return 0
-
-    def add(self, network_type):
-        index = len(self)
-
-        return self.container.set_config_item("lxc.net.%s.type" % index,
-                                              network_type)
-
-    def remove(self, index):
-        count = len(self)
-        if index >= count:
-            raise IndexError("list index out of range")
-
-        return self.container.clear_config_item("lxc.net.%s" % index)
-
-
-class Container(_lxc.Container):
-    def __init__(self, name, config_path=None):
-        """
-            Creates a new Container instance.
-        """
-
-        if config_path:
-            _lxc.Container.__init__(self, name, config_path)
-        else:
-            _lxc.Container.__init__(self, name)
-
-        self.network = ContainerNetworkList(self)
-
-    def add_device_net(self, name, destname=None):
-        """
-            Add network device to running container.
-        """
-
-        if not self.running:
-            return False
-
-        if os.path.exists("/sys/class/net/%s/phy80211/name" % name):
-            with open("/sys/class/net/%s/phy80211/name" % name) as fd:
-                phy = fd.read().strip()
-
-            if subprocess.call(['iw', 'phy', phy, 'set', 'netns',
-                                str(self.init_pid)]) != 0:
-                return False
-
-            if destname:
-                def rename_interface(args):
-                    old, new = args
-
-                    return subprocess.call(['ip', 'link', 'set',
-                                            'dev', old, 'name', new])
-
-                return self.attach_wait(rename_interface, (name, destname),
-                                        namespaces=(CLONE_NEWNET)) == 0
-
-            return True
-
-        if not destname:
-            destname = name
-
-        if not os.path.exists("/sys/class/net/%s/" % name):
-            return False
-
-        return subprocess.call(['ip', 'link', 'set',
-                                'dev', name,
-                                'netns', str(self.init_pid),
-                                'name', destname]) == 0
-
-    def append_config_item(self, key, value):
-        """
-            Append 'value' to 'key', assuming 'key' is a list.
-            If 'key' isn't a list, 'value' will be set as the value of 'key'.
-        """
-
-        return _lxc.Container.set_config_item(self, key, value)
-
-    def create(self, template=None, flags=0, args=(), bdevtype=None):
-        """
-            Create a new rootfs for the container.
-
-            "template" if passed must be a valid template name.
-
-            "flags" (optional) is an integer representing the optional
-            create flags to be passed.
-
-            "args" (optional) is a tuple of arguments to pass to the
-            template. It can also be provided as a dict.
-        """
-        if isinstance(args, dict):
-            tmp_args = []
-            for item in args.items():
-                tmp_args.append("--%s" % item[0])
-                tmp_args.append("%s" % item[1])
-            args = tmp_args
-        template_args = {}
-        if template:
-    	    template_args['template'] = template
-        template_args['flags'] = flags
-        template_args['args'] = tuple(args)
-        if bdevtype:
-            template_args['bdevtype'] = bdevtype
-        return _lxc.Container.create(self, **template_args)
-
-    def clone(self, newname, config_path=None, flags=0, bdevtype=None,
-              bdevdata=None, newsize=0, hookargs=()):
-        """
-            Clone the current container.
-        """
-
-        args = {}
-        args['newname'] = newname
-        args['flags'] = flags
-        args['newsize'] = newsize
-        args['hookargs'] = hookargs
-        if config_path:
-            args['config_path'] = config_path
-        if bdevtype:
-            args['bdevtype'] = bdevtype
-        if bdevdata:
-            args['bdevdata'] = bdevdata
-
-        if _lxc.Container.clone(self, **args):
-            return Container(newname, config_path=config_path)
-        else:
-            return False
-
-    def console(self, ttynum=-1, stdinfd=0, stdoutfd=1, stderrfd=2, escape=1):
-        """
-            Attach to console of running container.
-        """
-
-        if not self.running:
-            return False
-
-        return _lxc.Container.console(self, ttynum, stdinfd, stdoutfd,
-                                      stderrfd, escape)
-
-    def console_getfd(self, ttynum=-1):
-        """
-            Attach to console of running container.
-        """
-
-        if not self.running:
-            return False
-
-        return _lxc.Container.console_getfd(self, ttynum)
-
-    def get_cgroup_item(self, key):
-        """
-            Returns the value for a given cgroup entry.
-            A list is returned when multiple values are set.
-        """
-        value = _lxc.Container.get_cgroup_item(self, key)
-
-        if value is False:
-            return False
-        else:
-            return value.rstrip("\n")
-
-    def get_config_item(self, key):
-        """
-            Returns the value for a given config key.
-            A list is returned when multiple values are set.
-        """
-        value = _lxc.Container.get_config_item(self, key)
-
-        if value is False:
-            return False
-        elif value.endswith("\n"):
-            return value.rstrip("\n").split("\n")
-        else:
-            return value
-
-    def get_keys(self, key=None):
-        """
-            Returns a list of valid sub-keys.
-        """
-        if key:
-            value = _lxc.Container.get_keys(self, key)
-        else:
-            value = _lxc.Container.get_keys(self)
-
-        if value is False:
-            return False
-        elif value.endswith("\n"):
-            return value.rstrip("\n").split("\n")
-        else:
-            return value
-
-    def get_interfaces(self):
-        """
-            Get a tuple of interfaces for the container.
-        """
-
-        return _lxc.Container.get_interfaces(self)
-
-    def get_ips(self, interface=None, family=None, scope=None, timeout=0):
-        """
-            Get a tuple of IPs for the container.
-        """
-
-        kwargs = {}
-        if interface:
-            kwargs['interface'] = interface
-        if family:
-            kwargs['family'] = family
-        if scope:
-            kwargs['scope'] = scope
-
-        ips = None
-        timeout = int(os.environ.get('LXC_GETIP_TIMEOUT', timeout))
-
-        while not ips:
-            ips = _lxc.Container.get_ips(self, **kwargs)
-            if timeout == 0:
-                break
-
-            timeout -= 1
-            time.sleep(1)
-
-        return ips
-
-    def rename(self, new_name):
-        """
-            Rename the container.
-            On success, returns the new Container object.
-            On failure, returns False.
-        """
-
-        if _lxc.Container.rename(self, new_name):
-            return Container(new_name)
-
-        return False
-
-    def set_config_item(self, key, value):
-        """
-            Set a config key to a provided value.
-            The value can be a list for the keys supporting multiple values.
-        """
-        try:
-            old_value = self.get_config_item(key)
-        except KeyError:
-            old_value = None
-
-        # Check if it's a list
-        def set_key(key, value):
-            self.clear_config_item(key)
-            if isinstance(value, list):
-                for entry in value:
-                    if not _lxc.Container.set_config_item(self, key, entry):
-                        return False
-            else:
-                _lxc.Container.set_config_item(self, key, value)
-
-        set_key(key, value)
-        new_value = self.get_config_item(key)
-
-        # loglevel is special and won't match the string we set
-        if key == "lxc.log.level":
-            new_value = value
-
-        if (isinstance(value, str) and isinstance(new_value, str) and
-                value == new_value):
-            return True
-        elif (isinstance(value, list) and isinstance(new_value, list) and
-                set(value) == set(new_value)):
-            return True
-        elif (isinstance(value, str) and isinstance(new_value, list) and
-                set([value]) == set(new_value)):
-            return True
-        elif old_value:
-            set_key(key, old_value)
-            return False
-        else:
-            self.clear_config_item(key)
-            return False
-
-    def wait(self, state, timeout=-1):
-        """
-            Wait for the container to reach a given state or timeout.
-        """
-
-        if isinstance(state, str):
-            state = state.upper()
-
-        return _lxc.Container.wait(self, state, timeout)
-
-
-def list_containers(active=True, defined=True,
-                    as_object=False, config_path=None):
-    """
-        List the containers on the system.
-    """
-
-    if config_path:
-        if not os.path.exists(config_path):
-            return tuple()
-        try:
-            entries = _lxc.list_containers(active=active, defined=defined,
-                                           config_path=config_path)
-        except ValueError:
-            return tuple()
-    else:
-        try:
-            entries = _lxc.list_containers(active=active, defined=defined)
-        except ValueError:
-            return tuple()
-
-    if as_object:
-        return tuple([Container(name, config_path) for name in entries])
-    else:
-        return entries
-
-
-def attach_run_command(cmd):
-    """
-        Run a command when attaching
-
-        Please do not call directly, this will execvp the command.
-        This is to be used in conjunction with the attach method
-        of a container.
-    """
-    if isinstance(cmd, tuple):
-        return _lxc.attach_run_command(cmd)
-    elif isinstance(cmd, list):
-        return _lxc.attach_run_command((cmd[0], cmd))
-    else:
-        return _lxc.attach_run_command((cmd, [cmd]))
-
-
-def attach_run_shell():
-    """
-        Run a shell when attaching
-
-        Please do not call directly, this will execvp the shell.
-        This is to be used in conjunction with the attach method
-        of a container.
-    """
-    return _lxc.attach_run_shell(None)
-
-
-def arch_to_personality(arch):
-    """
-        Determine the process personality corresponding to the architecture
-    """
-    if isinstance(arch, bytes):
-        arch = str(arch, 'utf-8')
-    return _lxc.arch_to_personality(arch)
-
-# namespace flags (no other python lib exports this)
-CLONE_NEWIPC = _lxc.CLONE_NEWIPC
-CLONE_NEWNET = _lxc.CLONE_NEWNET
-CLONE_NEWNS = _lxc.CLONE_NEWNS
-CLONE_NEWPID = _lxc.CLONE_NEWPID
-CLONE_NEWUSER = _lxc.CLONE_NEWUSER
-CLONE_NEWUTS = _lxc.CLONE_NEWUTS
-
-# attach: environment variable handling
-LXC_ATTACH_CLEAR_ENV = _lxc.LXC_ATTACH_CLEAR_ENV
-LXC_ATTACH_KEEP_ENV = _lxc.LXC_ATTACH_KEEP_ENV
-
-# attach: attach options
-LXC_ATTACH_DEFAULT = _lxc.LXC_ATTACH_DEFAULT
-LXC_ATTACH_DROP_CAPABILITIES = _lxc.LXC_ATTACH_DROP_CAPABILITIES
-LXC_ATTACH_LSM_EXEC = _lxc.LXC_ATTACH_LSM_EXEC
-LXC_ATTACH_LSM_NOW = _lxc.LXC_ATTACH_LSM_NOW
-LXC_ATTACH_MOVE_TO_CGROUP = _lxc.LXC_ATTACH_MOVE_TO_CGROUP
-LXC_ATTACH_REMOUNT_PROC_SYS = _lxc.LXC_ATTACH_REMOUNT_PROC_SYS
-LXC_ATTACH_SET_PERSONALITY = _lxc.LXC_ATTACH_SET_PERSONALITY
-
-# clone: clone flags
-LXC_CLONE_KEEPBDEVTYPE = _lxc.LXC_CLONE_KEEPBDEVTYPE
-LXC_CLONE_KEEPMACADDR = _lxc.LXC_CLONE_KEEPMACADDR
-LXC_CLONE_KEEPNAME = _lxc.LXC_CLONE_KEEPNAME
-LXC_CLONE_MAYBE_SNAPSHOT = _lxc.LXC_CLONE_MAYBE_SNAPSHOT
-LXC_CLONE_SNAPSHOT = _lxc.LXC_CLONE_SNAPSHOT
-
-# create: create flags
-LXC_CREATE_QUIET = _lxc.LXC_CREATE_QUIET
diff --git a/src/python-lxc/setup.py b/src/python-lxc/setup.py
deleted file mode 100644
index bf0d74a0c..000000000
--- a/src/python-lxc/setup.py
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/usr/bin/env python3
-#
-# python-lxc: Python bindings for LXC
-#
-# (C) Copyright Canonical Ltd. 2012
-#
-# Authors:
-# Stéphane Graber <stgraber at ubuntu.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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
-# USA
-
-import os
-import subprocess
-
-# Fix build when PIE is enabled (must run before setuptools import)
-for var in ("LDFLAGS", "CFLAGS"):
-    current = os.environ.get(var, None)
-    if not current:
-        continue
-
-    new = []
-    for flag in current.split(" "):
-        if flag.lower() in ("-pie", "-fpie"):
-            if "-fPIC" not in new:
-                new.append("-fPIC")
-            continue
-        new.append(flag)
-
-    os.environ[var] = " ".join(new)
-
-from setuptools import setup, Extension
-from setuptools.command.build_ext import build_ext as BuildExtCommand
-
-
-class LxcBuildExtCommand(BuildExtCommand):
-    user_options = BuildExtCommand.user_options + [
-        ('no-pkg-config', None,
-         "don't use pkg-config to detect include/library paths")
-    ]
-
-    def initialize_options(self):
-        super(LxcBuildExtCommand, self).initialize_options()
-        self.no_pkg_config = False
-
-    def build_extensions(self):
-        if not self.no_pkg_config:
-            pkg_config_executable = os.environ.get('PKG_CONFIG_EXECUTABLE',
-                                                   'pkg-config')
-
-            def get_pkg_config_var(name):
-                args = [pkg_config_executable, '--variable', name, 'lxc']
-                output = subprocess.check_output(args,
-                                                 universal_newlines=True)
-                return output.rstrip('\n')
-
-            try:
-                includedir = get_pkg_config_var('includedir')
-                libdir = get_pkg_config_var('libdir')
-
-                self.compiler.add_include_dir(includedir)
-                self.compiler.add_library_dir(libdir)
-
-            except subprocess.CalledProcessError:
-                pass
-
-        super(LxcBuildExtCommand, self).build_extensions()
-
-
-setup(name='lxc',
-      version='0.1',
-      description='LXC',
-      packages=['lxc'],
-      package_dir={'lxc': 'lxc'},
-      ext_modules=[Extension('_lxc', sources=['lxc.c'], libraries=['lxc'])],
-      cmdclass={'build_ext': LxcBuildExtCommand},
-      )


More information about the lxc-devel mailing list