Bug 587276 - [LXC] can't connect to a OS container via console, and print any key expect "CTRL + ]" will make the container shutoff
[LXC] can't connect to a OS container via console, and print any key expect "...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt (Show other bugs)
6.0
All Linux
low Severity medium
: rc
: ---
Assigned To: Jiri Denemark
Virtualization Bugs
:
Depends On:
Blocks: 693512 Rhel6.1LibvirtTier1
  Show dependency treegraph
 
Reported: 2010-04-29 10:05 EDT by Osier Yang
Modified: 2011-12-06 05:43 EST (History)
9 users (show)

See Also:
Fixed In Version: libvirt-0.9.1-1.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-12-06 05:43:22 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Osier Yang 2010-04-29 10:05:40 EDT
Description of problem:
the OS is built via febootstrap. e.g
# febootstrap --group-install="base" rawhide fedora-rawhide

And the container XML is:
virsh # dumpxml fedora-rawhide
<domain type='lxc'>
  <name>fedora-rawhide</name>
  <uuid>6222c8db-8764-9c54-8fed-2646b8c4ef78</uuid>
  <memory>32768</memory>
  <currentMemory>32768</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64'>exe</type>
    <init>/init</init>
  </os>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/libexec/libvirt_lxc</emulator>
    <filesystem type='mount'>
      <source dir='/root/tmp/rawhide'/>
      <target dir='/'/>
    </filesystem>
    <interface type='network'>
      <mac address='52:54:00:73:6b:43'/>
      <source network='default'/>
      <target dev='veth1'/>
    </interface>
    <console type='pty'>
      <target port='0'/>
    </console>
  </devices>
</domain>

virsh # start fedora-rawhide
Domain fedora-rawhide started

virsh # list --all
 Id Name                 State
----------------------------------
29409 vm1                  running
29819 fedora-rawhide       running

virsh # console fedora-rawhide
Connected to domain fedora-rawhide
Escape character is ^]

!!!!!!!!!!!!!!!!!
no reaction here, and print any key except "CTRL + ]",  will escape from the connection, and as a side effect, the domain will be shutoff. input "CTRL + ]"
is okay, it will just escape. 
!!!!!!!!!!!!!!!!!

virsh # list --all
 Id Name                 State
----------------------------------
29409 vm1                  running
  - fedora-rawhide       shut off


Version-Release number of selected component (if applicable):
libvirt-0.8.0-4

How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:
Comment 2 RHEL Product and Program Management 2010-04-29 11:25:30 EDT
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux major release.  Product Management has requested further
review of this request by Red Hat Engineering, for potential inclusion in a Red
Hat Enterprise Linux Major release.  This request is not yet committed for
inclusion.
Comment 3 Osier Yang 2010-05-10 09:53:37 EDT
sry, the xml should be:

<domain type='lxc'>
  <name>fedora-rawhide</name>
  <uuid>6222c8db-8764-9c54-8fed-2646b8c4ef78</uuid>
  <memory>32768</memory>
  <currentMemory>32768</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64'>exe</type>
    <init>/sbin/init</init>
  </os>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/libexec/libvirt_lxc</emulator>
    <filesystem type='mount'>
      <source dir='/root/tmp/rawhide'/>
      <target dir='/'/>
    </filesystem>
    <interface type='network'>
      <mac address='52:54:00:73:6b:43'/>
      <source network='default'/>
      <target dev='veth1'/>
    </interface>
    <console type='pty'>
      <target port='0'/>
    </console>
  </devices>
</domain>

with the upper xml, the guest could be connected. so the main problem of this bug doesn't exist. close it.
Comment 4 dyuan 2010-05-11 02:29:54 EDT
Have modified the xml as Comment 3 and define the guest again,
but the result is the same as original description。

Version-Release number of selected component (if applicable):
libvirt-0.8.1-1
Comment 6 dyuan 2010-08-05 03:43:39 EDT
Test with libvirt-0.8.1-21.el6.i686

domain will not be shutoff when print any key except "CTRL + ]", but still cann't connect to the OS container via console.
Comment 7 dyuan 2010-08-05 05:13:55 EDT
After reboot os, cannot reproduce the issue in comment 6, can connect to the OS container via console successfully. Maybe there were some problems with the container at that time.
Comment 8 Daniel Berrange 2010-10-11 11:10:01 EDT
This is likely to be a configuration issue. The default febootstrap install likely does not configure mingetty to listen on the correct devices. Need to investigate & document the proper bootstrap technique
Comment 9 Daniel Berrange 2010-11-04 13:50:20 EDT
There's several issues at play here. 

 - Your Fedora container install needs to be manually configured to run a
mingetty on the right device
 - /dev/console is incorrectly setup in the container.
 - A bug in libvirt_lxc means that it often quits prematurely resulting in
error : vshRunConsole:77 : unable to open tty /dev/pts/10: No such file or


2 & 3 are easily fixed in libvirt. 1 is a documentation problem, and/or a
reason to provide a 'virt-bootstrap' tool for LXC with common distros
Comment 11 Daniel Berrange 2011-02-23 07:05:27 EST
The console handling is fixed in this upstream patch

http://www.redhat.com/archives/libvir-list/2011-February/msg01006.html
Comment 12 Jiri Denemark 2011-04-21 05:44:23 EDT
Fixed upstream by v0.8.8-179-g4e3117a:

commit 4e3117ae50efc0fcbd5ce485cd610dfab7f5c625
Author: Daniel P. Berrange <berrange@redhat.com>
Date:   Tue Feb 22 17:35:06 2011 +0000

    Make LXC container startup/shutdown/I/O more robust
    
    The current LXC I/O controller looks for HUP to detect
    when a guest has quit. This isn't reliable as during
    initial bootup it is possible that 'init' will close
    the console and let mingetty re-open it. The shutdown
    of containers was also flakey because it only killed
    the libvirt I/O controller and expected container
    processes to gracefully follow.
    
    Change the I/O controller such that when it see HUP
    or an I/O error, it uses kill($PID, 0) to see if the
    process has really quit.
    
    Change the container shutdown sequence to use the
    virCgroupKillPainfully function to ensure every
    really goes away
    
    This change makes the use of the 'cpu', 'devices'
    and 'memory' cgroups controllers compulsory with
    LXC
Comment 14 zhanghaiyan 2011-05-25 22:25:44 EDT
Verified this bug pass with libvirt-0.9.1-1.el6.x86_64

1. # febootstrap --group-install="base" rawhide /tmp/rawhide

2. # cat vm2.xml 
<domain type='lxc'>
  <name>fedora-rawhide-2</name>
  <memory>32768</memory>
  <currentMemory>32768</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64'>exe</type>
    <init>/sbin/init</init>
  </os>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/libexec/libvirt_lxc</emulator>
    <filesystem type='mount'>
      <source dir='/tmp/rawhide'/>
      <target dir='/'/>
    </filesystem>
    <interface type='network'>
      <source network='default'/>
      <target dev='veth1'/>
    </interface>
    <console type='pty'>
      <target port='0'/>
    </console>
  </devices>
</domain>

3. virsh # define vm2.xml 
Domain fedora-rawhide-2 defined from vm2.xml

virsh # start fedora-rawhide-2
Domain fedora-rawhide-2 started

virsh # list --all
 Id Name                 State
----------------------------------
679 vm1                  running
28627 fedora-rawhide-2     running

4. virsh # console fedora-rawhide-2
Connected to domain fedora-rawhide-2
Escape character is ^]
SELinux:  Could not open policy file <= /etc/selinux/targeted/policy/policy.26:  No such file or directory
Failed to load SELinux policy.
Failed to mount /sys/fs/cgroup: No such file or directory
Failed to mount /sys/fs/cgroup/systemd: No such file or directory
Failed to mount /sys/fs/cgroup/cpuset: No such file or directory
Failed to mount /sys/fs/cgroup/ns: No such file or directory
Failed to mount /sys/fs/cgroup/cpu: No such file or directory
Failed to mount /sys/fs/cgroup/cpuacct: No such file or directory
Failed to mount /sys/fs/cgroup/memory: No such file or directory
Failed to mount /sys/fs/cgroup/devices: No such file or directory
Failed to mount /sys/fs/cgroup/freezer: No such file or directory
Failed to mount /sys/fs/cgroup/net_cls: No such file or directory
Failed to mount /sys/fs/cgroup/blkio: No such file or directory
systemd 26 running in system mode. (+PAM +LIBWRAP +AUDIT +SELINUX +SYSVINIT +LIBCRYPTSETUP; fedora)
No hostname configured.
Failed to enable ctrl-alt-del handling: Operation not permitted
Failed to open /dev/tty0: No such file or directory
No control group support available, not creating root group.
Failed to fully start up daemon: No such file or directory
Failed to open /dev/autofs: No such file or directory
Failed to initialize automounter: No such file or directory
Unit dev-hugepages.automount entered failed state.
Failed to open /dev/autofs: No such file or directory
Failed to initialize automounter: No such file or directory
Unit proc-sys-fs-binfmt_misc.automount entered failed state.
Failed to open /dev/autofs: No such file or directory
Failed to initialize automounter: No such file or directory
Unit dev-mqueue.automount entered failed state.
Failed to open /dev/autofs: No such file or directory
Failed to initialize automounter: No such file or directory
Unit sys-kernel-security.automount entered failed state.
Failed to open /dev/autofs: No such file or directory
Failed to initialize automounter: No such file or directory
Unit sys-kernel-debug.automount entered failed state.
systemd-kmsg-syslogd.service: main process exited, code=exited, status=218
Unit systemd-kmsg-syslogd.service entered failed state.
systemd-readahead-collect.service: main process exited, code=exited, status=1
systemd-logger.service: main process exited, code=exited, status=218
Unit systemd-logger.service entered failed state.


fd
fdfd

virsh # list --all
 Id Name                 State
----------------------------------
679 vm1                  running
28627 fedora-rawhide-2     running

virsh # 

Could connect to console successfully, and when press key like 'fd' 'enter' 'fdfd', it doesn't quit console or causes guest shutdown, so the fix patch works well.
Comment 16 min zhan 2011-07-18 03:17:54 EDT
Move to Verified according to Comment #14
Comment 17 errata-xmlrpc 2011-12-06 05:43:22 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.

http://rhn.redhat.com/errata/RHBA-2011-1513.html

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