Closed rajil closed 4 years ago
Could be that your host isn't using the abstract unix socket at all, causing the connection error.
Try removing the @
from the connect side of the proxy device.
I modified the devices to look like so,
devices:
X0:
bind: container
connect: unix:/tmp/.X11-unix/X0
listen: unix:@/tmp/.X11-unix/X0
type: proxy
I am still get similar error in /var/snap/lxd/common/lxd/logs/mycontainer/proxy.X0.log when issuing glxinfo -B in the container,
Warning: Error while reading data: read unix @->/tmp/.X11-unix/X0: EOF
That's odd, the error message should have changed.
The error could also be coming from the fact that you're having the proxy connect to your X server as root rather than as your user, on most systems, this gets immediately rejected.
To get around that, you need to set security.uid
and security.gid
on your proxy device to match the uid and gid of the user that's running the graphical session on your system.
The non-root user on the host with the X session has UID of 1001 and GID of 100. Thus i modified the devices as follows,
devices:
X0:
bind: container
connect: unix:/tmp/.X11-unix/X0
listen: unix:@/tmp/.X11-unix/X0
security.gid: "100"
security.uid: "1001"
type: proxy
I still get the same error when running glxinfo like so,
lxc exec mycontainer -- sudo -u ubuntu glxinfo -B
Also, tried it with abstract socket, connect: unix:@/tmp/.X11-unix/X0
. Made no difference to the error, except '@' got added before /tmp.
Warning: Error while reading data: read unix @->@/tmp/.X11-unix/X0: EOF
Can you run strace -fF -p PID
where PID is the PID of the forkproxy
process?
Then try running something that uses it. That may give a clearer error as to what's going on.
Following is the strace output,
# strace -fF -p 4127522
strace: deprecated option -F ignored
strace: Process 4127522 attached with 8 threads
[pid 4128511] futex(0xc00028d9c8, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 4127533] futex(0xc0000ee4c8, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 4127532] futex(0x2495878, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 4127531] epoll_wait(7, <unfinished ...>
[pid 4127530] epoll_pwait(5, <unfinished ...>
[pid 4127529] futex(0x24959e0, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 4127528] restart_syscall(<... resuming interrupted read ...> <unfinished ...>
[pid 4127522] futex(0x1f4da08, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 4127531] <... epoll_wait resumed>[{EPOLLIN, {u32=4, u64=4}}], 10, -1) = 1
[pid 4127530] <... epoll_pwait resumed>[{EPOLLIN, {u32=2565914376, u64=139966960156424}}], 128, -1, NULL, 3) = 1
[pid 4127531] futex(0x1f4cd70, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid 4127530] epoll_pwait(5, <unfinished ...>
[pid 4127531] <... futex resumed>) = 1
[pid 4127528] <... restart_syscall resumed>) = 0
[pid 4127531] accept4(6, <unfinished ...>
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4127531] <... accept4 resumed>{sa_family=AF_UNIX}, [112->2], SOCK_CLOEXEC|SOCK_NONBLOCK) = 8
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4127531] epoll_ctl(5, EPOLL_CTL_ADD, 8, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=2565914168, u64=139966960156216}} <unfinished ...>
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4127531] <... epoll_ctl resumed>) = 0
[pid 4127530] <... epoll_pwait resumed>[{EPOLLIN|EPOLLOUT, {u32=2565914168, u64=139966960156216}}], 128, -1, NULL, 3) = 1
[pid 4127531] getsockname(8, <unfinished ...>
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4127531] <... getsockname resumed>{sa_family=AF_UNIX, sun_path=@"/tmp/.X11-unix/X0"}, [112->20]) = 0
[pid 4127530] epoll_pwait(5, <unfinished ...>
[pid 4127531] socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0 <unfinished ...>
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4127531] <... socket resumed>) = 9
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4127531] setsockopt(9, SOL_SOCKET, SO_BROADCAST, [1], 4 <unfinished ...>
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4127531] <... setsockopt resumed>) = 0
[pid 4127531] connect(9, {sa_family=AF_UNIX, sun_path=@"/tmp/.X11-unix/X0"}, 20 <unfinished ...>
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4127531] <... connect resumed>) = 0
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4127531] epoll_ctl(5, EPOLL_CTL_ADD, 9, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=2565913960, u64=139966960156008}} <unfinished ...>
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4127531] <... epoll_ctl resumed>) = 0
[pid 4127530] <... epoll_pwait resumed>[{EPOLLOUT, {u32=2565913960, u64=139966960156008}}], 128, -1, NULL, 3) = 1
[pid 4127531] getsockname(9, <unfinished ...>
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4127531] <... getsockname resumed>{sa_family=AF_UNIX}, [112->2]) = 0
[pid 4127530] epoll_pwait(5, <unfinished ...>
[pid 4127531] getpeername(9, <unfinished ...>
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4127531] <... getpeername resumed>{sa_family=AF_UNIX, sun_path=@"/tmp/.X11-unix/X0"}, [112->20]) = 0
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4127531] futex(0xc0000ee4c8, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4127533] <... futex resumed>) = 0
[pid 4127531] <... futex resumed>) = 1
[pid 4127533] nanosleep({tv_sec=0, tv_nsec=3000}, <unfinished ...>
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4127533] <... nanosleep resumed>NULL) = 0
[pid 4127531] epoll_wait(7, <unfinished ...>
[pid 4127533] futex(0xc00028d9c8, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4128511] <... futex resumed>) = 0
[pid 4127533] <... futex resumed>) = 1
[pid 4128511] futex(0xc00028d9c8, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4128511] <... futex resumed>) = -1 EAGAIN (Resource temporarily unavailable)
[pid 4127533] futex(0xc00028d9c8, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid 4128511] nanosleep({tv_sec=0, tv_nsec=3000}, <unfinished ...>
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4128511] <... nanosleep resumed>NULL) = 0
[pid 4127533] <... futex resumed>) = 0
[pid 4128511] mmap(NULL, 134217728, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0 <unfinished ...>
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4128511] <... mmap resumed>) = 0x7f4c7c000000
[pid 4127533] recvmsg(9, <unfinished ...>
[pid 4128511] munmap(0x7f4c80000000, 67108864 <unfinished ...>
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4128511] <... munmap resumed>) = 0
[pid 4127533] <... recvmsg resumed>{msg_namelen=112}, 0) = -1 EAGAIN (Resource temporarily unavailable)
[pid 4128511] mprotect(0x7f4c7c000000, 135168, PROT_READ|PROT_WRITE <unfinished ...>
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4128511] <... mprotect resumed>) = 0
[pid 4127533] futex(0xc0000ee4c8, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 4128511] rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], <unfinished ...>
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4128511] <... rt_sigprocmask resumed>[], 8) = 0
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4128511] mmap(NULL, 8392704, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0 <unfinished ...>
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4128511] <... mmap resumed>) = 0x7f4c90110000
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4128511] mprotect(0x7f4c90110000, 4096, PROT_NONE <unfinished ...>
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4128511] <... mprotect resumed>) = 0
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4128511] clone(child_stack=0x7f4c9090fcb0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID <unfinished ...>
[pid 4127528] <... nanosleep resumed>NULL) = 0
strace: Process 474225 attached
[pid 4128511] <... clone resumed>, parent_tid=[474225], tls=0x7f4c90910700, child_tidptr=0x7f4c909109d0) = 474225
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 474225] set_robust_list(0x7f4c909109e0, 24 <unfinished ...>
[pid 4128511] rt_sigprocmask(SIG_SETMASK, [], <unfinished ...>
[pid 474225] <... set_robust_list resumed>) = 0
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 474225] sigaltstack(NULL, <unfinished ...>
[pid 4128511] <... rt_sigprocmask resumed>NULL, 8) = 0
[pid 474225] <... sigaltstack resumed>{ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=0}) = 0
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 474225] sigaltstack({ss_sp=0xc000338000, ss_flags=0, ss_size=32768}, <unfinished ...>
[pid 4128511] recvmsg(8, <unfinished ...>
[pid 474225] <... sigaltstack resumed>NULL) = 0
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 474225] rt_sigprocmask(SIG_SETMASK, [], <unfinished ...>
[pid 4128511] <... recvmsg resumed>{msg_name=0xc00031eac8, msg_namelen=112->0, msg_iov=[{iov_base="l\0\v\0\0\0\0\0\0\0\0\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 12
[pid 474225] <... rt_sigprocmask resumed>NULL, 8) = 0
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 474225] gettid( <unfinished ...>
[pid 4128511] sendmsg(9, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="l\0\v\0\0\0\0\0\0\0\0\0", iov_len=12}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0 <unfinished ...>
[pid 474225] <... gettid resumed>) = 474225
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 474225] futex(0xc000334148, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 4128511] <... sendmsg resumed>) = 12
[pid 4127530] <... epoll_pwait resumed>[{EPOLLOUT, {u32=2565913960, u64=139966960156008}}], 128, -1, NULL, 3) = 1
[pid 4128511] recvmsg(8, <unfinished ...>
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4128511] <... recvmsg resumed>{msg_namelen=112}, 0) = -1 EAGAIN (Resource temporarily unavailable)
[pid 4127530] epoll_pwait(5, <unfinished ...>
[pid 4128511] futex(0xc00028d9c8, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4127530] <... epoll_pwait resumed>[{EPOLLIN|EPOLLOUT|EPOLLHUP|EPOLLRDHUP, {u32=2565913960, u64=139966960156008}}], 128, -1, NULL, 3) = 1
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4127530] recvmsg(9, {msg_name={sa_family=AF_UNIX, sun_path=@"/tmp/.X11-unix/X0"}, msg_namelen=112->20, msg_iov=[{iov_base="\0\26\v\0\0\0\6\0No protocol specified\n\0\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4127530] sendmsg(8, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\0\26\v\0\0\0\6\0No protocol specified\n\0\0", iov_len=32}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0 <unfinished ...>
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4127530] <... sendmsg resumed>) = 32
[pid 4127530] recvmsg(9, <unfinished ...>
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4127530] <... recvmsg resumed>{msg_name=0xc000322ac8, msg_namelen=112->0, msg_iov=[{iov_base="", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 0
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4127530] futex(0xc00028d9c8, FUTEX_WAKE_PRIVATE, 1) = 1
[pid 4128511] <... futex resumed>) = 0
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4127530] write(1, "Warning: Error while reading dat"..., 72 <unfinished ...>
[pid 4128511] epoll_pwait(5, <unfinished ...>
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4128511] <... epoll_pwait resumed>[{EPOLLIN|EPOLLOUT|EPOLLHUP|EPOLLRDHUP, {u32=2565914168, u64=139966960156216}}], 128, 0, NULL, 0) = 1
[pid 4127530] <... write resumed>) = 72
[pid 4128511] futex(0xc000334148, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 474225] <... futex resumed>) = 0
[pid 4128511] <... futex resumed>) = 1
[pid 4127530] epoll_ctl(5, EPOLL_CTL_DEL, 9, 0xc000316d9c <unfinished ...>
[pid 474225] epoll_pwait(5, <unfinished ...>
[pid 4128511] recvmsg(8, <unfinished ...>
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 474225] <... epoll_pwait resumed>[], 128, 0, NULL, 0) = 0
[pid 4128511] <... recvmsg resumed>{msg_name=0xc00031eac8, msg_namelen=112->0, msg_iov=[{iov_base="", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 0
[pid 4127530] <... epoll_ctl resumed>) = 0
[pid 474225] epoll_pwait(5, <unfinished ...>
[pid 4128511] futex(0xc00028d9c8, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4127530] close(9 <unfinished ...>
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4127530] <... close resumed>) = 0
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4127530] epoll_ctl(5, EPOLL_CTL_DEL, 8, 0xc000316d9c <unfinished ...>
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4127530] <... epoll_ctl resumed>) = 0
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4127530] close(8 <unfinished ...>
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4127530] <... close resumed>) = 0
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4127530] futex(0xc00028d9c8, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, <unfinished ...>
[pid 4128511] <... futex resumed>) = 0
[pid 4127530] <... futex resumed>) = 1
[pid 4128511] nanosleep({tv_sec=0, tv_nsec=3000}, <unfinished ...>
[pid 4127528] <... nanosleep resumed>NULL) = 0
[pid 4128511] <... nanosleep resumed>NULL) = 0
[pid 4127530] futex(0xc0000bcbc8, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 4128511] futex(0xc00028d9c8, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 4127528] nanosleep({tv_sec=0, tv_nsec=20000}, NULL) = 0
[pid 4127528] futex(0x1f4cd70, FUTEX_WAIT_PRIVATE, 0, {tv_sec=60, tv_nsec=0}
So the above shows the No protocol specified
being transferred over the unix socket, suggesting that it is in fact connected to something.
Do you get the same result running xvinfo
?
Yes, i get the same result with xvinfo.
Can you look at your xserver log see if maybe something is logged there?
You can also try running "xhost +" on your host, that should eliminate any potential authentication problems
Ok, we are getting somewhere with xhost +. After issuing that glxinfo is working,
$ lxc exec mycontainer -- sudo -u ubuntu glxinfo -B|grep -i render
direct rendering: Yes
OpenGL renderer string: GeForce GT 1030/PCIe/SSE2
How i still get a warning in /var/snap/lxd/common/lxd/logs/mycontainer/proxy.X0.log when the above command is issued,
Warning: Error while sending data: read unix @/tmp/.X11-unix/X0->@: EOF
I did an strace on the forkproxy pid and the results are here.
Yeah, that's probably fine, it's really just a warning that the connection got closed partway through a read, it's not a problem by itself and I've certainly seen it happen before. X is a bit of an odd protocol as it's not really just the single socket, a number of other files are also passed through using scm rights packets, that's especially true for GL workloads, so if things work, and looks like they do, I wouldn't worry about the connection getting disconnected somewhat abruptly by one of the two sides.
Closing as it sounds like the issue was around X authentication and not something to do with LXD.
Most distros allow X connections by the right user/group but it looks like your system may be entirely dependent on Xauthority instead which would explain why you had to use the xhost +
trick.
An alternative would probably be for you to transfer the Xauthority token/file into the container and set the XAUTHORITY env variable accordingly, though just keeping using xhost is fine too, so long as your X server isn't exposed to the network (I don't know of any distro which still does that).
Required information
Issue description
I am trying to run a gui app in the container. Unfortunately, the abstract proxy is giving an error. The host is running Archlinux and the container is Ubuntu-18.04.
My container definition is as follows:
The container gives an error when trying to use X,
Also, the container proxy log shows an error,
The X0 file does exist on the host,