Bug 982317

Summary: cannot open /dev/tty inside container
Product: [Fedora] Fedora Reporter: Martin Jenner <mjenner>
Component: libvirtAssignee: Eric Blake <eblake>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 19CC: berrange, clalancette, crobinso, dimitris.on.linux, dwalsh, eblake, geertj, itamar, jforbes, jyang, laine, libvirt-maint, tomek, veillard
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.0.5.5-1.fc19 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-08-06 23:35:19 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:
Attachments:
Description Flags
This patch creates /dev/tty within a container. none

Description Martin Jenner 2013-07-08 16:15:54 UTC
Description of problem:

A tty is not opened inside a container stopping the usex test program from running.

UNEXPECTED DIE CODE [20]: cannot open /dev/tty

Version-Release number of selected component (if applicable):
Running F19 RC1
libvirt-sandbox-0.2.0-1.fc19.x86_64
libvirt-1.0.5.1-1.fc19.x86_64
kernel-3.9.5-301.fc19.x86_64


How reproducible:
100%

Steps to Reproduce:
Confirm usex works outside container then test with virt-sandbox command, note the -T 3 switch sets the timeout too 3 minutes 

1. /usr/local/bin/usex -b -T 3 -C
2. virt-sandbox -c lxc:/// -n test -m host-bind:/tmp=/tmp/usex_tmp -- /usr/local/bin/usex -b -T 3 -C


Actual results:
UNEXPECTED DIE CODE [20]: cannot open /dev/tty

Expected results:
usex test program should run inside container as it does on bare metal.

Additional info:

Get usex from
  # curl http://people.redhat.com/anderson/usex/usex-1.9-34.tar.gz -o usex-1.9-34.tar.gz
  # tar xzvf usex-1.9-34.tar.gz
  # cd usex-1.9-34
  # yum install make gcc ncurses-devel
  # make
  # scp usex /usr/local/bin

Comment 1 Daniel Walsh 2013-07-08 18:17:20 UTC
Created attachment 770608 [details]
This patch creates /dev/tty within a container.

This is a libvirt bug not a libvirt-sandbox.

Comment 2 Daniel Berrangé 2013-07-09 10:50:23 UTC
commit 9a0ac6d9c21b914f887d2a1e0051b5beffa81bd7
Author: Richard Weinberger <richard>
Date:   Tue Jul 9 11:05:14 2013 +0100

    LXC: Create /dev/tty within a container

Comment 3 Fedora Update System 2013-07-12 00:44:26 UTC
libvirt-1.0.5.3-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/libvirt-1.0.5.3-1.fc19

Comment 4 Fedora Update System 2013-07-13 02:02:23 UTC
Package libvirt-1.0.5.3-1.fc19:
* should fix your issue,
* was pushed to the Fedora 19 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing libvirt-1.0.5.3-1.fc19'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-12938/libvirt-1.0.5.3-1.fc19
then log in and leave karma (feedback).

Comment 5 Cole Robinson 2013-07-23 14:33:47 UTC
1.0.5.4 is heading to stable now, which fixes this.

Comment 6 Geert Jansen 2013-07-29 19:33:50 UTC
Note that in version 1.0.5.4, for some reason the bug is not fixed correctly. This version creates a /tty, not a /dev/tty. The attached patch will properly fix it:

--- libvirt-1.0.5.4/src/lxc/lxc_container.c.orig	2013-07-29 21:10:08.138088891 +0200
+++ libvirt-1.0.5.4/src/lxc/lxc_container.c	2013-07-29 21:10:21.117815031 +0200
@@ -839,7 +839,7 @@
         { LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_FULL, 0666, "/dev/full" },
         { LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_RANDOM, 0666, "/dev/random" },
         { LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_URANDOM, 0666, "/dev/urandom" },
-        { LXC_DEV_MAJ_TTY, LXC_DEV_MIN_TTY, 0666, "/tty" },
+        { LXC_DEV_MAJ_TTY, LXC_DEV_MIN_TTY, 0666, "/dev/tty" },
     };
     const struct {
         const char *src;

Comment 7 Eric Blake 2013-07-29 19:41:23 UTC
(In reply to Geert Jansen from comment #6)
> Note that in version 1.0.5.4, for some reason the bug is not fixed
> correctly. This version creates a /tty, not a /dev/tty. The attached patch
> will properly fix it:
> 
> --- libvirt-1.0.5.4/src/lxc/lxc_container.c.orig	2013-07-29
> 21:10:08.138088891 +0200
> +++ libvirt-1.0.5.4/src/lxc/lxc_container.c	2013-07-29 21:10:21.117815031
> +0200
> @@ -839,7 +839,7 @@
>          { LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_FULL, 0666, "/dev/full" },
>          { LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_RANDOM, 0666, "/dev/random" },
>          { LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_URANDOM, 0666, "/dev/urandom" },
> -        { LXC_DEV_MAJ_TTY, LXC_DEV_MIN_TTY, 0666, "/tty" },
> +        { LXC_DEV_MAJ_TTY, LXC_DEV_MIN_TTY, 0666, "/dev/tty" },
>      };
>      const struct {
>          const char *src;

Can you also post this to libvir-list? It would be nice to get this fixed in the 1.1.1 release.

Comment 8 Geert Jansen 2013-07-29 19:51:33 UTC
(In reply to Eric Blake from comment #7)

> Can you also post this to libvir-list? It would be nice to get
> this fixed in the 1.1.1 release.

Upstream has already fixed htis. Device creation moved to lxc_controller.c and and table entries now have the "/dev" prefixes got removed.

Comment 9 Eric Blake 2013-07-29 20:04:21 UTC
Good to know - that just means we botched things when backporting to v1.0.5-maint.  I'll take a look at fixing it.

Comment 10 Eric Blake 2013-07-29 21:51:27 UTC
Cole's next release on the 1.0.5.x maint series will include this:

commit a10d077ef202d35b62d586e2356ce507e4ca6135
Author: Eric Blake <eblake>
Date:   Mon Jul 29 15:45:25 2013 -0600

    lxc: correctly backport /dev/tty fix
    
    https://bugzilla.redhat.com/show_bug.cgi?id=982317
    
    maint-only patch; reported by Geert Jansen
    
    Commit 17cdc298 tried to backport upstream 90a0c6d, but in
    resolving conflicts, failed to account that upstream commit
    e1d32bb refactored code to leave off a leading /dev.
    
    * src/lxc/lxc_container.c (lxcContainerPopulateDevices): Use
    correct device name.
    
    Signed-off-by: Eric Blake <eblake>

Comment 11 Fedora Update System 2013-08-01 23:49:37 UTC
libvirt-1.0.5.5-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/libvirt-1.0.5.5-1.fc19

Comment 12 Fedora Update System 2013-08-02 22:03:36 UTC
Package libvirt-1.0.5.5-1.fc19:
* should fix your issue,
* was pushed to the Fedora 19 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing libvirt-1.0.5.5-1.fc19'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-14127/libvirt-1.0.5.5-1.fc19
then log in and leave karma (feedback).

Comment 13 Geert Jansen 2013-08-03 08:13:29 UTC
Works for me. I have added Karma to the update. Thanks for the quick fix!

Comment 14 Daniel Berrangé 2013-08-06 13:04:20 UTC
*** Bug 993733 has been marked as a duplicate of this bug. ***

Comment 15 Tomasz Sterna 2013-08-06 20:21:22 UTC
libvirt-1.0.5.5-1.fc19 fixed bug 993733 for me. Thanks.

Comment 16 Fedora Update System 2013-08-06 23:35:19 UTC
libvirt-1.0.5.5-1.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 17 Daniel Berrangé 2013-08-07 08:59:54 UTC
*** Bug 994280 has been marked as a duplicate of this bug. ***