]> git.proxmox.com Git - mirror_lxc.git/commitdiff
pass on reboot flag and delete old veth on reboot
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 27 Jul 2015 05:33:08 +0000 (07:33 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Thu, 13 Aug 2015 20:24:05 +0000 (16:24 -0400)
When setting lxc.network.veth.pair to get a fixed interface
name the recreation of it after a reboot caused an EEXIST.
-) The reboot flag is now a three-state value. It's set to
1 to request a reboot, and 2 during a reboot until after
lxc_spawn where it is reset to 0.
-) If the reboot is set (!= 0) within instantiate_veth and
a fixed name is used, the interface is now deleted before
being recreated.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/conf.c
src/lxc/lxccontainer.c
src/lxc/start.c

index e6e2a4a2a5287cd7979005f9086f5800572e3572..309ceea4068f444655c7adcc327d8781897f1125 100644 (file)
@@ -2611,9 +2611,11 @@ static int instantiate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
        char veth2buf[IFNAMSIZ], *veth2;
        int err;
 
-       if (netdev->priv.veth_attr.pair)
+       if (netdev->priv.veth_attr.pair) {
                veth1 = netdev->priv.veth_attr.pair;
-       else {
+               if (handler->conf->reboot)
+                       lxc_netdev_delete_by_name(veth1);
+       } else {
                err = snprintf(veth1buf, sizeof(veth1buf), "vethXXXXXX");
                if (err >= sizeof(veth1buf)) { /* can't *really* happen, but... */
                        ERROR("veth1 name too long");
index 1c103e8283e755b7a81756b0a42dabb7c9aa618a..223e78e096bd4813cdd13889e8aae9ea48a1cce7 100644 (file)
@@ -760,9 +760,9 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
                pid_fp = NULL;
        }
 
-reboot:
        conf->reboot = 0;
 
+reboot:
        if (lxc_check_inherited(conf, daemonize, -1)) {
                ERROR("Inherited fds found");
                ret = 1;
@@ -772,9 +772,9 @@ reboot:
        ret = lxc_start(c->name, argv, conf, c->config_path, daemonize);
        c->error_num = ret;
 
-       if (conf->reboot) {
+       if (conf->reboot == 1) {
                INFO("container requested reboot");
-               conf->reboot = 0;
+               conf->reboot = 2;
                goto reboot;
        }
 
index 6eded6155941e2a5c41ea1de4c58e2d62149a503..2fc026ef3e57324ece11d8004074f3e93d1ce94d 100644 (file)
@@ -1173,6 +1173,8 @@ int __lxc_start(const char *name, struct lxc_conf *conf,
                goto out_detach_blockdev;
        }
 
+       handler->conf->reboot = 0;
+
        netnsfd = get_netns_fd(handler->pid);
 
        err = lxc_poll(name, handler);