]> git.proxmox.com Git - mirror_lxc.git/blobdiff - src/lxc/criu.c
Merge pull request #1539 from brauner/2017-05-06/fix_abstract_unix_sockets
[mirror_lxc.git] / src / lxc / criu.c
index 9523af3b41f8a88a59ef3d5b71f4fbbb54b3d1d6..9b0ccacb6af7a136603a3d4e569dd223e9e74e91 100644 (file)
@@ -21,7 +21,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #define _GNU_SOURCE
-#include <assert.h>
 #include <inttypes.h>
 #include <linux/limits.h>
 #include <sched.h>
@@ -58,6 +57,7 @@
 #define CRIU_GITID_PATCHLEVEL  0
 
 #define CRIU_IN_FLIGHT_SUPPORT "2.4"
+#define CRIU_EXTERNAL_NOT_VETH "2.8"
 
 lxc_log_define(lxc_criu, lxc);
 
@@ -329,13 +329,23 @@ static void exec_criu(struct criu_opts *opts)
                DECLARE_ARG(opts->user->action_script);
        }
 
-       mnts = write_mount_file(&opts->c->lxc_conf->mount_list);
+       mnts = make_anonymous_mount_file(&opts->c->lxc_conf->mount_list);
        if (!mnts)
                goto err;
 
        while (getmntent_r(mnts, &mntent, buf, sizeof(buf))) {
-               char *fmt, *key, *val;
+               char *fmt, *key, *val, *mntdata;
                char arg[2 * PATH_MAX + 2];
+               unsigned long flags;
+
+               if (parse_mntopts(mntent.mnt_opts, &flags, &mntdata) < 0)
+                       goto err;
+
+               free(mntdata);
+
+               /* only add --ext-mount-map for actual bind mounts */
+               if (!(flags & MS_BIND))
+                       continue;
 
                if (strcmp(opts->action, "dump") == 0) {
                        fmt = "/%s:%s";
@@ -482,7 +492,19 @@ static void exec_criu(struct criu_opts *opts)
 
                lxc_list_for_each(it, &opts->c->lxc_conf->network) {
                        char eth[128], *veth;
+                       char *fmt;
                        struct lxc_netdev *n = it->elem;
+                       bool external_not_veth;
+
+                       if (strcmp(opts->criu_version, CRIU_EXTERNAL_NOT_VETH) >= 0) {
+                               /* Since criu version 2.8 the usage of --veth-pair
+                                * has been deprecated:
+                                * git tag --contains f2037e6d3445fc400
+                                * v2.8 */
+                               external_not_veth = true;
+                       } else {
+                               external_not_veth = false;
+                       }
 
                        if (n->name) {
                                if (strlen(n->name) >= sizeof(eth))
@@ -498,10 +520,21 @@ static void exec_criu(struct criu_opts *opts)
                        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 (n->link) {
+                                       if (external_not_veth)
+                                               fmt = "veth[%s]:%s@%s";
+                                       else
+                                               fmt = "%s=%s@%s";
+
+                                       ret = snprintf(buf, sizeof(buf), fmt, eth, veth, n->link);
+                               } else {
+                                       if (external_not_veth)
+                                               fmt = "veth[%s]:%s";
+                                       else
+                                               fmt = "%s=%s";
+
+                                       ret = snprintf(buf, sizeof(buf), fmt, eth, veth);
+                               }
                                if (ret < 0 || ret >= sizeof(buf))
                                        goto err;
                                break;
@@ -524,7 +557,10 @@ static void exec_criu(struct criu_opts *opts)
                                goto err;
                        }
 
-                       DECLARE_ARG("--external");
+                       if (external_not_veth)
+                               DECLARE_ARG("--external");
+                       else
+                               DECLARE_ARG("--veth-pair");
                        DECLARE_ARG(buf);
                        netnr++;
                }