提交 c13a2c28 编写于 作者: D Daniel P. Berrange

Ensure that /dev exists in the container root filesystem

If booting a container with a root FS that isn't the host's
root, we must ensure that the /dev mount point exists.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 63ba687f
...@@ -868,7 +868,7 @@ static int lxcContainerMountProcFuse(virDomainDefPtr def ATTRIBUTE_UNUSED, ...@@ -868,7 +868,7 @@ static int lxcContainerMountProcFuse(virDomainDefPtr def ATTRIBUTE_UNUSED,
static int lxcContainerMountFSDev(virDomainDefPtr def, static int lxcContainerMountFSDev(virDomainDefPtr def,
const char *stateDir) const char *stateDir)
{ {
int ret; int ret = -1;
char *path = NULL; char *path = NULL;
VIR_DEBUG("Mount /dev/ stateDir=%s", stateDir); VIR_DEBUG("Mount /dev/ stateDir=%s", stateDir);
...@@ -877,14 +877,24 @@ static int lxcContainerMountFSDev(virDomainDefPtr def, ...@@ -877,14 +877,24 @@ static int lxcContainerMountFSDev(virDomainDefPtr def,
stateDir, def->name)) < 0) stateDir, def->name)) < 0)
return ret; return ret;
VIR_DEBUG("Tring to move %s to /dev", path); if (virFileMakePath("/dev") < 0) {
virReportSystemError(errno, "%s",
_("Cannot create /dev"));
goto cleanup;
}
VIR_DEBUG("Trying to move %s to /dev", path);
if ((ret = mount(path, "/dev", NULL, MS_MOVE, NULL)) < 0) { if (mount(path, "/dev", NULL, MS_MOVE, NULL) < 0) {
virReportSystemError(errno, virReportSystemError(errno,
_("Failed to mount %s on /dev"), _("Failed to mount %s on /dev"),
path); path);
goto cleanup;
} }
ret = 0;
cleanup:
VIR_FREE(path); VIR_FREE(path);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册