Setup serial console device for 'virsh console' (Centos)

KVM (for Kernel-based Virtual Machine) is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V). It consists of a loadable kernel module, kvm.ko, that provides the core virtualization infrastructure and a processor specific module, kvm-intel.ko or kvm-amd.ko. KVM also requires a modified QEMU although work is underway to get the required changes upstream.

Setup serial console device for 'virsh console' (Centos)

Postby lik » Fri Jan 04, 2013 12:22 pm

If you plan to use 'virsh console' for access to KVM domains from the carrier server you should setup correct guest console device first.

1. Centos6 case

Centos 6 use upstart for configuration of serial consoles (terminals). You can find tip on it in the /etc/inittab configuration file.
Content of default Centos 6 /etc/inittab :
Code: Select all
# cat /etc/inittab
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:

Upstart configuration files are stored in /etc/init directory:
Code: Select all
# ls -1 /etc/init/*

/etc/init/control-alt-delete.conf
/etc/init/init-system-dbus.conf
/etc/init/kexec-disable.conf
/etc/init/plymouth-shutdown.conf
/etc/init/prefdm.conf
/etc/init/quit-plymouth.conf
/etc/init/rc.conf
/etc/init/rcS.conf
/etc/init/rcS-emergency.conf
/etc/init/rcS-sulogin.conf
/etc/init/serial.conf
/etc/init/splash-manager.conf
/etc/init/start-ttys.conf
/etc/init/tty.conf

We will need to create /etc/init/ttyS0.conf configuration file with the following content for a new TTY device:
Code: Select all
# ttyS0 - mingetty
#
# This service maintains a mingetty on ttyS0.
stop on runlevel [S016]
start on runlevel [2345]

respawn
instance /dev/ttyS0
exec /sbin/mingetty --autologin root --noclear ttyS0

Add ttyS0 device to the list of of tty lines on which root is allowed to login :
Code: Select all
echo "ttyS0" >> /etc/securetty

Start it:
Code: Select all
# initctl start ttyS0
ttyS0 (/dev/ttyS0) start/running, process 27100

Configure the guest kernel settings in the guest /boot/grub/grub.conf and append console=/dev/ttyS0 option to the default kernel.
Reboot KVM domain to apply new settings. Check 'virsh console' work:
Code: Select all
# virsh console kvm101
Connected to domain kvm101
Escape character is ^]

CentOS release 6.3 (Final)
Kernel 2.6.32-279.19.1.el6.i686 on an i686

srv1 login:


2. Centos5 case

Centos 5 do not use upstart, therefore configuration is a bit simplier.
We need to add definition of console device in /etc/inittab:
Code: Select all
7:2345:respawn:/sbin/mingetty --autologin root --noclear ttyS0

Add ttyS0 device to the list of of tty lines on which root is allowed to login :
Code: Select all
echo "ttyS0" >> /etc/securetty

Append console=/dev/ttyS0 option to the default kernel in /boot/grub/grub.conf.
Reboot KVM domain to apply new settings. Check 'virsh console' work.

Similar steps can be used for Xen domains and correct work of 'xm console' / 'xl console'.
lik
Founder
Founder
 
Posts: 497
Joined: Wed Dec 15, 2010 3:21 am

Return to KVM related

 


  • Related topics
    Replies
    Views
    Last post
cron