===========================================================================
				    HVCS
	IBM "Hypervisor Virtual Console Server" Installation Guide
			    for Linux Kernel 2.6.4+
		      Copyright (C) 2004 IBM Corporation

===========================================================================
NOTE:Eight space tabs are the optimum editor setting for reading this file.
===========================================================================

		 Author(s) :  Ryan S. Arnold <rsa@us.ibm.com>
			Date Created: March, 02, 2004

---------------------------------------------------------------------------
Table of contents:

	1.  Driver Introduction:
	2.  System Requirements
	3.  Build Options:
		3.1  Built-in:
		3.2  Module:
	4.  Installation:
	5.  Connection:
	6.  Configuration:
	7.  Questions & Answers:
	8.  Reporting Bugs:

---------------------------------------------------------------------------
1. Driver Introduction:

This is the device driver for the IBM Hypervisor Virtual Console Server,
"hvcs".  The IBM hvcs provides a tty driver interface to allow Linux user
space applications access to the system consoles of logically partitioned
operating systems (Linux and AIX) running on the same partitioned Power5
ppc64 system.  Physical hardware consoles per partition are not practical
on this hardware so system consoles are accessed by this driver using
firmware interfaces to virtual terminal devices.

---------------------------------------------------------------------------
2. System Requirements:

This device driver was written using 2.6.4 Linux kernel APIs and will only
build and run on kernels of this version or later.

This driver was written to operate solely on IBM Power5 ppc64 hardware
though some care was taken to abstract the architecture dependent hcalls
from the driver code.

Sysfs must be mounted on the system so that the user can determine which
major and minor numbers are associated with each vty-server.  Directions
for sysfs mounting are outside the scope of this document.

---------------------------------------------------------------------------
3. Build Options:

The hvcs driver registers itself as a tty driver.  The tty layer
dynamically allocates a block of major and minor numbers in a quantity
requested by the registering driver.  The hvcs driver asks the tty layer
for 64 of these major/minor numbers by default to use for hvcs device node
entries.

If the default number of device entries is adequate then this driver can be
built into the kernel.  If not, the default can be over-ridden by inserting
the driver as a module with insmod parameters.

---------------------------------------------------------------------------
3.1 Built-in:

The following menuconfig example demonstrates selecting to build this
driver into the kernel.

	Device Drivers  --->
		Character devices  --->
			<*> IBM Hypervisor Virtual Console Server Support

Begin the kernel make process.

---------------------------------------------------------------------------
3.2 Module:

The following menuconfig example demonstrates selecting to build this
driver as a kernel module.

	Device Drivers  --->
		Character devices  --->
			<M> IBM Hypervisor Virtual Console Server Support

The make process will build a kernel module named:

	hvcs.ko

To insert the module with the default allocation execute the
following command:

	insmod hvcs.ko

To override the default use an insmod parameter as follows (requesting 4
tty devices as an example):

	insmod hvcs.ko hvcs_parm_num_devs=4

There is a maximum number of dev entries that can be specified on insmod.
We think that 1024 is currently a decent maximum number of server adapters
to allow.  This can always be changed by modifying the constant in the
source file before building.

NOTE: The length of time it takes to insmod the driver seems to be related
to the number of tty interfaces the registering driver requests.

In order to remove the driver module execute the following command:

	rmmod hvcs.ko

---------------------------------------------------------------------------
4. Installation:

The tty layer creates sysfs entries which contain the major and minor
numbers allocated for the hvcs driver.  The following snippet of "tree"
output of the sysfs directory shows where these numbers are presented:

	sys/
	|-- *other sysfs base dirs*
	|
	|-- class
	|   |-- *other classes of devices*
	|   |
	|   `-- tty
	|       |-- *other tty devices*
	|       |
	|       |-- hvcs0
	|       |   `-- dev
	|       |-- hvcs1
	|       |   `-- dev
	|       |-- hvcs2
	|       |   `-- dev
	|       |-- hvcs3
	|       |   `-- dev
	|       |
	|       |-- *other tty devices*
	|
	|-- *other sysfs base dirs*

For the above examples the following output is a result of cat'ing the
"dev" entry in the hvcs directory:

	Pow5:/sys/class/tty/hvcs0/ # cat dev
	254:0

	Pow5:/sys/class/tty/hvcs1/ # cat dev
	254:1

	Pow5:/sys/class/tty/hvcs2/ # cat dev
	254:2

	Pow5:/sys/class/tty/hvcs3/ # cat dev
	254:3

The output from reading the "dev" attribute is the char device major and
minor numbers that the tty layer has allocated for this driver's use.  Most
systems running hvcs will already have the device entries created or udev
will do it automatically.

Given the example output above, to manually create a /dev/hvcs* node entry
mknod can be used as follows:

	mknod /dev/hvcs0 c 254 0
	mknod /dev/hvcs1 c 254 1
	mknod /dev/hvcs2 c 254 2
	mknod /dev/hvcs3 c 254 3

Using mknod to manually create the device entries makes these device nodes
persistent.  Once created they will exist prior to the driver insmod.

Attempting to connect an application to /dev/hvcs* prior to insertion of
the hvcs module will result in an error message similar to the following:

	"/dev/hvcs*: No such device".

NOTE: Just because there is a device node present doesn't mean that there
is a vty-server device configured for that node.

---------------------------------------------------------------------------
5. Connection

Since this driver implements a tty interface a user can interact with the
device node entries in a standard tty-interactive method.  The original
purpose of this driver, however, is to provide real time console
interaction with a Linux partition's console.  This is easily done using
"minicom".

As a precautionary measure an hvcs user should always "exit" from their
session before disconnecting a program such as minicom from the device.  If
this is not done, the next user to connect to the console will continue
using the previous user's logged in session.

---------------------------------------------------------------------------
6. Configuration

Each vty-server has a sysfs entry in the sys/devices/vio directory, which
is symlinked in several other sysfs tree directories, notably under the
hvcs driver entry, which looks like the following example:

	Pow5:/sys/bus/vio/drivers/hvcs # ls
	.  ..  30000003  30000004  rescan

By design, firmware notifies the hvcs driver of vty-server lifetimes and
partner vty removals but not the addition of partner vtys.  Since an HMC
Super Admin can add partner info dynamically we have provided the hvcs
driver sysfs directory with the "rescan" update attribute which will query
firmware and update the partner info for all the vty-servers that this
driver manages.  Writing a '1' to the attribute triggers the update.  An
explicit example follows:

	Pow5:/sys/bus/vio/drivers/hvcs # echo 1 > rescan

Reading the attribute will indicate a state of '1' or '0'.  A one indicates
that an update is in process.  A zero indicates that an update has
completed or was never executed.

Vty-server entries in this directory are a 32 bit partition unique unit
address that is created by firmware.  An example vty-server sysfs entry
looks like the following:

	Pow5:/sys/bus/vio/drivers/hvcs/30000004 # ls
	.   current_vty   name          partner_vtys
	..  detach_state  partner_clcs

Each entry is provided, by default with a "name" attribute.  Reading the
"name" attribute will reveal the device type as shown in the following
example:

	Pow5:/sys/bus/vio/drivers/hvcs/30000003 # cat name
	vty-server

Each vty-server sysfs dir is provided with two read-only attributes that
provide lists of easily parsed partner vty data: "partner_vtys" and
"partner_clcs".

	Pow5:/sys/bus/vio/drivers/hvcs/30000004 # cat partner_vtys
	30000000
	30000001
	30000002
	30000000
	30000000

	Pow5:/sys/bus/vio/drivers/hvcs/30000004 # cat partner_clcs
	U5112.428.103048A-V3-C0
	U5112.428.103048A-V3-C2
	U5112.428.103048A-V3-C3
	U5112.428.103048A-V4-C0
	U5112.428.103048A-V5-C0

Reading partner_vtys returns a list of partner vtys.  Vty unit address
numbering is only per-partition-unique so entries will frequently repeat.

Reading partner_clcs returns a list of "converged location codes" which are
composed of a system serial number followed by "-V*", where the '*' is the
target partition number, and "-C*", where the '*' is the slot of the
adapter.  The first vty partner corresponds to the first clc item, the
second vty partner to the second clc item, etc.

A vty-server can only be connected to a single vty at a time.  The entry,
"current_vty" prints the clc of the currently selected partner vty when
read.

The current_vty can be changed by writing a valid partner clc to the entry
as in the following example:

	Pow5:/sys/bus/vio/drivers/hvcs/30000004 # echo U5112.428.10304
	8A-V4-C0 > current_vty

Changing the current_vty when a vty-server is already connected to a vty
does not affect the current connection.  The change takes effect when the
currently open connection is freed.

---------------------------------------------------------------------------
7. Questions & Answers:
===========================================================================
Q: What are the security concerns involving hvcs?

A: There are three main security concerns:

	1. The creator of the /dev/hvcs* nodes has the ability to restrict
	the access of the device entries to certain users or groups.  It
	may be best to create a special hvcs group privilege for providing
	access to system consoles.

	2. To provide network security when grabbing the console it is
	suggested that the user connect to the console hosting partition
	using a secure method, such as SSH or sit at a hardware console.

	3. Make sure to exit the user session when done with a console.
	Minicom can be configured to do it automatically by adding "exit^M"
	as a reset string.

---------------------------------------------------------------------------
Q: How do I multiplex a console that I grab through hvcs so that other
people can see it:

A: Use "screen" and setup a session on your machine with the console group
privileges.  Then inside of the screen session execute minicom to connect
to the target console.

---------------------------------------------------------------------------
Q: When I use screen to multiplex the console how do I get out of minicom?

A: Screen interprets Ctrl-A-a as an indication to allow a Ctrl-A pass
through, at which point the user should hit 'X' to terminate minicom.

---------------------------------------------------------------------------
Q: Why are the colors all messed up?
Q: Why are the control characters acting strange?
Q: Why is the console output all strange and unintelligible?

A: The user should be aware that minicom can either do vt100 or ANSI
terminal emulation, (which can be specified using "Terminal settings..T"
under the "Minicom Command Summary").  Once logged in the user will want to
set the $TERM env variable of the console to "vt100" (recommended) or
"ANSI".

Just because you logged into the console with minicom (native vt100
$TERM) type, doesn't mean someone else didn't log into the console with the
HMC console (vt320) before you and leave the session logged in.  The best
thing to do is to "export TERM=vt100" when you get the console.
Additionally make sure to "exit" the console before you disconnect minicom
(which can be set up to be done automatically).  This will ensure that the
next user gets their own TERM type set when they login.

---------------------------------------------------------------------------
Q: When I try to use minicom to connect to a device I get "minicom: cannot
open /dev/hvcs*: No such device".  What is happening?

A: You probably haven't inserted the hvcs.ko module yet or there is not a
corresponding vty-server device that maps to the /dev/hvcs* entry.

---------------------------------------------------------------------------
Q: When I try to use minicom to connect to a device I get "Cannot create
lockfile. Sorry."  What is happening?

A: The user profile you are using to execute minicom probably doesn't have
permissions to use the /dev/hvcs* device.

---------------------------------------------------------------------------
Q: When I use minicom and input data reaches the end of the line it carriage
returns without a linewrap.  What is happening?

A: Invoke minicom with the "-w" command and it will auto linewrap.
---------------------------------------------------------------------------
Q: No matter what, I keep getting a rejection from minicom that the console
is busy.  What is happening?

A: Some other Power5 console mechanism has a connection to the vty and
isn't giving it up.  You can try to force disconnect the consoles from the
HMC by right clicking on the partition and then selecting "close terminal".
Otherwise you have to hunt down the people who have console authority.  It
is possible that you already have the console open using minicom and just
forgot about it.  Please review the console options for Power5 systems to
determine the many ways a system console can be held.

---------------------------------------------------------------------------
Q: If I already have one linux partition installed can I use hvcs on said
partition to provide the console for the install of a second linux
partition?

A: As far as we know, yes.

---------------------------------------------------------------------------
Q: Can I connect to more than one partition's console at a time using this
driver?

A: Yes.  Of course this means that there must be more than one vty-server
configured for this partition and it must point to a disconnected vty.

---------------------------------------------------------------------------
8. Reporting Bugs:

The proper channel for reporting bugs is either through the Linux OS
distribution company that provided your OS or by posting issues to the
ppc64 development mailing list at:

linuxppc64-dev@lists.linuxppc.org

This request is to provide a documented and searchable public exchange
of the problems and solutions surrounding this driver for the benefit of
all users.
