On 10/12/2011 08:31 PM, Serge E. Hallyn wrote:
glibc's grantpt and ptsname cannot be used on a fd for a pty not in /dev/pts. The lxc controller tries to do just that. So if you try to start a container on a system where /dev/pts/0 is not available, it will fail. You can make this happen by opening a terminal on /dev/pts/0, and doing 'sleep 2h& disown; exit'. To fix this, I call the virFileOpenTtyAt() from a forked task in a new mount ns, and first mount the container's /dev/pts onto /dev/pts. (Then the opened fd must be passed back to the lxc driver). Another solution would be to just do it all by hand without grantpt and ptsname. Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/863629 Signed-off-by: Serge Hallyn<serge.hallyn@xxxxxxxxxxxxx> --- src/lxc/lxc_controller.c | 117 ++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 112 insertions(+), 5 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 51488e7..1a56e0c 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -780,6 +780,113 @@ static int lxcSetPersonality(virDomainDefPtr def) # define MS_SLAVE (1<<19) #endif +static int send_pty(int sock, int *pty) +{ + struct iovec vector; + struct msghdr msg; + struct cmsghdr * cmsg; + int ret; +
Yuck. Why not just use gnulib's sendfd/recvfd interfaces, and greatly shrink the size of this patch? We're already using those functions elsewhere, for much more compact fd passing.
+ if (VIR_ALLOC_N(*path, PATH_MAX)< 0) { + virReportSystemError(errno, "%s", + _("Failed to allocate space for ptyname")); + return -ENOMEM; + } + //snprintf(*path, PATH_MAX, "%s/0", devpts);
Also, looks like you left some debug stuff behind. Have you filed a bug against glibc's grantpt? -- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list