Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 872628 - List available LXC consoles using container_ttys env variable
List available LXC consoles using container_ttys env variable
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt (Show other bugs)
7.0
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Daniel Berrange
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-11-02 11:48 EDT by Daniel Berrange
Modified: 2016-04-26 12:21 EDT (History)
7 users (show)

See Also:
Fixed In Version: libvirt-1.2.7-1.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-03-05 02:19:40 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:0323 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2015-03-05 07:10:54 EST

  None (edit)
Description Daniel Berrange 2012-11-02 11:48:02 EDT
Description of problem:
For multiple console support libvirt should not use /dev/ttyNNN fake symlinks to /dev/pts/MMM. Psuedo-TTYs do not support the same features as console TTYs and this annoys systemd somewhat. Instead we should create /dev/cttyNNN or /dev/containerttyNNN and set the 'container_tty' env variable to list all device names.
Comment 4 Daniel Berrange 2013-12-13 11:56:24 EST
Support is in systemd upstream now (will be in systemd 209)

http://cgit.freedesktop.org/systemd/systemd/commit/?id=1d97ff7dd71902a5604c2fed8964925d54e09de9


And proposed for libvirt

https://www.redhat.com/archives/libvir-list/2013-December/msg00829.html
Comment 5 Daniel Berrange 2013-12-18 06:32:59 EST
commit daf08f36b525dc9e0f8469ee29ea9ebfd3aa860e
Author: Daniel P. Berrange <berrange@redhat.com>
Date:   Fri Dec 13 16:50:28 2013 +0000

    Set the 'container_ttys' env variable for LXC consoles
    
    Systemd specified that any /dev/pts/NNN device on which it
    is expected to spawn a agetty login, should be listed in
    the 'container_ttys' env variable. It should just contain
    the relative paths, eg 'pts/0' not '/dev/pts/0' and should
    be space separated.
    
    http://cgit.freedesktop.org/systemd/systemd/commit/?id=1d97ff7dd71902a5604c2fed8964925d54e09de9
    
    Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Comment 7 Jiri Denemark 2014-06-17 09:37:27 EDT
Fixed upstream by v1.2.0-155-gdaf08f3.
Comment 11 yangyang 2014-10-21 06:31:17 EDT
Thanks Daniel a lot.

I'd like to verify it on the following version
libvirt-1.2.8-5.el7.x86_64
systemd-208-14.el7.x86_64

Steps:
1. define/start a lxc with multiple console

# cat lxc.xml 
<domain type='lxc'>
  <name>lxc-test</name>
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <os>
    <type arch='x86_64'>exe</type>
<init>/bin/sh</init>  
</os>
  <clock offset='utc'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/libexec/libvirt_lxc</emulator>
    <interface type='network'>
      <mac address='52:54:00:8f:13:eb'/>
      <source network='default'/>
    </interface>
    <console type='pty'>
      <target type='lxc' port='0'/>
    </console>
<console type='pty'>
      <target type='serial' port='1'/>
    </console>
<console type='pty'>
      <target type='lxc' port='2'/>
    </console>
<console type='pty'>
      <target type='lxc' port='3'/>
    </console>
  </devices>
</domain>


# virsh -c lxc:/// define lxc.xml 
Domain lxc-test defined from lxc.xml

# virsh -c lxc:/// start lxc-test 
Domain lxc-test started

2. conneting to lxc console and check env variable *container_ttys*
# virsh -c lxc:/// console lxc-test 
Connected to domain lxc-test
Escape character is ^]
sh-4.2# env
TERM=linux
container_ttys=pts/1 pts/2 pts/3
PATH=/bin:/sbin
PWD=/
container_uuid=c5ae31a2-f950-4f26-8272-9c67636a3575
SHLVL=1
LIBVIRT_LXC_UUID=c5ae31a2-f950-4f26-8272-9c67636a3575
LIBVIRT_LXC_NAME=lxc-test
container=lxc-libvirt
_=/bin/env
sh-4.2# ls /dev/tty* -l
crw-rw-rw-. 1 root root 5, 0 Oct 21 14:26 /dev/tty
lrwxrwxrwx. 1 root root   10 Oct 21 14:26 /dev/tty1 -> /dev/pts/0
lrwxrwxrwx. 1 root root   10 Oct 21 14:26 /dev/tty2 -> /dev/pts/1
lrwxrwxrwx. 1 root root   10 Oct 21 14:26 /dev/tty3 -> /dev/pts/2
lrwxrwxrwx. 1 root root   10 Oct 21 14:26 /dev/tty4 -> /dev/pts/3

3. clean env and define/start a lxc with one console
# cat lxc.xml 
<domain type='lxc'>
  <name>lxc-test</name>
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <os>
    <type arch='x86_64'>exe</type>
<init>/bin/sh</init>  
</os>
  <clock offset='utc'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/libexec/libvirt_lxc</emulator>
    <interface type='network'>
      <mac address='52:54:00:8f:13:eb'/>
      <source network='default'/>
    </interface>
    <console type='pty'>
      <target type='lxc' port='0'/>
    </console>
  </devices>
</domain>

# virsh -c lxc:/// define lxc.xml 
Domain lxc-test defined from lxc.xml

# virsh -c lxc:/// start lxc-test
Domain lxc-test started

4. conneting to the lxc console and check env variable *container_ttys* does not exist
# virsh -c lxc:/// console lxc-test
Connected to domain lxc-test
Escape character is ^]
sh-4.2# env
TERM=linux
PATH=/bin:/sbin
PWD=/
container_uuid=7b48ee47-2e0e-4f72-920c-29ac38d553c4
SHLVL=1
LIBVIRT_LXC_UUID=7b48ee47-2e0e-4f72-920c-29ac38d553c4
LIBVIRT_LXC_NAME=lxc-test
container=lxc-libvirt
_=/bin/env
sh-4.2# ls /dev/tty* -l
crw-rw-rw-. 1 root root 5, 0 Oct 21 15:07 /dev/tty
lrwxrwxrwx. 1 root root   10 Oct 21 15:07 /dev/tty1 -> /dev/pts/0
sh-4.2#

Since above steps got the expected results, set it to verified status
Comment 13 errata-xmlrpc 2015-03-05 02:19:40 EST
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2015-0323.html

Note You need to log in before you can comment on or make changes to this bug.