HLUG TWiki > HLUG > UsingConserverWithUserModeLinux TWiki webs:
AIX| Classes | HALBOD | HLUG | Helpdesk | Library | Main | Samba | TWiki |
HLUG . { Home | Changes | Index | Search | Go }

Using Conserver with User Mode Linux

Introduction

User mode linux can be used to create multiple virtual linux boxen on top of a host system.

This document covers the use of Conserver as a software KVM for managing multiple UML virtual machines.

User Mode Linux Consoles

Each virtual machine created with UML requires one or more console ports in order to boot, in addition to being an administrative interface. These console ports serve the same function as the keyboard and monitor on a real linux system.

I'll briefly cover the different types of console port and the issues with supporting multiple virtual systems.

Xterminals (default)

By default UML opens an xterm for each console on a UML virtual machine.

This means a working X server is neccesary, and an unwieldy number of xterms will be open.

While this may be ok for one UML virtual machine, its not suited to managing multiple virtual machines.

File Descriptors

This mode allows UML to bind a console port to existing file descriptors (ie: STDIN/STDOUT).

Typically, this is used to assign con0 to run within the existing terminal, when launched interactively.

This is undesireable because launching more than one virtual machine becomes a manual process.

Network Ports

Binding UML consoles to network ports is another way to make a range of consoles available to the administrator.

Assigning con0-9 to sequential dedicated port numbers is an easy way to differentiate between virtual systems, and nothing more complex than a standard telnet client is required.

My experience was that upon booting a virtual machine, I had to telnet into con0 in order for it to continue to boot. Again, this was a very manual process that didn't lend itself to managing several virtual machines.

Dynamically assigned PTY's

UML can bind console ports to pty's when launched, allowing the use of Minicom or Kermit to communicate with the pty's that are allocated.

This may be more secure than opening network ports, however the dynamic nature of the pty assignments makes automation difficult. Its unlikely that the same pty's will be reused for a given virtual machine.

Automating UML Consoles

Given the automation problems encountered with the various methods of assigning consoles to virtual machines, I decided what I needed was a software KVM switch.

I wanted a solution that:

Using preallocated PTY/TTY pairs

UML can use pty/tty devices for consoles in a statically assigned manner.

Dedicated pty/tty devices can be predetermined for UML consoles at the upper bound of the pty range, preventing conflict with dynamic pty allocation.

Enter Conserver

Conserver is a program for logging and controlling multiple hosts attached via serial device, or via network port. I've used Conserver previously to manage DEC Alphas and Linux systems via serial console cable and network terminal server.

Conserver allows users to attach to a console while continuing to log all activity on that console. Conserver also automatically opens the initial console connection, and reopens connections that fail.

In this instance, we'll use Conserver to manage the dedicated pty/tty devices that our UML virtual systems will use for consoles.

UML Dedicated PTY/TTY Setup

I decided to use /dev/ptyy0-/dev/ptyyf for con0 on my UML systems, and /dev/ptyz0-/dev/ptyzf for con1. The corresponding tty devices are /dev/ttyy0-/dev/ttyyf, and /dev/ttyz0-/dev/ttyzf.

This provides a boot console and an administrative console for each UML system.

Here is a sample invocation of UML on dedicated pty/tty console ports.

# Launching virtual host "Dwarf"

/vm/linux ubd0=/vm/dwarf/hda con=null con0=tty:/dev/ptyy0 con1=tty:/dev/ptyz0 eth0=tuntap,,,192.168.1.160 &

Parameter breakdown:

I run five UML virtual machines on sequential pty/tty combos, however this method could work for any number of hosts provided sufficient pty's are available.

Managing the Dedicated PTY/TTY Consoles with Conserver

Conserver Configuration

Here are portions of my Conserver configuration file (conserver.cf) to support multiple UML virtual machines.

# Defaults section

default full {
        rw *;
}

# Keep logfiles for each console, using the console name for the logfile.

default * {
        logfile /var/consoles/&;
        timestamp "";
        include full;
        master localhost;
        type device;
        baud 115200;
        parity none;
}

# Allow access from localhost only for console sessions.

access * {
        allowed 127.0.0.1;
}

# List of UML virtual machines and their dedicated console pty/tty pair.

console dwarf_vt0 { device /dev/ttyy0; }
console dwarf_vt1 { device /dev/ttyz0; }

console elf_vt0 { device /dev/ttyy1; }
console elf_vt1 { device /dev/ttyz1; }

console hobbit_vt0 { device /dev/ttyy2; }
console hobbit_vt1 { device /dev/ttyz2; }

console human_vt0 { device /dev/ttyy3; }
console human_vt1 { device /dev/ttyz3; }

console orc_vt0 { device /dev/ttyy4; }
console orc_vt1 { device /dev/ttyz4; }

Using Conserver

When Conserver is started, it attempts to connect to all the consoles it is supposed to manage.

On my system using devfs, the tty ports aren't created until the corresponding tty is opened. I run Conserver with the "-O1" parameter, forcing Conserver to attempt to reconnect once per minute to any downed console.

With this in mind, I can launch my UML virtual machines at any time, and they will finish booting when Conserver connects to their respective con0 within a minute.

I can connect to any console using the console command. Invoke console with the "-u" flag to display a list of available consoles and their current status, or specify the console to attach to as the first parameter.

Once connected you can use the console normally.

To get help on Conserver commands in console, press Control-E, then "c", then "?". This is quite obtuse, however its unlikely to happen accidentally.

To exit from the console, press Control-E, "c", ".".

All activity on all consoles are logged to /var/consoles, which is useful for troubleshooting boots and monitoring usage.

Summary

Conserver is an excellent way to automate management of multiple UML virtual machines in a consistent manner across dedicated pty/tty console devices.

-- RussellAdams - 10 Dec 2003

Topic UsingConserverWithUserModeLinux . { Edit | Attach | 5B%5EA-Za-z%5D">Ref-By | Printable | Diffs | r1.1 | More }
Revision r1.1 - 10 Dec 2003 - 07:33 GMT - RussellAdams Copyright © 2003-2007 by the contributing authors