mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
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: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
63ba687f2b
commit
c13a2c282b
@ -868,7 +868,7 @@ static int lxcContainerMountProcFuse(virDomainDefPtr def ATTRIBUTE_UNUSED,
|
||||
static int lxcContainerMountFSDev(virDomainDefPtr def,
|
||||
const char *stateDir)
|
||||
{
|
||||
int ret;
|
||||
int ret = -1;
|
||||
char *path = NULL;
|
||||
|
||||
VIR_DEBUG("Mount /dev/ stateDir=%s", stateDir);
|
||||
@ -877,14 +877,24 @@ static int lxcContainerMountFSDev(virDomainDefPtr def,
|
||||
stateDir, def->name)) < 0)
|
||||
return ret;
|
||||
|
||||
VIR_DEBUG("Tring to move %s to /dev", path);
|
||||
if (virFileMakePath("/dev") < 0) {
|
||||
virReportSystemError(errno, "%s",
|
||||
_("Cannot create /dev"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ((ret = mount(path, "/dev", NULL, MS_MOVE, NULL)) < 0) {
|
||||
VIR_DEBUG("Trying to move %s to /dev", path);
|
||||
|
||||
if (mount(path, "/dev", NULL, MS_MOVE, NULL) < 0) {
|
||||
virReportSystemError(errno,
|
||||
_("Failed to mount %s on /dev"),
|
||||
path);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(path);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user