Skip to content

Commit

Permalink
Merge pull request #1950 from brauner/2017-11-27/criu_fixes
Browse files Browse the repository at this point in the history
bugfixes
  • Loading branch information
hallyn committed Dec 9, 2017
2 parents f6812e7 + 1c7222c commit be459e9
Show file tree
Hide file tree
Showing 21 changed files with 322 additions and 235 deletions.
8 changes: 4 additions & 4 deletions src/lxc/conf.c
Expand Up @@ -1191,7 +1191,7 @@ static int lxc_setup_rootfs(struct lxc_conf *conf)
return -1;
}

bdev = storage_init(conf, rootfs->path, rootfs->mount, rootfs->options);
bdev = storage_init(conf);
if (!bdev) {
ERROR("Failed to mount rootfs \"%s\" onto \"%s\" with options \"%s\".",
rootfs->path, rootfs->mount,
Expand Down Expand Up @@ -2725,22 +2725,22 @@ int chown_mapped_root_exec_wrapper(void *args)
* root is privileged with respect to hostuid/hostgid X, allowing
* him to do the chown.
*/
int chown_mapped_root(char *path, struct lxc_conf *conf)
int chown_mapped_root(const char *path, struct lxc_conf *conf)
{
uid_t rootuid, rootgid;
unsigned long val;
int hostuid, hostgid, ret;
struct stat sb;
char map1[100], map2[100], map3[100], map4[100], map5[100];
char ugid[100];
char *args1[] = {"lxc-usernsexec",
const char *args1[] = {"lxc-usernsexec",
"-m", map1,
"-m", map2,
"-m", map3,
"-m", map5,
"--", "chown", ugid, path,
NULL};
char *args2[] = {"lxc-usernsexec",
const char *args2[] = {"lxc-usernsexec",
"-m", map1,
"-m", map2,
"-m", map3,
Expand Down
2 changes: 1 addition & 1 deletion src/lxc/conf.h
Expand Up @@ -410,7 +410,7 @@ extern int setup_resource_limits(struct lxc_list *limits, pid_t pid);
extern int find_unmapped_nsid(struct lxc_conf *conf, enum idtype idtype);
extern int mapped_hostid(unsigned id, struct lxc_conf *conf,
enum idtype idtype);
extern int chown_mapped_root(char *path, struct lxc_conf *conf);
extern int chown_mapped_root(const char *path, struct lxc_conf *conf);
extern int lxc_ttys_shift_ids(struct lxc_conf *c);
extern int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data,
const char *fn_name);
Expand Down
36 changes: 35 additions & 1 deletion src/lxc/confile.c
Expand Up @@ -1910,7 +1910,41 @@ static int set_config_includefiles(const char *key, const char *value,
static int set_config_rootfs_path(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data)
{
return set_config_path_item(&lxc_conf->rootfs.path, value);
int ret;
char *dup, *tmp;
const char *container_path;

if (lxc_config_value_empty(value)) {
free(lxc_conf->rootfs.path);
lxc_conf->rootfs.path = NULL;
return 0;
}

dup = strdup(value);
if (!dup)
return -1;

/* Split <storage type>:<container path> into <storage type> and
* <container path>. Set "rootfs.bdev_type" to <storage type> and
* "rootfs.path" to <container path>.
*/
tmp = strchr(dup, ':');
if (tmp) {
*tmp = '\0';
ret = set_config_path_item(&lxc_conf->rootfs.bdev_type, dup);
if (ret < 0) {
free(dup);
return -1;
}
tmp++;
container_path = tmp;
} else {
container_path = value;
}

ret = set_config_path_item(&lxc_conf->rootfs.path, container_path);
free(dup);
return ret;
}

static int set_config_rootfs_mount(const char *key, const char *value,
Expand Down
2 changes: 2 additions & 0 deletions src/lxc/criu.c
Expand Up @@ -564,6 +564,8 @@ static void exec_criu(struct criu_opts *opts)
switch (n->type) {
case LXC_NET_VETH:
veth = n->priv.veth_attr.pair;
if (veth[0] == '\0')
veth = n->priv.veth_attr.veth1;

if (n->link[0] != '\0') {
if (external_not_veth)
Expand Down

0 comments on commit be459e9

Please sign in to comment.