mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
Mount temporary devpts on /var/lib/libvirt/lxc/$NAME.devpts
Currently the lxc controller sets up the devpts instance on $rootfsdef->src, but this only works if $rootfsdef is using type=mount. To support type=block or type=file for the root filesystem, we must use /var/lib/libvirt/lxc/$NAME.devpts for the temporary devpts mount in the controller
This commit is contained in:
parent
05f664b12c
commit
7e1a7444c6
@ -627,15 +627,17 @@ static int lxcContainerMountProcFuse(virDomainDefPtr def ATTRIBUTE_UNUSED,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int lxcContainerMountFSDevPTS(virDomainFSDefPtr root)
|
static int lxcContainerMountFSDevPTS(virDomainDefPtr def,
|
||||||
|
const char *srcprefix)
|
||||||
{
|
{
|
||||||
char *devpts = NULL;
|
int ret;
|
||||||
int rc = -1;
|
char *path = NULL;
|
||||||
|
|
||||||
if (virAsprintf(&devpts, "/.oldroot%s/dev/pts", root->src) < 0) {
|
if ((ret = virAsprintf(&path,
|
||||||
virReportOOMError();
|
"%s/%s/%s.devpts",
|
||||||
goto cleanup;
|
srcprefix ? srcprefix : "", LXC_STATE_DIR,
|
||||||
}
|
def->name)) < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
if (virFileMakePath("/dev/pts") < 0) {
|
if (virFileMakePath("/dev/pts") < 0) {
|
||||||
virReportSystemError(errno, "%s",
|
virReportSystemError(errno, "%s",
|
||||||
@ -643,19 +645,20 @@ static int lxcContainerMountFSDevPTS(virDomainFSDefPtr root)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_DEBUG("Trying to move %s to %s", devpts, "/dev/pts");
|
VIR_DEBUG("Trying to move %s to /dev/pts", path);
|
||||||
if ((rc = mount(devpts, "/dev/pts", NULL, MS_MOVE, NULL)) < 0) {
|
|
||||||
virReportSystemError(errno, "%s",
|
if ((ret = mount(path, "/dev/pts",
|
||||||
_("Failed to mount /dev/pts in container"));
|
NULL, MS_MOVE, NULL)) < 0) {
|
||||||
|
virReportSystemError(errno,
|
||||||
|
_("Failed to mount %s on /dev/pts"),
|
||||||
|
path);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = 0;
|
cleanup:
|
||||||
|
VIR_FREE(path);
|
||||||
|
|
||||||
cleanup:
|
return ret;
|
||||||
VIR_FREE(devpts);
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lxcContainerPopulateDevices(char **ttyPaths, size_t nttyPaths)
|
static int lxcContainerPopulateDevices(char **ttyPaths, size_t nttyPaths)
|
||||||
@ -1961,7 +1964,7 @@ static int lxcContainerSetupPivotRoot(virDomainDefPtr vmDef,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* Mounts /dev/pts */
|
/* Mounts /dev/pts */
|
||||||
if (lxcContainerMountFSDevPTS(root) < 0)
|
if (lxcContainerMountFSDevPTS(vmDef, "/.oldroot") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* Populates device nodes in /dev/ */
|
/* Populates device nodes in /dev/ */
|
||||||
@ -2204,7 +2207,11 @@ static int lxcContainerChild(void *data)
|
|||||||
|
|
||||||
if (argv->nttyPaths) {
|
if (argv->nttyPaths) {
|
||||||
if (root) {
|
if (root) {
|
||||||
if (virAsprintf(&ttyPath, "%s%s", root->src, argv->ttyPaths[0]) < 0) {
|
const char *tty = argv->ttyPaths[0];
|
||||||
|
if (STRPREFIX(tty, "/dev/pts/"))
|
||||||
|
tty += strlen("/dev/pts/");
|
||||||
|
if (virAsprintf(&ttyPath, "%s/%s.devpts/%s",
|
||||||
|
LXC_STATE_DIR, vmDef->name, tty) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -1219,15 +1219,10 @@ virLXCControllerSetupDevPTS(virLXCControllerPtr ctrl)
|
|||||||
mount_options = virSecurityManagerGetMountOptions(ctrl->securityManager,
|
mount_options = virSecurityManagerGetMountOptions(ctrl->securityManager,
|
||||||
ctrl->def);
|
ctrl->def);
|
||||||
|
|
||||||
if (!virFileExists(root->src)) {
|
if (virAsprintf(&devpts, "%s/%s.devpts",
|
||||||
virReportSystemError(errno,
|
LXC_STATE_DIR, ctrl->def->name) < 0 ||
|
||||||
_("root source %s does not exist"),
|
virAsprintf(&ctrl->devptmx, "%s/%s.devpts/ptmx",
|
||||||
root->src);
|
LXC_STATE_DIR, ctrl->def->name) < 0) {
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virAsprintf(&devpts, "%s/dev/pts", root->src) < 0 ||
|
|
||||||
virAsprintf(&ctrl->devptmx, "%s/dev/pts/ptmx", root->src) < 0) {
|
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user