Section 10.7. Installing Xen Virtual Machines


10.7. Installing Xen Virtual Machines

Xen is a technology that permits one physical computer to act as two or more virtual machines (or domains). Each domain is isolated from other domains, so administration privilege can be safely delegated; you can designate a system administrator for one domain and give him the root password for total control of that system, confident that he will not be able to touch the configuration of other domains.

Virtualization technology is also very helpful when testing multiple software versions or configurations, and since virtual machines can be migrated between physical systems, it provides a lot of flexibility for server deployment and management.

To use Xen, you must install a special kernel and utilities on your existing Fedora system, which then becomes your primary domain (Domain-0). You can then install Fedora on as many additional domains as you want.

10.7.1. How Do I Do That?

To set up for Xen, install the kernel-xen and xen packages using Pirut or this command:

# yum -y install kernel-xen xen             

Reboot your system. When the GRUB boot screen appears, press the spacebar to display the boot menu. Select the new xen kernel using the cursor keys, and then press Enter to boot.

To make your system boot the Xen kernel by default, edit /boot/grub/grub.conf (see Lab 10.5, "Configuring the GRUB Bootloader")


You can confirm that you are running the Xen kernel by using the uname command:

# uname -r 2.6.17-1.2564.fc6xen

The xend service should also be running, which you can confirm using the service command:

# service xend status service xend is running

The Fedora installation that you are using is Domain-0, the master domain. Additional virtual machines, called guest domains, must be installed from a network installation server. If you do not have one, you can quickly set up one within Domain-0 by inserting a Fedora Core DVD and typing:

# yum -y install httpd ...(Lines snipped)... # setenforce 0 # ln -s /media/disk /var/www/html/fedora # service httpd start Starting httpd:                                        [ OK ]

The setenforce command just shown disables SELinux protection for your system, which presents a security risk. Re-enable SELinux as soon as you are finished using the network installation server:

# setenforce 1                


To start the guest domain installation:

# xenguest-install What is the name of your virtual machine? fedora How much RAM should be allocated (in megabytes)?  256 What would you like to use as the disk (path)?  /var/xen/fedora How large would you like the disk to be (in gigabytes)?  2 Would you like to enable graphics support (yes or no)  no What is the install location?  http://192.168.2.48/fedora

The name of the virtual machine can be any value that meets the requirements for a filename. The disk path and size requested are used to set up a file that will act as the hard disk for the guest domain. The install location is the URL of the network installation server; if you're using an HTTP server on Domain-0, use the full IP address of that system instead of the loopback address 127.0.0.1 (since, inside a guest domain, the loopback destination is the guest domain itself, not Domain-0).

A regular Fedora installation will now start in text mode within the guest domain. After prompting you for the language and keyboard, the installer will give you the option of continuing with a text mode installation or using VNC for a graphical installation, as shown in Figure 10-29.

Figure 10-29. Text mode and VNC installation options


This message indicates that the installer was unable to start X. This is normal, since the guest domain does not have a video card.


Choose one of the two options:

  • To continue in text mode, press Enter.

  • To use VNC, press Tab, and then press Enter. The installer will prompt you to create a VNC password and will then start a VNC server. This message will be displayed on the screen:

  • Starting VNC... The VNC server is now running. Please connect to 192.168.2.112:1 to begin the install... Starting graphical installation... Press <enter> for a shell

  • Use the vncviewer program to connect to the indicated address and port:

  • $ vncviewer 192.168.2.112:1

  • A window will appear showing the normal Fedora graphical installation display.

You can then proceed with a regular Fedora installation into the guest domain. When the installation is finished, you can start your guest domain with this command:

# xm create fedora Using config file "/etc/xen/fedora". Going to boot Fedora Core (2.6.17-1.2517.fc6xen)   kernel: /vmlinuz-2.6.17-1.2517.fc6xen   initrd: /initrd-2.6.17-1.2517.fc6xen Started domain fedora

This will boot the guest domain. You can view the current domains using xm list :

# xm list Name                                    ID Mem(MiB) VCPUs State  Time(s) Domain-0                                 0      510    2  r-----  247.8 fedora                                   5      256    1  -b----    9.5

This display shows that the domains Domain-0 and fedora are both running, and displays the domain ID number, memory, virtual CPUs, and CPU usage in seconds for each domain.

So what's going on in the guest domain? Good question! You can see the guest console by using xm console:

# xm console fedora

The first time your guest domain boots, you will see a text version of the firstboot configuration.

To start a guest domain and connect to its console immediately, use xm create with the -c (console) option:

# xm create -c fedora


After the first boot, you may find it just as easy to use SSH to connect to the guest domain as though it were a remote server:

$ ssh -X  192.168.2.112

The -XC option enables the remote display of X clients, so that you can use graphical administration tools such as system-config-printer within the guest domain and display the window on your Domain-0 screen.

To shut down a guest domain, either initiate a shutdown within the domain (for example, by executing the shutdown command), or use the xm shutdown command in Domain-0:

# xm shutdown fedora

The shutdown will take up to a few minutes, just like the shutdown of a physical system. If a guest domain is stuck in an unrecoverable state, you can forcefully stop it (although this is the equivalent of turning off the power on the virtual machine, so it may result in data loss):

# xm destroy fedora

10.7.2. How Does It Work?

Xen boots a small program called a hypervisor before booting Domain-0. The hypervisor masks the underlying hardware and presents a modified virtual environment to each domain. Domain-0 has direct access to certain hardware, such as network interface cards and other peripherals, and the standard device drivers are used to access those devices.

Inside Domain-0, a service daemon named xend provides monitoring and control functions for the guest domains and communication between the guest domains and certain types of hardware (such as network interfaces).

The Xen environment is different from the normal PC environment, and the operating system must be modified to run in this special environment; this is called paravirtualization because it requires some cooperation on the part of the guest operating system. The advantage to this approach is higher performance and the ability to control the guest operating system in certain ways (such as sending the guest OS a shutdown message when xm shutdown is used).

Xen is developed as an open source project; XenSource is a company formed by the original Xen researchers to offer an enhanced, commercially supported version of Xen.

The Fedora Xen guest installation tool, xenguest-install, is a Python script that interfaces with Fedora's Anaconda system and python libraries. The configuration files generated by xenguest-install are stored in /etc/xen.

10.7.3. What About...

10.7.3.1. ...starting Xen guest domains automatically at boot time?

Xen configuration files created with xenguest-install are installed in /etc/xen, and the filenames match the guest domain names. If these files are symlinked to the /etc/xen/auto directory, they will be started automatically at boot time by the xendomains service.

For example, to start the fedora guest domain automatically at each boot, link its configuration file using ln -s:

# ln -s /etc/xen/fedora /etc/xen/auto                

10.7.3.2. ...hardware support for virtualization?

CPU makers are starting to build support for virtualization into their CPUs. AMD's technology is named Pacifica, while Intel's is named VT-X. Xen can take advantage of either technology to boost performance and to provide full virtualization to unmodified operating systems.

10.7.3.3. ...using other network or storage configurations?

Xen is very configurable, but the Fedora Xen guest installation script handles only a small subset of the possibilities. To use alternate configurations it is necessary to manually edit the configuration files in /etc/xen (see the Xen documentation and the sample configuration files in /etc/xen for details).

10.7.3.4. ...booting other operating systems?

It is possible to install other Linux distributions and (soon) other operating systems into guest domains, but they must be installed manually; Fedora's Xen installer only works with Fedora Core at this point. For information on installing other Xen guests, see the XenSource web site (http://www.xensource.com) and the documentation for the Xen guest you wish to install.

Microsoft Windows and other unmodified operating systems can be used as Xen guests only with hardware virtualization support.

10.7.3.5. ...monitoring the resource usage and activity of Xen domains?

Xen provides the xentop tool for domain monitoring, shown in Figure 10-30. As the name implies, it provides a top-like display of domain activity, updated every three seconds.

Figure 10-30. Xentop display


Fedora Core also includes the Virtual Machine Manager (virt-manager) application, but the version released with Fedora Core 6 is at a very early stage of development. It is designed to provide an effective way of managing virtual machines through a graphical user interface; you can follow development on the fedora-xen list (see Lab 9.1, "Participating in the Fedora Mailing Lists").

10.7.4. Where Can I Learn More?

  • The Fedora Virtualization Project: http://fedora.redhat.com/projects/virtualization/

  • The XenSource web site: http://www.xensource.com/

  • The Xen Wiki: http://wiki.xensource.com/xenwiki/




Fedora Linux
Fedora Linux: A Complete Guide to Red Hats Community Distribution
ISBN: 0596526822
EAN: 2147483647
Year: 2006
Pages: 115
Authors: Chris Tyler

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net