From: Christian Brauner Date: Wed, 20 Oct 2021 12:48:41 +0000 (+0200) Subject: criu: support restoring containers with pre-created veth devices X-Git-Tag: lxc-5.0.0~68^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4004%2Fhead;p=thirdparty%2Flxc.git criu: support restoring containers with pre-created veth devices 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 --- diff --git a/src/lxc/criu.c b/src/lxc/criu.c index b7966cc7d..eb4b14c1c 100644 --- a/src/lxc/criu.c +++ b/src/lxc/criu.c @@ -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: