Go to the previous, next section.

Virtual Machines

A virtual machine is a special task, used to provide the illusion of a complete PC system to the program running in the task.

All virtual machines are given a standard set of virtual hardware when they are created. This includes a tty to provide a virtual video adaptor and virtual keyboard hardware. Other virtual devices may be added using the shell commands that initialise virtual machines.

Launching Virtual Machines

The shell is used to configure and launch a virtual machine; this involves initialising a virtual machine, specifying the hardware virtualised by this machine in a series of shell commands and a final command to actually start the newly created virtual machine executing.

Command: vminit [name] [memory-size] [display-type]

This command begins a new virtual machine initialisation block for a virtual machine called name.

The parameter memory-size defines the number of kilobytes of memory given to the new virtual machine while display-type names the type of virtual video adaptor given to the machine. Currently the only options are `MDA' or `CGA'.

If any of the optional parameters aren't specified suitable default values are chosen.

Command: vmvxd module-name [args ...]

This command is used to install a virtual device into the virtual machine currently being configured (i.e. the most recent vminit command).

The parameter module-name names the virtual device module containing the virtualisation code, the optional argument strings args are passed to the virtual device's initialisation function.

Command: vmlaunch

Use this command to end a initialisation block started by the vminit command. The virtual machine is started executing.

Using the above shell commands blocks of commands completely configuring a virtual machine can be built. If these commands are saved in files they can be used as shell scripts to start a particular type of virtual machine.

Standard Virtual Devices

When creating a virtual machine the virtual devices you give it is entirely up to you. However, several virtual devices exist that should normally be installed in a virtual machine to let it work as a real machine would. These devices are listed below

vpic
The virtual interrupt controller. Without this device the virtual machine won't receive any interrupt requests.

vpit
The virtual timer device.

vcmos
The virtual CMOS device.

vdma
The virtual DMA controller.

vbios
The virtual BIOS.

This basically means that every virtual machine initialisation block should include the following lines near its start.

vmvxd vpic
vmvxd vpit
vmvxd vcmos
vmvxd vdma
vmvxd vbios

Virtual IDE Device

This virtual device (stored in the vide module) emulates a standard IDE hard disk controller with a single hard disk.

When installing this virtual device in a virtual machine the module must be told how to virtualise the disk, this can either be done with a file in the system's filing system (see section The Filing System) or by using all of a partition on a physical hard disk (note that using the partition representing the whole of a hard disk can allow a virtual machine to see the same hard disk as the physical machine does).

The shell command to install a virtual IDE controller in a virtual machine has the format:

vmvxd vide disk [blocks]

where disk specifies the object to use to virtualise the disk, either the name of a file, or a string ending in a colon (`:') specifying a hard disk partition. The optional parameter blocks is only necessary when disk specifies a file; it defines the maximum number of blocks to give the virtual disk. When this parameters is omitted the device uses the size of the file or partition instead.

From the maximum number of blocks, the device manufactures a plausible geometry for the virtual disk. If the disk is a physical hard disk (i.e. `hda:') the geometry of the physical disk will be used instead (this guarantees compatibility with data already on the disk).

Example commands to install the Virtual IDE device could be:

# Create a file-based 20 meg. virtual disk.
vmvxd vide /usr/hd-image 40960

# Use the system's physical disk.
vmvxd vide hda:

# File-based, using the current size of the
# file to provide the size of the disk.
vmvxd vide /images/dos-hd.image

After installing a virtual IDE device the virtual machine will be able to use it in exactly the same way as a normal computer uses its hard disk.

Virtual Floppy Device

The vfloppy Virtual Device driver provides BIOS level support for a single floppy drive in a virtual machine.

The virtualisation presently allows for the user to start a machine with a floppy drive mapped to a specified file. All access to that file will be converted to references into that file, the file normally being the image of a physical disk.

Use the vmvxd command (see section Launching Virtual Machines) to install the vfloppy virtual device into the current virtual machine context. The command format is:

vmvxd vfloppy [file]

It opens the file file and all access in the virtual machine, via the BIOS, to the floppy drive will be mirrored in the specified file.

If file isn't specified, the device will be added to the virtual machine, but it won't open any file. The file can later be specified with the vdisk command.

Command: vdisk pid [file]

The vdisk command specifies the file to which all floppy disk access in the virtual machine pid will be mirrored into.

If no file is specified, then any currently open file is closed. If a file was already open, then it is closed prior to opening of the specified file.

Virtual Printer Device

The vprinter virtual device creates virtual printer ports for a virtual machine. This allows printing from the virtual machine via the printer spooler.

Use the vmvxd command to add a virtual printer device to the virtual machine being initialised (see section Launching Virtual Machines). The command format is:

vmvxd vprinter addr...

Each addr parameter (there may be up to four in all) specifies the base address of one printer port in hexadecimal notation. This allows each virtual machine to have up to four printer ports. The standard printer port address are 278, 378 and 3BC.

Example Virtual Machines

This section contains several example blocks of commands to define and start virtual machines.

# Start the initialisation block for a VM with
# 2 megabytes of memory and a CGA display.
vminit 2048 CGA

  # Give it virtual PIC, PIT, DMA, CMOS and BIOS devices,
  vmvxd vpic
  vmvxd vpit
  vmvxd vdma
  vmvxd vcmos
  vmvxd vbios

  # a virtual IDE disk,
  vmvxd vide /usr/dos-hd.image

  # and a virtual printer.
  vmvxd vprinter 0x278

# Now launch the new machine.
vmlaunch

The following example shows how you can get a virtual machine to boot from one of the host system's physical hard disks.

vminit 1024 CGA
  vmvxd vpic
  vmvxd vpit
  vmvxd vdma
  vmvxd vcmos
  vmvxd vbios

  # Use device `hda' as the virtual disk; this is the first IDE
  # hard disk.
  vmvxd vide hda:
vmlaunch

Go to the previous, next section.