Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 872628

Summary: List available LXC consoles using container_ttys env variable
Product: Red Hat Enterprise Linux 7 Reporter: Daniel Berrangé <berrange>
Component: libvirtAssignee: Daniel Berrangé <berrange>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: ajia, cwei, dwalsh, dyuan, jdenemar, mzhan, yanyang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
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 07:19:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Daniel Berrangé 2012-11-02 15:48:02 UTC
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 Berrangé 2013-12-13 16:56:24 UTC
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 Berrangé 2013-12-18 11:32:59 UTC
commit daf08f36b525dc9e0f8469ee29ea9ebfd3aa860e
Author: Daniel P. Berrange <berrange>
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>

Comment 7 Jiri Denemark 2014-06-17 13:37:27 UTC
Fixed upstream by v1.2.0-155-gdaf08f3.

Comment 11 Yang Yang 2014-10-21 10:31:17 UTC
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 07:19:40 UTC
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