[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] Libvirt + LXC terminals

On Thu, Mar 14, 2013 at 11:10:31AM +0000, Purcareata Bogdan-B43198 wrote:
> Hello all,
> I am looking for a way to start a container with libvirt and bind
> multiple consoles to it. My container is running busybox, the filesystem
> created using the LXC package (0.8.0). My libvirt version is 0.10.1.
> Configuration of the filesystem:
> - in the container rootfs, /dev contains 2 devices - /dev/console and /dev/tty1

Ok, there's no need to put anything in /dev. Libvirt will mount a
tmpfs on /dev and a devpts on /dev/pts create all the devices nodes

> - the inittab file looks like this:
> ::sysinit:/etc/init.d/rcS
> tty1::respawn:/bin/getty -L tty1 115200 vt100
> console::askfirst:/bin/sh
> - it will link the /bin/sh process to /dev/console and the /bin/getty process to /dev/tty
> - when starting the container with lxc-start, each of these processes gets his own local /dev/pts device:

I'm not sure how sf.net LXC tools setup consoles, but what you have won't
work with Libvirt LXC. The primary console is setup as /dev/console and
/dev/tty1, so your inittab here is putting both processes on the same
console device. The second console is /dev/tty2 with libvirt.

> I've found some documentation at [1], hence my trials in the presented .xml. Is my scenario possible / supported?

Here is the XML I have just used to test the scenario you want:

<domain type='lxc'>
  <memory unit='KiB'>32768</memory>
  <currentMemory unit='KiB'>32768</currentMemory>
  <vcpu placement='static'>1</vcpu>
    <type arch='x86_64'>exe</type>
  <clock offset='utc'/>
    <filesystem type='mount' accessmode='passthrough'>
      <source dir='/root/containers/root-busybox'/>
      <target dir='/'/>
    <console type='pty'>
      <target type='serial' port='0'/>
    <console type='pty'>
      <target type='serial' port='1'/>
    <console type='pty'>
      <target type='serial' port='2'/>
    <console type='pty'>
      <target type='serial' port='3'/>
  <seclabel type='static' model='selinux' relabel='no'>

And I have this inittab

# cat /root/containers/root-busybox/etc/inittab
tty2::respawn:/bin/getty -L tty2 115200 vt100
tty3::respawn:/bin/getty -L tty3 115200 vt100
tty4::respawn:/bin/getty -L tty4 115200 vt100

Now if you start this 'virsh -c lxc:/// start busyinit'


  # virsh -c lxc:/// console busyinit
  Connected to domain busyinit
  Escape character is ^]

  Please press Enter to activate this console.
  /bin/sh: can't access tty; job control turned off
  # ...

will connect you to the first console, which is tty1 and your /bin/sh

To connect to the 2nd, 3rd, etc consoles you can use

  # virsh -c lxc:/// console --devname console1 busyinit
  Connected to domain busyinit
  Escape character is ^]

  t500wlan.home.berrange.com login: 

Use 'virsh -c lxc:/// dumpxml busyinit' to see what console device
names libvirt gave to each - for LXC they'll be named 'console0',
'console1', 'console2', etc.  NB the tty paths in the XML are the
host side TTY names, which are different from the guest side names.

|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]