mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-26 03:32:44 +00:00
cgroups: fix the recently broken setting of clone_children
Several places think that the current cgroup will be NULL rather than "/" when we're in the root cgroup. Fix that. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
2c495ae35a
commit
c9cbb9e514
@ -606,8 +606,7 @@ static int create_lxcgroups(const char *lxcgroup)
|
|||||||
* TODO - handle case where lxcgroup has subdirs? (i.e. build/l1)
|
* TODO - handle case where lxcgroup has subdirs? (i.e. build/l1)
|
||||||
* We probably only want to support that for /users/joe
|
* We probably only want to support that for /users/joe
|
||||||
*/
|
*/
|
||||||
ret = snprintf(path, MAXPATHLEN, "%s/%s",
|
ret = snprintf(path, MAXPATHLEN, "%s/%s", mntent_r.mnt_dir, lxcgroup);
|
||||||
mntent_r.mnt_dir, lxcgroup ? lxcgroup : "lxc");
|
|
||||||
if (ret < 0 || ret >= MAXPATHLEN)
|
if (ret < 0 || ret >= MAXPATHLEN)
|
||||||
goto fail;
|
goto fail;
|
||||||
if (access(path, F_OK)) {
|
if (access(path, F_OK)) {
|
||||||
@ -663,6 +662,8 @@ char *lxc_cgroup_path_create(const char *lxcgroup, const char *name)
|
|||||||
|
|
||||||
char buf[LARGE_MAXPATHLEN] = {0};
|
char buf[LARGE_MAXPATHLEN] = {0};
|
||||||
|
|
||||||
|
if (!lxcgroup || strlen(lxcgroup) == 0 || strcmp(lxcgroup, "/") == 0)
|
||||||
|
lxcgroup = "lxc";
|
||||||
if (!allcgroups)
|
if (!allcgroups)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -702,12 +703,12 @@ again:
|
|||||||
|
|
||||||
/* find unused mnt_dir + lxcgroup + name + -$i */
|
/* find unused mnt_dir + lxcgroup + name + -$i */
|
||||||
ret = snprintf(path, MAXPATHLEN, "%s/%s/%s%s", mntent_r.mnt_dir,
|
ret = snprintf(path, MAXPATHLEN, "%s/%s/%s%s", mntent_r.mnt_dir,
|
||||||
lxcgroup ? lxcgroup : "lxc", name, tail);
|
lxcgroup, name, tail);
|
||||||
if (ret < 0 || ret >= MAXPATHLEN)
|
if (ret < 0 || ret >= MAXPATHLEN)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
INFO("lxcgroup %s name %s tail %s, makes path .%s.",
|
INFO("lxcgroup %s name %s tail %s, makes path .%s.",
|
||||||
lxcgroup ? lxcgroup : "lxc", name, tail, path);
|
lxcgroup, name, tail, path);
|
||||||
|
|
||||||
if (access(path, F_OK) == 0) goto next;
|
if (access(path, F_OK) == 0) goto next;
|
||||||
|
|
||||||
@ -721,8 +722,7 @@ again:
|
|||||||
endmntent(file);
|
endmntent(file);
|
||||||
|
|
||||||
// print out the cgpath part
|
// print out the cgpath part
|
||||||
ret = snprintf(path, MAXPATHLEN, "%s/%s%s",
|
ret = snprintf(path, MAXPATHLEN, "%s/%s%s", lxcgroup, name, tail);
|
||||||
lxcgroup ? lxcgroup : "lxc", name, tail);
|
|
||||||
if (ret < 0 || ret >= MAXPATHLEN) // can't happen
|
if (ret < 0 || ret >= MAXPATHLEN) // can't happen
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user