All the major Linux distributions such as Red Hat,
Debian, Ubuntu, SuSe, and Gentoo ship some form of support for using Xen
virtualization. In most cases they provide easy to install binary
packages in the packaging format used by the specific distributions.
This is the easiest and quickest way to get up and running with Xen.
will run other operating systems in virtual machines inside it. The package manager used by Fedora is named yum. If you are new to yum and have not used it before, please refer to the Fedora yum manual at http://fedora.redhat.com/docs/yum/en/. We will use yum
to install Xen from the pre‑built packages provided by Red Hat. It will
install the Xen kernel used by Domain0, the libraries, Python modules,
and user space tools used for interacting with Xen.
Time for Action—Installing Xen with yum
yum makes installing Xen in your Fedora Core 6 system a breeze. The following steps are needed to get Xen running:
Install the Xen kernel and tools by running the following command:
yum install kernel-xen xen
This will download and install the following packages and their dependencies:
kernel-xen: Contains the Xen enabled kernel for both the host and guest operating systems as well as the hypervisor.
xen: Contains the user-space tools for interacting with the hypervisor.
bridge-utils: Utilities for configuring the Ethernet bridge that is used for connecting multiple Ethernet devices together.
libvirt: A C library that provides an API to use the Xen framework.
libvirt-python: Contains a Python module that let's Python applications to use the API to the Xen framework provided by libvirt.
python-virtinst:
Contains a Python module that uses libvirt for starting installations
of Fedora/Red Hat Enterprise Linux related distributions inside virtual
machines.
xen-libs: Contains the libraries needed to run applications to manage Xen.
Fedora Core 6 uses grub as the bootloader. Installation of the Xen packages from the previous step will add an entry to the /boot/grub/grub.conf file for booting the Xen kernel. This is what the grub.conf looks after the installation.
However, Xen kernel is not set as the default boot option. Modify /boot/grub/grub.conf and change the value default=1 to default=0.
This will change the default kernel used for booting to the Xen kernel
instead of the default Fedora kernel. You will need to be the root or a
user with administrative privileges in order to do this.
Reboot to start using this kernel.
Once the machine is up and running, check the version of the running kernel to ensure that you are running the Xen kernel.
The management of domains is done by xend—the Xen Controller daemon. It can be started and stopped using the /etc/rc.d/init.d/xend script and is started up by Fedora Core 6 automatically on boot. Check to make sure that xend is running by executing the following command to search the list of processes running on the system:
Once xend
is running, it will start Domain0, which is the privileged domain.
Check to see that Domain0 has been created and is up and running by
using the xm command.
Check to see that all the network interfaces are up. This will include the normal network interfaces such as eth0 and lo, and the Xen related interfaces. The name of the network interface peth0 that we can see in the following screenshot has changed to eth0 in the newer versions of Fedora 7.0 and above.
What Just Happened?
We used yum to install the following:
The
configuration for grub was modified automatically by the installation to
add an entry for booting the Xen hypervisor and the dom0 kernel. Let us
examine each line that was added as it will give a good insight into
the process of what happens when a Xen system boots up. Here is the
section that was added for the Xen kernel in the /boot/grub/grub.conf (Line numbers have been added and are not actually present in the file):
1. title Fedora Core (2.6.19-1.2911.6.5.fc6xen)2. root (hd0,1)
3. kernel /xen.gz-2.6.19-1.2911.6.5.fc6
4. module /vmlinuz-2.6.19-1.2911.6.5.fc6xen ro root=/dev/VolGroup00/ LogVol00 rhgb quiet
5. module /initrd-2.6.19-1.2911.6.5.fc6xen.img
Line 1 defines the title for this kernel and is displayed in the grub menu on boot, which allows you to select a kernel.
Line 2 defines the root partition that will be used for booting up.
Line 3 specifies the
kernel that is to be used for booting. In Xen this specifies the Xen
hypervisor and not the dom0 kernel. When a normal Linux is booted, the
kernel option refers to an actual Linux kernel.
Line 4 specifies the kernel
that is used for booting up the privileged dom0, the root option
specifies the partition that holds the root file system, and a few other
options, which are not Xen specific but apply to any Linux kernel.
Line 5 defines the file that contains the initial ram disk image that is
first loaded by the kernel on initialization before it switches over to
using the root file system. This initrd image is only suitable for the host and not for any of the guests.
When the machine boots up, it loads the hypervisor that initializes
Xen. At this stage you will see a lot of messages flash by on the screen
prepended with the text, [XEN]. The Xen hypervisor then boots using the dom0 kernel. The operating system that is used by the dom0 kernel contains an init script that starts up the Xen daemon—xend, which creates and loads dom0.
The dom0 contains the
Xen libraries that provide the API that can be used by client and
userland applications to communicate with the Xen framework. The Python
modules wrap this functionality so that it can be used by applications
written in Python, which is the scripting language used for scripting
Xen. We used one of these tools—xm, the Xend Manager—to check whether any Xen domains were running. xm
is the
main interface provided for managing the various Xen guest domains. It
can be used to create, pause, and shutdown domains. It can also be used,
as we did, to list current domains. Finally we check to make sure that our network interfaces are
up.