}
#endif
-static int lxcContainerMountFSDevPTS(virDomainFSDefPtr root)
+static int lxcContainerMountFSDevPTS(virDomainDefPtr def,
+ const char *srcprefix)
{
- char *devpts = NULL;
- int rc = -1;
+ int ret;
+ char *path = NULL;
- if (virAsprintf(&devpts, "/.oldroot%s/dev/pts", root->src) < 0) {
- virReportOOMError();
- goto cleanup;
- }
+ if ((ret = virAsprintf(&path,
+ "%s/%s/%s.devpts",
+ srcprefix ? srcprefix : "", LXC_STATE_DIR,
+ def->name)) < 0)
+ return ret;
if (virFileMakePath("/dev/pts") < 0) {
virReportSystemError(errno, "%s",
goto cleanup;
}
- VIR_DEBUG("Trying to move %s to %s", devpts, "/dev/pts");
- if ((rc = mount(devpts, "/dev/pts", NULL, MS_MOVE, NULL)) < 0) {
- virReportSystemError(errno, "%s",
- _("Failed to mount /dev/pts in container"));
+ VIR_DEBUG("Trying to move %s to /dev/pts", path);
+
+ if ((ret = mount(path, "/dev/pts",
+ NULL, MS_MOVE, NULL)) < 0) {
+ virReportSystemError(errno,
+ _("Failed to mount %s on /dev/pts"),
+ path);
goto cleanup;
}
- rc = 0;
-
- cleanup:
- VIR_FREE(devpts);
+cleanup:
+ VIR_FREE(path);
- return rc;
+ return ret;
}
static int lxcContainerPopulateDevices(char **ttyPaths, size_t nttyPaths)
goto cleanup;
/* Mounts /dev/pts */
- if (lxcContainerMountFSDevPTS(root) < 0)
+ if (lxcContainerMountFSDevPTS(vmDef, "/.oldroot") < 0)
goto cleanup;
/* Populates device nodes in /dev/ */
if (argv->nttyPaths) {
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();
goto cleanup;
}
mount_options = virSecurityManagerGetMountOptions(ctrl->securityManager,
ctrl->def);
- if (!virFileExists(root->src)) {
- virReportSystemError(errno,
- _("root source %s does not exist"),
- root->src);
- goto cleanup;
- }
-
- if (virAsprintf(&devpts, "%s/dev/pts", root->src) < 0 ||
- virAsprintf(&ctrl->devptmx, "%s/dev/pts/ptmx", root->src) < 0) {
+ if (virAsprintf(&devpts, "%s/%s.devpts",
+ LXC_STATE_DIR, ctrl->def->name) < 0 ||
+ virAsprintf(&ctrl->devptmx, "%s/%s.devpts/ptmx",
+ LXC_STATE_DIR, ctrl->def->name) < 0) {
virReportOOMError();
goto cleanup;
}