Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1292201
  • 博文数量: 196
  • 博客积分: 4141
  • 博客等级: 中将
  • 技术积分: 2253
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-21 20:04
文章存档

2019年(31)

2016年(1)

2014年(16)

2011年(8)

2010年(25)

2009年(115)

分类: 虚拟化

2009-03-22 15:05:46

Lguest: A simple virtualization platform for Linux

By on February 20, 2008 (4:00:00 PM)

The Linux kernel has merged three hypervisors into its mainline tree, starting with in 2.6.20, and continuing with and 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

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.


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.


阅读(2009) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~