ENTERPRISE

Xen Virtualization : Installing Xen from Source

2/20/2012 5:49:40 PM
In the previous section we installed Xen using binary packages. It was quite simple and quick, and enabled us to get Xen running easily especially because the hard job of matching the hypervisor/host/guest kernel options was done by RedHat. However, this means that you depend on the Xen pre-built packages, keeping up with the changes taking place in Xen, which is a fast moving target with bug fixes and features. You cannot take advantage of a brand new feature or a bug fix that was added recently and which is quite crucial for your use. The binary packages usually track the release versions of Xen, so there is no way for you to try out the development versions or the pre-release versions. Here are some reasons why you should get comfortable building Xen from the source code in the Xen revision control repository hosted by Xensourc ( http://xenbits.xensource.com/):
  • You can access the latest bug fixes or new features immediately.

  • You can experiment with Xen to learn how it works.

  • You can extend and build products on top of Xen.

  • You can share the bug fixes or improvements you made with the Xen community.

  • You can create customized versions of Xen to use within your enterprise or as a commercial product.

In this section we are going to get the latest source code for the next pre-release version of Xen and build it from scratch. We will then install it on our base Fedora system and use it.

Time for Action—Compile Xen

We are going to retrieve the source code, install all the required dependencies, compile the source and, finally, install it on our Fedora Core 6 system.

  1. Create a directory that will be used to store the Xen source files and change to this new directory.

    mkdir ~/xen-sourcecd ~/xen-source
  2. Xen source is stored in a Mercurial revision control repository. You will need to install the mercurial client that can be used for checking out the source code. Use yum to install mercurial.

    yum install mercurial

    Now we are going to checkout the latest version of the Xen source files. There are several different versions of Xen in the mercurial repository:

    xen-3.0.4-testing.hg: pre-release of the next 3.0.4 version of Xen

    xen-3.0.3-testing.hg: pre-release of the next 3.0.3 version of Xen

    xen-3.0.2-testing.hg: pre-release of the next 3.0.2 version of Xen

    xen-2.0-testing.hg: pre-release of the next 2.0 version of Xen

    We will be using the 3.0.4 version of Xen in this article. Use the mercurial client (hg) to check out the source:

  3. This will create a directory named xen-3.0.4-testing.hg under the xen-source directory and populate it with the source. The following screenshot shows a listing of the files and directories in it.

    We are ready to compile Xen. We need to install the pre-requisite packages that provide the compiler, libraries, and development headers required for setting up a Xen development environment. Here are the packages that need to be installed on a Fedora Core 6 machine. If you have already compiled C code on your machine, you may have some of these installed.

    • gcc: Contains the GNU Compiler Collection version 4.0 and is needed for compiling C code.

    • glibc-devel: Contains the object files necessary for developing programs, which use the standard C libraries.

    • libgomp: Contains GCC shared support library, which is needed for OpenMP 2.5 support.

    • glibc-headers: Contains the header files necessary for developing programs, which use the standard C libraries.

    • ncurses-devel: The header files and libraries for developing applications that use the ncurses terminal handling library.

    • openssl-devel: Contains static libraries and include files needed to develop applications that support various cryptographic algorithms and protocols.

    • zlib-devel: Contains the header files and libraries needed to develop programs that use the zlib compression and decompression library.

    • xorg-X11-proto-devel: Contains all necessary include files and libraries needed to develop X11 applications.

    • python-devel: Contains the header files and libraries needed to develop Python extensions.

    • tetex-latex: Contains the LaTeX front end for the TeX text formatting system that is used for producing the documentation for Xen.

    • xen-devel: Contains the libraries and header files that are needed for compiling Xen from source.

      Install these packages using yum:

      yum install gcc glibc-devel xen-devel libgomp glibc-headersncurses-devel openssl-devel zlib-devel xorg-X11-proto-devel
      python-devel tetex-latex



  4. The first step before we compile the kernel is to configure it. The following command will bring up the familiar Linux kernel configuration dialog. Accept the defaults unless you need to make changes to add support for some drivers or other options. Exit the dialog and save the changes when asked.

    make linux-2.6-xen0-config
  5. Compile the kernel and the modules.

    make linux-2.6-xen0-build
  6. The above command will compile and install the various artifacts from the build into the dist/install directory.

    The boot directory contains the configuration used for this Xen kernel, the kernel image, and the kernel debugging symbols files.

    The lib directory contains all the kernel modules and drivers.

  7. Install these artifacts on to your system by running the following command as root. This will install the kernel modules and copy the kernel image and symbol files to /boot.

    make linux-2.6-xen0-install

    Following are the files in the /boot directory after running the above command.

  8. Run depmod to create a list of module dependencies by reading each module under /lib/modules/2.6.16.38-xen0 and to determine what symbols it exports, and what symbols it needs

    depmod -a 2.6.16.38-xen0
  9. Create the initrd in the boot dir that will be used by the Xen kernel while booting.

    Compile and install the various Xen tools, libraries and Python modules. Please make sure that you don't have the Xen tools binary package installed before doing this.

    make install KERNELS="linux-2.6-xen0"
  10. Modify grub to add an entry for booting this new Xen kernel.

  11. Reboot into your new Xen system!

  12. Check to make sure that everything started up fine.

  13. Check the network interfaces to make sure they are all up and running.

You have successfully compiled and installed the development version of Xen in your machine and are now running it.

What Just Happened?

The source code for Xen is stored in a mercurial repository that is hosted at http://xenbits.xensource.com. This is a public repository and contains the source code for the open-source version of Xen. The code is tagged with different versions for the stable and development versions. The stable released versions are usually the ones that are available as pre-built packages. In the previous section we used the pre-built packages for Xen 3.0.4 provided by Fedora Core 6. However, there is a new pre-release version of Xen that has several bug fixes and enhancements. It would be nice to use this or any other version of Xen for that matter, without depending on a pre-built package of Xen. We first installed the mercurial client used for retrieving the source. We also installed all the pre-requisites for compiling C code including the gcc compiler collection. You may already have some of these packages if you have ever compiled C code on your system. Also, there are some libraries such as openssl and zlib that are needed to compile Xen.

The Makefile provided with the Xen distribution has several pre-defined targets that we can use for compiling Xen. the following were used in this section:

  • linux-2.6-xen0-config: This target is used for configuring the dom0 kernel. The default will configure the linux kernel using the familiar menuconfig option that brings up a ncurses dialog based configuration utility. You can configure the various options to fine tune the dom0 kernel to your specifications. You can also select a different interface for configuration. Running this target for the first time will download linux-2.6.16.38 from http://kernel.org to the current directory. This unmodified kernel is referred to as a pristine kernel. It is downloaded and stored locally in a directory called pristine-linux and is also archived to a bzip file. A dom0 directory named linux-2.6.16.38-xen0 is created, Xen patches are then applied to the pristine kernel in this directory to create the dom0 kernel. This is the kernel that is configured when we run this target. If you are new to Linux kernel configuration the following resources will be useful:

  • linux-2.6-xen0-build: This target compiles the kernel and the modules using the configuration from the previous step. The compiled kernel and modules are installed into a dist/install directory created within the current directory.

  • linux-2.6-xen0-install: This target will take everything from the dist/install directory and install it on to the local system. The kernel and the kernel configuration file are copied to the /boot directory along with the kernel symbols file that is helpful for debugging. In order to do this you must have administrative privileges. So either use sudo or become the super user by using su before you execute this target.

  • install KERNELS="linux-2.6-xen0": This target will compile the Xen libraries and Python modules and install them on to the system. Once again you will need administrative privileges in order to do this.

We have installed most of the things needed to run the pre-release version of Xen. After the compilation, we also created an initrd image that can be used for booting. This was automatically installed for us when we installed Xen using a pre-built package. Since we compiled the kernel ourselves in this section, we created the initrd image by using the mkinitrd command. Finally we added an entry to the /boot/grub/grub.conf

Other  
  •  Xen Virtualization : Installing Xen from Binary Packages
  •  Introducing IBM BPM and ESB : IBM SOA Reference Architecture & Introducing IBM WebSphere Process Server
  •  Introducing IBM BPM and ESB : Achieving success through BPM enabled by SOA
  •  Separating BPM and SOA Processes : Example-Process for Handling Credit Card Disputes
  •  Separating BPM and SOA Processes : The Model Stack & Design Tips on Separating BPM and SOA
  •  BizTalk 2006 : Editing and Resubmitting Suspended Messages (part 2) - Pseudo-Walkthrough to Perform Edits and Resubmits
  •  BizTalk 2006 : Editing and Resubmitting Suspended Messages (part 1)
  •  BizTalk 2006 : Building a Resequencing Aggregator
  •  Windows System Programming : Listing Registry Keys and Contents
  •  Windows System Programming : Registry Management
  •  .NET Debugging : PowerDbg (part 2) - Send-PowerDbgCommand & Extending PowerDbg
  •  .NET Debugging : PowerDbg (part 1) - Installing PowerDbg & Analyze-PowerDbgThreads
  •  Sharepoint 2010 : Business Connectivity Services Deployment Types (part 3) - Configure Indexing & Performing a Search
  •  Sharepoint 2010 : Business Connectivity Services Deployment Types (part 2) - Creating a Profile Page to Display BCS Results
  •  Sharepoint 2010 : Business Connectivity Services Deployment Types (part 1) - Code-Based Solutions
  •  Sharepoint 2010 : BCS Architecture - Presentation & Core Components
  •  Collaborating via Web-Based Communication Tools : Evaluating Instant Messaging Services
  •  Collaborating via Web-Based Communication Tools : Evaluating Web Mail Services
  •  Developing the SAP Data Center : Data Center Physical Requirements
  •  Developing the SAP Data Center : Introducing the SAP Data Center
  •  
    Top 10
    Windows Vista : Installing and Running Applications - Launching Applications
    Windows Vista : Installing and Running Applications - Applications and the Registry, Understanding Application Compatibility
    Windows Vista : Installing and Running Applications - Practicing Safe Setups
    Windows Server 2003 : Domain Name System - Command-Line Utilities
    Microsoft .NET : Design Principles and Patterns - From Principles to Patterns (part 2)
    Microsoft .NET : Design Principles and Patterns - From Principles to Patterns (part 1)
    Brother MFC-J4510DW - An Innovative All-In-One A3 Printer
    Computer Planet I7 Extreme Gaming PC
    All We Need To Know About Green Computing (Part 4)
    All We Need To Know About Green Computing (Part 3)
    Most View
    Droid Support - DSLR effects are possible within the Android OS (Part 4)
    Silverlight : Play a Video
    Amiga – Mixing It Up
    Polywell H7700i-400B - Desktop Power In A Tiny Box
    BlackBerry Java Application Development : installing other JDE component packages over-the-air
    Tag The Location Of Your Photographs
    Defensive Database Programming with SQL Server: The Ticket-Tracking System (part 1) - Enforcing business rules using constraints only
    Fujitsu Stylistic Q552
    Toshiba Satellite C840 Review (Part 1)
    D-Link Cloud Router 5700 With 1750Mbps Total Band
    Graphics Cards for All Budgets (Part 3) - Radeon HD 7950, GeForce GTX 580, GeForce GTX670
    Share and stream media (Part 1) - Windows and NAS sharing
    Personalizing Windows 8 : Choosing Your Language
    How To Find The BEST DEALS (Part 1)
    Business Intelligence in SharePoint 2010 with Business Connectivity Services : External Content Types (part 1)
    All the stuff you didn't know (Part 3)
    Java Mobile Edition Security : Permissions and User Controls
    Windows 8 Special (Part 4)
    Sony Xperia S
    Armaggeddon Mikoyan Foxbat, Shteelseries Sensei Major League Gaming Edition, Logitech G600