- Package:
- lxc-templates
- Source:
- lxc-templates
- Description:
- Linux Containers userspace tools (templates)
- Submitter:
- Alex Mestiashvili
- Date:
- 2021-09-23 10:27:03 UTC
- Severity:
- wishlist
- Tags:
Steps to reproduce:
install lxc, create a container with debian template (backing store
doesn't matter in this case)
lxc-create -n deb2 -t debian -B zfs --zfsroot=ocz/lxc
lxc-console -n deb2 -l trace -o console_deb2.lxc.log
Connected to tty 1
Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a>
to enter Ctrl+a itself
Log file:
cat console_deb2.lxc.log
lxc-console 20180830074928.590 WARN lxc_confile -
confile.c:set_config_pivotdir:2262 - lxc.pivotdir is ignored. It will
soon become an error.
lxc-console 20180830074928.590 TRACE lxc_commands -
commands.c:lxc_cmd:290 - command get_init_pid tries to connect command
socket
lxc-console 20180830074928.590 TRACE lxc_commands -
commands.c:lxc_cmd_send:222 - Command "get_init_pid" connected to
command socket
lxc-console 20180830074928.590 TRACE lxc_commands -
commands.c:lxc_cmd_send:238 - Command "get_init_pid" requested data of
length 0
lxc-console 20180830074928.590 TRACE lxc_commands -
commands.c:lxc_cmd_rsp_recv:128 - Command "get_init_pid received response
lxc-console 20180830074928.590 DEBUG lxc_commands -
commands.c:lxc_cmd_rsp_recv:152 - command get_init_pid response data
length is 0
lxc-console 20180830074928.590 TRACE lxc_commands -
commands.c:lxc_cmd:290 - command get_cgroup tries to connect command socket
lxc-console 20180830074928.590 TRACE lxc_commands -
commands.c:lxc_cmd_send:222 - Command "get_cgroup" connected to command
socket
lxc-console 20180830074928.590 TRACE lxc_commands -
commands.c:lxc_cmd_send:238 - Command "get_cgroup" requested data of
length 8
lxc-console 20180830074928.591 TRACE lxc_commands -
commands.c:lxc_cmd_rsp_recv:128 - Command "get_cgroup received response
lxc-console 20180830074928.591 TRACE lxc_commands -
commands.c:lxc_cmd_get_cgroup_path:456 - command get_cgroup successful
for container "deb2"
lxc-console 20180830074928.591 TRACE lxc_commands -
commands.c:lxc_cmd:290 - command get_state tries to connect command socket
lxc-console 20180830074928.591 TRACE lxc_commands -
commands.c:lxc_cmd_send:222 - Command "get_state" connected to command
socket
lxc-console 20180830074928.591 TRACE lxc_commands -
commands.c:lxc_cmd_send:238 - Command "get_state" requested data of length 0
lxc-console 20180830074928.591 TRACE lxc_commands -
commands.c:lxc_cmd_rsp_recv:128 - Command "get_state received response
lxc-console 20180830074928.591 DEBUG lxc_commands -
commands.c:lxc_cmd_rsp_recv:152 - command get_state response data length
is 0
lxc-console 20180830074928.591 DEBUG lxc_commands -
commands.c:lxc_cmd_get_state:569 - Container "deb2" is in "RUNNING" state.
lxc-console 20180830074928.591 TRACE lxc_commands -
commands.c:lxc_cmd:290 - command console tries to connect command socket
lxc-console 20180830074928.591 TRACE lxc_commands -
commands.c:lxc_cmd_send:222 - Command "console" connected to command socket
lxc-console 20180830074928.591 TRACE lxc_commands -
commands.c:lxc_cmd_send:238 - Command "console" requested data of length 0
lxc-console 20180830074928.591 TRACE lxc_commands -
commands.c:lxc_cmd_rsp_recv:128 - Command "console received response
lxc-console 20180830074928.591 DEBUG lxc_commands -
commands.c:lxc_cmd_rsp_recv:152 - command console response data length is 0
lxc-console 20180830074928.591 INFO lxc_commands -
commands.c:lxc_cmd_console:719 - tty 1 allocated fd 5 sock 4.
lxc-console 20180830074928.591 INFO console -
console.c:lxc_console:696 - already group leader
lxc-console 20180830074928.591 DEBUG console -
console.c:lxc_console_sigwinch_init:151 - process 13995 created signal
fd 6 to handle SIGWINCH events
lxc-console 20180830074928.591 DEBUG console -
console.c:lxc_console_winsz:71 - set winsz dstfd:5 cols:211 rows:65
lxc-console 20180830074928.591 TRACE lxc_commands -
commands.c:lxc_cmd:290 - command console_winch tries to connect command
socket
lxc-console 20180830074928.591 TRACE lxc_commands -
commands.c:lxc_cmd_send:222 - Command "console_winch" connected to
command socket
lxc-console 20180830074928.591 TRACE lxc_commands -
commands.c:lxc_cmd_send:238 - Command "console_winch" requested data of
length 0
lxc-console 20180830074928.591 TRACE lxc_commands -
commands.c:lxc_cmd_rsp_recv:128 - Command "console_winch received response
lxc-console 20180830074928.591 DEBUG lxc_commands -
commands.c:lxc_cmd_rsp_recv:152 - command console_winch response data
length is 0
Ubuntu template works as expected:
lxc-console -n ubutest -l trace -o console_ubutest.lxc.log
Connected to tty 1
Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a>
to enter Ctrl+a itself
Ubuntu 16.04.5 LTS ubutest pts/0
ubutest login:
Hi, Le jeudi 30 août 2018 à 09:58:31+0200, Alex Mestiashvili a écrit : Why using -l, which tend to ruin the interface and hence compromise the readability of the output? On your paste I can't see a thing saying the console isn't working. I never met this issue myself, and I'm unable to reproduce it. As lxc moved to version 3, can you give it a try at some point and tell me if you are still having this issue? Cheers
Well, -l is for the logpriority, that's why it is there. Sorry if that was useless. I just gave it another try. And I think I narrowed down the issue with the template. When attaching to a newly created debian container (lxc-create -t debian) with lxc-attach -n <container> I can see that there is only 1 console and no ttys are spawned: root@deb2:/etc# ps -ef | grep agetty root 73 1 0 09:42 console 00:00:00 /sbin/agetty --noclear --keep-baud console 115200,38400,9600 vt220 While in an ubuntu template there are 1 console and 4 pts: ps -ef | grep agetty root 102 1 0 08:58 pts/0 00:00:00 /sbin/agetty --noclear --keep-baud pts/0 115200 38400 9600 vt220 root 103 1 0 08:58 console 00:00:00 /sbin/agetty --noclear --keep-baud console 115200 38400 9600 vt220 root 104 1 0 08:58 pts/3 00:00:00 /sbin/agetty --noclear --keep-baud pts/3 115200 38400 9600 vt220 root 105 1 0 08:58 pts/1 00:00:00 /sbin/agetty --noclear --keep-baud pts/1 115200 38400 9600 vt220 root 106 1 0 08:58 pts/2 00:00:00 /sbin/agetty --noclear --keep-baud pts/2 115200 38400 9600 vt220 So my initial bug report wasn't exactly correct. One can get login prompt on container created with debian template, but only by calling lxc-console -n <container> -t 0 This "-t 0" is not obvious and I can imagine some people don't know about it. lxc and lxc-console are totally ok. It's the debian template with systemd which is by default have a not optimal setup. No idea how to fix that, spent some time, but lost in systemd crosslinked docs. Thanks! Alex
Hi Alex, Le 11/01/2019 à 10:59, Alex Mestiashvili a écrit : I'm pretty sorry if I gave you the impression that it was useless. My intent was more to suggest that as this output lacks sufficient intel, you can get rid of it. :) With what version of lxc did you give it another try? This is interesting, but I'm surprised, I'm not meeting such an issue, my Debian containers work perfectly fine. Do you get any message? Can you use trace on lxc-create and log all of this in a file?
Le 11 janvier 2019 21:21:54 GMT+01:00, Alex Mestiashvili <amestia@rsh2.donotuse.de> a écrit : Is this issue occurring with root or unpriviledged containers ?
No problem at all. It's a buster installation with lxc 1:3.1.0-1: dpkg -l | perl -lanE '/lxc/ && say $F[1],"\t",$F[2]' liblxc1 1:3.1.0-1 lxc 1:3.1.0-1 lxc-templates 3.0.3-1 lxcfs 3.0.3-2 I've got another box with up-to-date debian buster installed. Installed lxc with apt-get install lxc (lxc 1:3.1.0-1, lxc-templates 3.0.3-1) created a new container with this command: lxc-create -t debian -n test1 after that started the container: lxc-start -dn test1 tried to lxc-console to the container: lxc-console -n test1 Connected to tty 1 Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a> to enter Ctrl+a itself Not getting prompt, however lxc-console -n test1 -t 0 does give a prompt. lxc-attach with ps -ef: lxc-attach -n test1 root@test1:~# ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 19:54 ? 00:00:00 /sbin/init root 36 1 0 19:54 ? 00:00:00 /lib/systemd/systemd-journald root 76 1 0 19:54 pts/2 00:00:00 /sbin/agetty --noclear --keep-baud console 115200,38400,9600 vt220 root 77 1 0 19:54 ? 00:00:00 /usr/sbin/sshd -D root 79 0 0 20:06 pts/3 00:00:00 /bin/bash So the issue is reproducible on a testing system. When creating a container with -l trace I just get this: lxc-create -l debug -o /tmp/lxc-create_debian.txt -t debian -n test5 cat /tmp/lxc-create_debian.txt lxc-create test7 20190111201044.860 DEBUG storage - storage/storage.c:get_storage_by_name:231 - Detected rootfs type "dir" The same issue I observe with a sid container on another Debian buster installation, only 1 aggety instance listening on console - t 0. Regards, Alex
lxc-info --name test1 | grep PID PID: 5561 ps -ef | grep 5561 root 5561 5560 0 20:54 ? 00:00:00 /sbin/init root 5597 5561 0 20:54 ? 00:00:00 /lib/systemd/systemd-journald root 5640 5561 0 20:54 pts/2 00:00:00 /sbin/agetty --noclear --keep-baud console 115200,38400,9600 vt220 root 5641 5561 0 20:54 ? 00:00:00 /usr/sbin/sshd -D
Hello, I just encountered the same issue. Thanks Alex for debugging and finding the reason: lxc-console attaches by default to tty 1 vs. but the template listens by default on tty 0. Host is an up-to-date Debian buster, with packages lxc (1:3.1.0+really3.0.3-8) and lxc-templates (3.0.3-1). I created a Debian buster container like this: # lxc-create -n buster -t debian -- -r buster Then tried to open a console like this: # lxc-console -n buster Connected to tty 1 Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a> to enter Ctrl+a itself Nothing happened, so I specified tty 0 and it worked: # lxc-console -n buster -t 0 Connected to tty 0 Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a> to enter Ctrl+a itself buster login: Now I don't actually need lxc-console, I use lxc-attach which works great, but when I tested it it was weird that it didn't work with default options. Thanks!
This is happening because /dev/tty0 doesn't exist:
root@vs5:/home/volo# lxc-start -n speedtest
root@vs5:/home/volo# lxc-attach -n speedtest
root@speedtest:/# exit
exit
root@vs5:/home/volo# lxc-console -n speedtest
Connected to tty 1
Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a> to enter Ctrl+a itself
<Ctrl+a q>
root@vs5:/home/volo# lxc-attach -n speedtest
root@speedtest:/# systemctl status getty@tty1.service
● getty@tty1.service - Getty on tty1
Loaded: loaded (/lib/systemd/system/getty@.service; enabled; vendor preset: enabled)
Active: inactive (dead)
Condition: start condition failed at Sat 2020-01-25 10:46:07 UTC; 40s ago
└─ ConditionPathExists=/dev/tty0 was not met
Docs: man:agetty(8)
man:systemd-getty-generator(8)
http://0pointer.de/blog/projects/serial-console.html
Jan 25 10:46:07 speedtest systemd[1]: Condition check resulted in Getty on tty1 being skipped.
root@speedtest:/# mknod /dev/tty0 c 4 0
root@speedtest:/# systemctl restart getty@tty1.service
root@speedtest:/# systemctl status getty@tty1.service
● getty@tty1.service - Getty on tty1
Loaded: loaded (/lib/systemd/system/getty@.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2020-01-25 10:47:11 UTC; 2s ago
Docs: man:agetty(8)
man:systemd-getty-generator(8)
http://0pointer.de/blog/projects/serial-console.html
Main PID: 83 (agetty)
Tasks: 1 (limit: 4915)
Memory: 352.0K
CGroup: /system.slice/system-getty.slice/getty@tty1.service
└─83 /sbin/agetty -o -p -- \u --noclear tty1 linux
Jan 25 10:47:11 speedtest systemd[1]: Started Getty on tty1.
root@speedtest:/# exit
exit
root@vs5:/home/volo# lxc-console -n speedtest
Connected to tty 1
Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a> to enter Ctrl+a itself
Debian GNU/Linux bullseye/sid speedtest tty1
speedtest login:
<Ctrl+a q>
I used lxc.hook.autodev to create tty0 and that fixes the symptom but not the problem:
root@vs5:/home/volo# grep autodev /var/lib/lxc/speedtest/config
lxc.hook.autodev = /var/lib/lxc/speedtest/devhook
root@vs5:/home/volo# cat /var/lib/lxc/speedtest/devhook
#!/bin/sh
mknod ${LXC_ROOTFS_MOUNT}/dev/tty0 c 4 0
root@vs5:/home/volo# lxc-start -n speedtest
root@vs5:/home/volo# lxc-console -n speedtest
Connected to tty 1
Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a> to enter Ctrl+a itself
Debian GNU/Linux bullseye/sid speedtest tty1
speedtest login: root
Password:
Linux speedtest 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u1 (2019-09-20) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Jan 25 14:41:04 UTC 2020 on console
root@speedtest:~# ls -l /dev/{console,tty,tty0,tty1}
crw--w---- 1 root tty 136, 4 Jan 25 14:51 /dev/console
crw-rw-rw- 1 root root 5, 0 Jan 25 14:51 /dev/tty
crw-r--r-- 1 root root 4, 0 Jan 25 14:51 /dev/tty0
crw------- 1 root tty 136, 0 Jan 25 15:03 /dev/tty1
Compare that to the host:
root@vs5:/home/volo# ls -l /dev/{console,tty,tty0,tty1}
crw------- 1 root root 5, 1 Jan 24 18:47 /dev/console
crw-rw-rw- 1 root tty 5, 0 Jan 25 08:38 /dev/tty
crw--w---- 1 root tty 4, 0 Jan 24 18:47 /dev/tty0
crw------- 1 volo tty 4, 1 Jan 24 18:47 /dev/tty1
I think I could have used touch /dev/tty0 instead of mknod and it would
have had the same effect. I also saw systemd-getty-generator in the
systemctl output, which seems relevant, and discusses
container-getty@X.service, but:
root@speedtest:~# systemctl status container-getty@0.service
● container-getty@0.service - Container Getty on /dev/pts/0
Loaded: loaded (/lib/systemd/system/container-getty@.service; enabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:agetty(8)
man:systemd-getty-generator(8)
man:machinectl(1)
Hopefully someone knows where to go from here...
Peter
Hi, is there any new state? i tried the workaround: # mknod /dev/tty0 c 4 0 # systemctl restart getty@tty1.service # systemctl status getty@tty1.service and then it works...till the next container-restart.../dev/tty0 is missing again. Tried lxc-create in buster and bullseye host with bullseye guest. Both are still affected. regards Frank