This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: System Administration

Lguest: A simple virtualization platform for Linux

By M. Shuaib Khan on February 20, 2008 (4:00:00 PM)

Share    Print    Comments   

The Linux kernel has merged three hypervisors into its mainline tree, starting with KVM in 2.6.20, and continuing with Xen and lguest in the 2.6.23 release of the kernel. Hypervisors let users run multiple operating systems on a host system. Lguest is the simplest of the three in terms of usability and implementation, which makes it a good candidate for helping you learn how virtualization works.

Lguest is still relatively new software, and lacks some of the advance features of other mature virtualization platforms for Linux. It comprises two main parts: a kernel module and a client launcher. You can virtualize only another Linux guest on top of the Linux host, using the lguest launcher, and both must be running the same kernel version. Lguest lacks support for X output from guest OSes, and lacks the VM migration facilities, which let you move your guest OS to another instance of the hypervisor on a different machine across a network. But despite such significant drawbacks, lguest does have its uses, such as checking your kernel under different configurations without actually rebooting the system.

With a small code base of around 6,000 lines of code, the project offers tremendous opportunity for new kernel hackers and virtualization machine monitor developers to learn about the workings of a simple hypervisor. Also, since lguest lacks features that other hypervisors already have, it offers low-hanging fruit in terms of functionality implementation for developers in order to get their code into the mainline kernel.

Using lguest

Lguest is a paravirtualization hypervisor, which means you have to modify the guest kernel in order to let it know that it is being run in a virtualized environment, so that it won't try to access the resources of the system in an unauthorized way.

To use lguest, make sure you have the following options enabled in both your host and guest kernel configuration. It is easiest to use the same kernel as host and guest.

  • CONFIG_HIGHMEM64G=n -- lguest might have problems with high memory support, so this is best disabled.
  • CONFIG_TUN=y/m -- Universal TUN/TAP device driver support. "y" builds it into the kernel, while "m" builds it as a loadable module.
  • CONFIG_EXPERIMENTAL=y -- Prompt for development and/or incomplete code and drivers. Setting this to "y" makes sure you are asked about the option below.
  • CONFIG_PARAVIRT=y -- The paravirtualization code in the kernel has an experimental status, but you need it in order to work with lguest.
  • CONFIG_LGUEST=y/m -- Builds the Linux hypervisor example code into the kernel or as a loadable module. Gets you the lg module, which is the core of lguest.
  • CONFIG_LGUEST_GUEST=y -- lguest guest support.

Recompile your kernel, boot with it, and if you chose "m" instead of "y" in any of the kernel configuration options, make sure you install the modules using make modules_install.

The launcher program lguest.c is located in the kernel source tree at Documentation/lguest/lguest.c, and is used to set and configure the guest kernels. Use make in this directory to build it.

Lguest can't boot up a bootable CD or DVD and let you install a complete Linux distribution along with its X Window environment. You must install a Linux distribution on another primary partition on a hard drive, or using QEMU, after which you can use lguest to launch multiple instances of the second distribution in a virtualized environment.

To launch the guest kernel, run the following command from the Documentation/lguest directory of the kernel source tree:

./lguest 64m ../../vmlinux --block=rootfile root=/dev/lgba

Here, 64m specifies the amount of memory to use for the guest. ../../vmlinux is the kernel image found in the top of the build directory. rootfile is the file or block device which should become /dev/lgba in the guest's environment. This should either be the image which was installed using QEMU, or a primary partition on which your guest Linux distribution is installed. Finally, /dev/lgba is passed as a boot parameter to the guest kernel, telling it to use /dev/lgba as the root device.

If all goes well, you will be greeted by getty to log in to your guest OS.

Lguest's documentation

There is just one README file in the drivers/lguest/ directory. At the end of the README file is a hint for lguest hackers. If you pay attention to the last two lines in this file, you'll notice it says, "make Preparation!" and there is a make target for "Preparation." Running make Preparation in the directory gives you the documentation from within the lguest source files and dumps it to the output console. This documentation takes you from first steps to the deep down inner details of the working of lguest.

Lguest is not an appropriate virtualization platform for business or scientific needs yet. It has a long way to go in terms of features and support for multiple guest platforms. But it does provide an excellent opportunity to you to play with hypervisors; how they work, what makes them tick. You are even welcome to fork lguest and make it into a fully blown hypervisor of your own.

Share    Print    Comments   

Comments

on Lguest: A simple virtualization platform for Linux

Note: Comments are owned by the poster. We are not responsible for their content.

Very neat!

Posted by: Anonymous [ip: 169.233.25.59] on February 20, 2008 05:53 PM
It's interesting to see so much innovation in the Linux arena :)

#

Lguest: A simple virtualization platform for Linux

Posted by: Anonymous [ip: 137.99.92.242] on February 20, 2008 09:52 PM
just a slight correction: xen support does not include the hypervisor, just support for guest VMs (in .23) and some very basic host support in .24/.25. -- steve maresca

#

Poor Article

Posted by: Anonymous [ip: 141.85.0.113] on February 21, 2008 12:17 AM
The website of I guest was probably set up in less than an hour and provides the same amount of info as this article.

#

User Mode Linux

Posted by: Anonymous [ip: 129.240.235.122] on February 21, 2008 02:36 PM
What's the difference between this and User Mode Linux?

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya