]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
criu: support restoring containers with pre-created veth devices 4004/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 20 Oct 2021 12:48:41 +0000 (14:48 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 20 Oct 2021 12:52:18 +0000 (14:52 +0200)
We did th CRIU and kernel work but for some reason we never did push the
LXC work.

Link: https://github.com/checkpoint-restore/criu/commit/cdb0d427020f0531f5a35146513c3a36b6eece11
      commit cdb0d427020f ("net: allow restoring of precreated veth devices")
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/criu.c

index b7966cc7d7d1e0b7e9fa9afd399b4978e0edf180..eb4b14c1ceff0b874ddc2d9107cd6f8d815c740c 100644 (file)
@@ -45,6 +45,7 @@
 
 #define CRIU_IN_FLIGHT_SUPPORT "2.4"
 #define CRIU_EXTERNAL_NOT_VETH "2.8"
+#define CRIU_EXTERNAL_NETDEV   "3.15"
 
 lxc_log_define(criu, lxc);
 
@@ -550,8 +551,22 @@ static int exec_criu(struct cgroup_ops *cgroup_ops, struct lxc_conf *conf,
 
                                TRACE("Added macvlan device entry %s", buf);
 
+                               break;
+                       case LXC_NET_PHYS:
+                               if (cmp_version(opts->criu_version, CRIU_EXTERNAL_NETDEV) < 0)
+                                       return syserror_set(-EOPNOTSUPP, "Restoring physical network devices not supported");
+
+                               if (is_empty_string(netdev->link))
+                                       return syserror_set(-EINVAL, "Specifying link is required");
+
+                               ret = strnprintf(buf, sizeof(buf), "netdev[%s]:%s", eth, netdev->link);
+                               if (ret < 0)
+                                       return syserror_set(-EIO, "Failed to append phys device name");
+
+                               TRACE("Added phys device entry %s", buf);
                                break;
                        case LXC_NET_NONE:
+                               __fallthrough;
                        case LXC_NET_EMPTY:
                                break;
                        default:
@@ -825,6 +840,7 @@ 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_PHYS:
                case LXC_NET_MACVLAN:
                        break;
                default: