diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 7c722ccdc9..7bc2bab2c6 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -938,6 +938,7 @@ static int lxcContainerMountFSDev(virDomainDefPtr def, { int ret = -1; char *path = NULL; + int flags = def->idmap.nuidmap ? MS_BIND : MS_MOVE; VIR_DEBUG("Mount /dev/ stateDir=%s", stateDir); @@ -951,9 +952,10 @@ static int lxcContainerMountFSDev(virDomainDefPtr def, goto cleanup; } - VIR_DEBUG("Trying to move %s to /dev", path); + VIR_DEBUG("Trying to %s %s to /dev", def->idmap.nuidmap ? + "bind" : "move", path); - if (mount(path, "/dev", NULL, MS_MOVE, NULL) < 0) { + if (mount(path, "/dev", NULL, flags, NULL) < 0) { virReportSystemError(errno, _("Failed to mount %s on /dev"), path); @@ -972,6 +974,7 @@ static int lxcContainerMountFSDevPTS(virDomainDefPtr def, { int ret; char *path = NULL; + int flags = def->idmap.nuidmap ? MS_BIND : MS_MOVE; VIR_DEBUG("Mount /dev/pts stateDir=%s", stateDir); @@ -987,10 +990,10 @@ static int lxcContainerMountFSDevPTS(virDomainDefPtr def, goto cleanup; } - VIR_DEBUG("Trying to move %s to /dev/pts", path); + VIR_DEBUG("Trying to %s %s to /dev/pts", def->idmap.nuidmap ? + "bind" : "move", path); - if ((ret = mount(path, "/dev/pts", - NULL, MS_MOVE, NULL)) < 0) { + if ((ret = mount(path, "/dev/pts", NULL, flags, NULL)) < 0) { virReportSystemError(errno, _("Failed to mount %s on /dev/pts"), path);