An Introduction to Xen/Linux-based Assignments

Note: To work on the Xen/Linux assignment track, you must have explicit permission from the instructor. This is now the third time we have the assignment track and we are still improving our quite limited experience. To work on this assignment track,

If you are an undergraduate student and you have the instructor's permission to work on this project, you need to apply for an account in the research (graduate students and faculty) network.

The managing TA for all Xen/Linux track assignments is Hemayet Hossain (hossain@cs). All email inquiries about these assignment should be addressed to the TA and cc the instructor.

Acquiring and building your OS

In the Xen/Linux track assignments, you are required to modify a customized Linux kernel designed to run on the Xen virtual machine, developed at the University of Cambridge, England. We have installed Xen on the following machines: canberra.cs.rochester.edu. Note that this machine is in the research (graduate students and faculty) network and you cannot access it directly from the csug network.

You will get an account and password on canberra from the TA. The account will be called team1, team2, or ... Once you log into canberra, you can obtain the original version of your kernel by copying from /kernel/kernel.tgz. You can first unpack it by typing "gunzip -c kernel.tgz | tar xf -". There are actually two customized Linux kernels in this distribution. One is the U (unprivileged) kernel and the other is the 0 (system) kernel. We will be working with the U kernel. A 0 kernel also doubles as a virtual machine monitor. In case you wonder, the kernel runs on the canberra hardware machine is a 0 kernel. These kernels have been customized for use with Xen.

There are several subdirectories in the unpacked distribution. For the purpose of this course, you only need to worry about the subdirectory kernel/linux-2.6.10-xenU. There is still a lot of stuff inside this subdirectory. The truth is that this is a slightly modified Linux kernel. Within each assignment, we will try to be very specific about what files you need to be familiar with and modify.

We have created a top-level makefile. To use our makefile you may type the following commands:

Note that you do not have to build the kernel on canberra. In fact it would be a good idea to build it somewhere else because it would free up CPU for other teams running their kernels here. Also, the hard drive on canberra is not backed up. So it is better to develop your kernel on a more reliable storage partition. However, we should warn you that you need around 800MB for the development. First check the available space before settling on a kernel development environment.

Running your OS in the Xen virtual machine

After building your kernel, the product kernelU will be placed in the top-level directory. Now you are ready to run it in the Xen virtual machine. First you need to move it to your canberra account's home directory, because the default domain configuration expects it in this location. You may, of course, change the domain configuration, which we will talk about shortly. By the way, a "domain" is the Xen terminology for an individual virtual machine.

Before running your kernel, you also need to set up a disk image, a swap space image and the domain configuration. Both the disk image and the swap space image are actually files on the host system, but your kernel will consider them as a disk and the swap space. You can acquire a bootable initial disk image and the swap space image by copying from /kernel/disk-image and /kernel/swap-image. An example Xen domain configuration file is located at /kernel/xen.config on canberra. You need to make your copy of this file and replace "team?" (several occasions) in it with your actual team id. When you get more familiar with the system later, you may try to adjust configurations in this file.

Now you are ready to create your domain (the Xen jargon for a virtual machine). Type the following to create a domain: "xm create xen.config -c". You will find that the new domain is automatically attached to your console (this is actually the effect of the -c option). From now on, we will differentiate two types of consoles: the domain console that is attached to a specific domain, and the command console on the native OS. The default root password for the domains can be found in the file /kernel/readme on canberra. The first time you boot, you might find the boot process "hangs" on occasions ("sendmail", etc). Be patient, it is just timing out on network problems. This is because the domain IP address has not been set properly. Each of the teams will get an IP address from the TA. You need to set the IP address in the domain specification file xen.config. You also need to set it in the network configuration file inside your domain /etc/sysconfig/network-scripts/ifcfg-eth0. You should find that the existing IP address setup in both places is a dummy "1.2.3.4", which surely wouldn't work.

You may want to destroy your domain when you are done for the day or you need to put up a new kernel. You can do so by running "shutdown -h now" or "reboot" in a domain console. You need to be root in the domain console to do this. When your kernel hangs or it does not boot at all, you need a more radical way to destroy it. You can do so by typing: "xm destroy domain-name" in a command console. In the default domain configuration, your domain name should be the same as your team name. Note that we do not have a mechanism to disallow you from destroying other teams' domains. So please do not destroy other other teams' domains when calling "xm destroy". If you accidentally did it, please notify the affected team immediately, who might be suspecting a bug in their kernel.

It would be a courtesy to others if you destroy your domain when you are not working on it. Remember that all teams are sharing one computer (canberra). If you want to get a list of domains currently running at any time, you may type: "xm list" in a command console. This is for the case in which you either forget if you have created a domain while buying a soda or want to spy on other teams.

Need help?

For more information about Xen, you can visit their website. For basic help on running Xen commands, you can type xm help in a command console. Of course, you can ask help by emailing the TA and the instructor. At the same time, we would like to encourage you to help out each other.