]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
c/r: add checkpoint/restore support for macvlan interfaces
authorTycho Andersen <tycho.andersen@canonical.com>
Thu, 22 Sep 2016 23:13:42 +0000 (23:13 +0000)
committerTycho Andersen <tycho.andersen@canonical.com>
Mon, 24 Oct 2016 21:28:56 +0000 (21:28 +0000)
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
src/lxc/criu.c

index 84d420956d033e81c4a1f62fde8d7f881b041d2c..c998fe42c769ebf35e1dfb72b061483130bddbaf 100644 (file)
@@ -439,9 +439,6 @@ static void exec_criu(struct criu_opts *opts)
                        char eth[128], *veth;
                        struct lxc_netdev *n = it->elem;
 
-                       if (n->type != LXC_NET_VETH)
-                               continue;
-
                        if (n->name) {
                                if (strlen(n->name) >= sizeof(eth))
                                        goto err;
@@ -449,14 +446,42 @@ static void exec_criu(struct criu_opts *opts)
                        } else
                                sprintf(eth, "eth%d", netnr);
 
-                       veth = n->priv.veth_attr.pair;
+                       switch (n->type) {
+                       case LXC_NET_VETH:
+                               veth = n->priv.veth_attr.pair;
 
-                       if (n->link)
-                               ret = snprintf(buf, sizeof(buf), "veth[%s]:%s@%s", eth, veth, n->link);
-                       else
-                               ret = snprintf(buf, sizeof(buf), "veth[%s]:%s", eth, veth);
-                       if (ret < 0 || ret >= sizeof(buf))
+                               if (n->link)
+                                       ret = snprintf(buf, sizeof(buf), "veth[%s]:%s@%s", eth, veth, n->link);
+                               else
+                                       ret = snprintf(buf, sizeof(buf), "veth[%s]:%s", eth, veth);
+                               if (ret < 0 || ret >= sizeof(buf))
+                                       goto err;
+                               break;
+                       case LXC_NET_MACVLAN:
+                               if (n->name) {
+                                       if (strlen(n->name) >= sizeof(eth))
+                                               goto err;
+                                       strncpy(eth, n->name, sizeof(eth));
+                               } else
+                                       sprintf(eth, "eth%d", netnr);
+
+                               if (!n->link) {
+                                       ERROR("no host interface for macvlan %s\n", n->name);
+                                       goto err;
+                               }
+
+                               ret = snprintf(buf, sizeof(buf), "macvlan[%s]:%s", eth, n->link);
+                               if (ret < 0 || ret >= sizeof(buf))
+                                       goto err;
+                               break;
+                       case LXC_NET_NONE:
+                       case LXC_NET_EMPTY:
+                               break;
+                       default:
+                               /* we have screened for this earlier... */
+                               ERROR("unexpected network type %d\n", n->type);
                                goto err;
+                       }
 
                        DECLARE_ARG("--external");
                        DECLARE_ARG(buf);
@@ -616,9 +641,10 @@ static bool criu_ok(struct lxc_container *c, char **criu_version)
                case LXC_NET_VETH:
                case LXC_NET_NONE:
                case LXC_NET_EMPTY:
+               case LXC_NET_MACVLAN:
                        break;
                default:
-                       ERROR("Found network that is not VETH or NONE\n");
+                       ERROR("Found un-dumpable network: %s (%s)\n", lxc_net_type_to_str(n->type), n->name);
                        return false;
                }
        }