As of criu 1.5, the --veth-pair argument supports an additional parameter that
is the bridge name to attach to. This enables us to get rid of the goofy
action-script hack that passed bridge names as environment variables.

This patch is on top of the systemd/lxcfs mount rework patch, as we probably
want to wait to use 1.5 options until it has been out for a while and is in
distros.

Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com>
---
 src/lxc/Makefile.am     |  4 ----
 src/lxc/lxc-restore-net | 26 --------------------------
 src/lxc/lxccontainer.c  | 37 +------------------------------------
 3 files changed, 1 insertion(+), 66 deletions(-)
 delete mode 100755 src/lxc/lxc-restore-net

diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am
index 8b79c40..a56d504 100644
--- a/src/lxc/Makefile.am
+++ b/src/lxc/Makefile.am
@@ -164,7 +164,6 @@ bin_SCRIPTS = lxc-checkconfig
 
 EXTRA_DIST = \
        lxc-ls \
-       lxc-restore-net \
        lxc-top.lua
 
 if ENABLE_PYTHON
@@ -262,8 +261,5 @@ install-exec-local: install-soPROGRAMS
 install-exec-hook:
        chmod u+s $(DESTDIR)$(libexecdir)/lxc/lxc-user-nic
 
-install-data-local:
-       install -c -m 755 lxc-restore-net $(DESTDIR)$(datadir)/lxc
-
 uninstall-local:
        $(RM) $(DESTDIR)$(libdir)/liblxc.so*
diff --git a/src/lxc/lxc-restore-net b/src/lxc/lxc-restore-net
deleted file mode 100755
index 6ae3c19..0000000
--- a/src/lxc/lxc-restore-net
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-
-set -e
-
-i=0
-while true; do
-       eval "bridge=\$LXC_CRIU_BRIDGE$i"
-       eval "veth=\$LXC_CRIU_VETH$i"
-
-       if [ -z "$bridge" ] || [ -z "$veth" ]; then
-               exit 0
-       fi
-
-       if [ "$CRTOOLS_SCRIPT_ACTION" = "network-lock" ]; then
-               brctl delif $bridge $veth
-       fi
-
-       if [ "$CRTOOLS_SCRIPT_ACTION" = "network-unlock" ]; then
-               brctl addif $bridge $veth
-               ip link set dev $veth up
-       fi
-
-       i=$((i+1))
-done
-
-exit 1
diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index d759703..3f50fa6 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -3779,8 +3779,6 @@ static void exec_criu(struct criu_opts *opts)
        DECLARE_ARG("auto");
        DECLARE_ARG("--enable-external-sharing");
        DECLARE_ARG("--enable-external-masters");
-       DECLARE_ARG("--action-script");
-       DECLARE_ARG(DATADIR "/lxc/lxc-restore-net");
        DECLARE_ARG("-D");
        DECLARE_ARG(opts->directory);
        DECLARE_ARG("-o");
@@ -3832,7 +3830,7 @@ static void exec_criu(struct criu_opts *opts)
 
                        veth = n->priv.veth_attr.pair;
 
-                       ret = snprintf(buf, sizeof(buf), "%s=%s", eth, veth);
+                       ret = snprintf(buf, sizeof(buf), "%s=%s@%s", eth, veth, 
n->link);
                        if (ret < 0 || ret >= sizeof(buf))
                                goto err;
 
@@ -3844,39 +3842,6 @@ static void exec_criu(struct criu_opts *opts)
 
        argv[argc] = NULL;
 
-       netnr = 0;
-       lxc_list_for_each(it, &opts->c->lxc_conf->network) {
-               struct lxc_netdev *n = it->elem;
-               char veth[128];
-
-               /*
-                * Here, we set some parameters that lxc-restore-net
-                * will examine to figure out the right network to
-                * restore.
-                */
-               snprintf(buf, sizeof(buf), "LXC_CRIU_BRIDGE%d", netnr);
-               if (setenv(buf, n->link, 1))
-                       goto err;
-
-               if (strcmp("restore", opts->action) == 0)
-                       strncpy(veth, n->priv.veth_attr.pair, sizeof(veth));
-               else {
-                       char *tmp;
-                       ret = snprintf(buf, sizeof(buf), 
"lxc.network.%d.veth.pair", netnr);
-                       if (ret < 0 || ret >= sizeof(buf))
-                               goto err;
-                       tmp = lxcapi_get_running_config_item(opts->c, buf);
-                       strncpy(veth, tmp, sizeof(veth));
-                       free(tmp);
-               }
-
-               snprintf(buf, sizeof(buf), "LXC_CRIU_VETH%d", netnr);
-               if (setenv(buf, veth, 1))
-                       goto err;
-
-               netnr++;
-       }
-
 #undef DECLARE_ARG
 #undef RESIZE_ARGS
        execv(argv[0], argv);
-- 
2.1.4

_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to