特殊:Badtitle/NS100:XenVirtualMachine/XenOnUbuntuBreezy

来自Ubuntu中文
Wikibot留言 | 贡献2007年12月5日 (三) 12:38的版本
跳到导航跳到搜索
可打印版本不再受到支持且可能有渲染错误。请更新您的浏览器书签并改用浏览器默认打印功能。

{{#ifexist: :XenVirtualMachine/XenOnUbuntuBreezy/zh | | {{#ifexist: XenVirtualMachine/XenOnUbuntuBreezy/zh | | {{#ifeq: {{#titleparts:XenVirtualMachine/XenOnUbuntuBreezy|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:XenVirtualMachine/XenOnUbuntuBreezy|1|-1|}} | zh | | }}

This HOWTO-style page describes a manual install of Xen 3.0 on Ubuntu 5.10. Please see XenVirtualMachine for an overview of Xen, or XenOnUbuntuBinaryInstall to use the precompiled kernel from Xen Source. This document is updated from the previous half-complete effort using Xen 2.0 (JackWasey)

Overview

At the moment, installing Xen on Breezy Badger requires installing from source. Making the Xen hypervisor and tools are not strictly necessary; however, we will want to compile the 2.6.12 kernel ourselves in order to stick closely with the kernel Ubuntu expects. This work has been tested on i386 architecture. It is likely that Ubuntu kernel patches and Xen kernel patches will conflict for some configurations and architectures. Please comment this wiki if you have to do anything differently to make it work. The goal is to use the ubuntu-patched kernel as closely as possible, with additional Xen patches.

Requirements

These are the recommended packages to build Xen. Also, Xen does not seem to build with GCC 4.0, so we need an older version. We will need the Ubuntu kernel source in order to make th

  • grub
  • bridge-utils
  • iproute
  • python2.4-twisted-bin
  • libcurl3
  • libcurl3-dev
  • zlib1g
  • zlib1g-dev
  • python2.4-dev
  • make
  • gcc-3.4

Kernel

We will need to use the testing version of Xen, because it supports the 2.6.12 kernel.

  • linux-source-2.6.12
  • kernel-package

I succeeded using xen-testing 3.0.1

Downloading Xen

Go to the download page and get the xen-3.0-testing-src.tgz file and unpack it. The sources can be compiled without root privileges, but they are needed to install the xen kernel.

Make Targets

The Makefile structure of Xen is quite complicated, with various includes. Note that the default build is for Xen developers. For normal use (including drivers for handy things like hard disk controllers and video drivers) the -xen (as opposed to -xen0 or -xenU) build should be used. This can be used as either the privileged (xen0) or unprivileged (xenU) domain. Compiling xen0 or xenU kernels just leaves out large numbers of drivers so that the Xen developers can test more quickly. To specify this, edit the KERNELS target in the toplevel Makefile:

#KERNELS ?= linux-2.6-xen0 linux-2.6-xenU
KERNELS ?= linux-2.6-xen

JackWasey I used the Breezy default GCC 4.0.2 without any problems. For your information, you can run make help to see what the Xen builder can build.

Compiling the Easy Stuff

Xen Hypervisor

Compile the Xen hypervisor by making the "xen" target. Remember to use GCC version 3.4.

# make CC=gcc-3.4 xen

Confirm that the build was successful by showing that the make returned successful.

# echo $?
0

Xen Tools

Compile the Xen tools by making the "tools" target. Remember to use GCC version 3.4.

# make CC=gcc-3.4 tools

Confirm that the build was successful by showing that the make returned successful.

# echo $?
0

Compiling the Kernel

Patching

I run a "make world" to allow the xen scripts to automatically fetch the kernel archive that it wants (seems to be 2.6.12.tar.gz for Xen 3.0.1-testing). If you use a different kernel archive, e.g. ubuntu pre-patched or 2.6.12.xx then the xen patches probably will not apply correctly.

sudo apt-get install linux-patch-ubuntu-2.6.12

package which contains the ubuntu patches against the 2.6.12 kernel. This puts a patch-2.6.12-*.*.bz2 file in /usr/src/linux-patches/i386/2.6.12/debian/. bunzip2 this file. In the unzipped xen source folder, we are interested in the linux-2.6.12-xen tree. in that kernel tree: Note: the above line is not fully clear, at least not to newbies. Can you be more specific with exactly which folder I should be in when I type the following line?

patch -f -p1 < ../patch-2.6.12

This gives quite a few patch errors. I think this is because ubuntu patches overlap with the 2.6.12 -> 2.6.12.6 kernel patches. Many are not for i386, or drivers that I use; they may be a problem for you. Please annotate your solutions here. You need to add a declaration for pcibios_disable_irq() in xen-3.0-testing/linux-2.6.12-xen/arch/xen/i386/pci/irq.c:

--- irq.c.orig  2006-02-23 17:47:38.000000000 +1100
+++ irq.c       2006-02-23 17:48:07.000000000 +1100
@@ -55,6 +55,7 @@
int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
};
+void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
int (*pcibios_enable_irq)(struct pci_dev *dev) = NULL;
/*

You must also correct a patching error against zlib.h. This function is defined twice, and you have to remove one definition. This is the diff I get:

--- include/linux/zlib.h        2006-02-20 11:15:43.000000000 +0000
+++ include/linux/zlib.h.orig   2006-02-20 09:56:33.000000000 +0000
@@ -506,11 +506,6 @@
stream state was inconsistent (such as zalloc or state being NULL).
*/
-/*static inline unsigned long deflateBound(unsigned long s)
-{
-       return s + ((s + 7) >> 3) + ((s + 63) >> 6) + 11;
-} */
-
static inline unsigned long deflateBound(unsigned long s)
{
return s + ((s + 7) >> 3) + ((s + 63) >> 6) + 11;

Config and Compilation

With the patches above, it should compile fine if certain kernel features are disabled. I used the instructions in README in the root of the unzipped xen source. This tells you to use: make linux-2.6-xen-config (from the root of the xen unzip, not the -xen kernel tree) menuconfig is the default, giving the normal ncurses interface for kernel configuration. make linux-2.6-xen-buildis then used to build the -xen kernel, and sudo make linux-2.6-xen-install puts everything apart from initramfs images in place in /boot and /lib/modules/2.6.12.6-xen/. I grepped the default xen config for the string XEN and appended this to the default ubuntu config. (if you ran make world, xen will already have put the default -xen config in place (.config in the linux-2.6.12-xen tree)). from the unzip root (/usr/local/src/xen/ in my case), not the -xen tree root, I did:

mv linux-2.6.12-xen/.config config.xenorig
cp /boot/config-2.6.12-10-k7 linux-2.6.12-xen/.config
grep XEN config.xenorig >> linux-2.6.12-xen/.config

You now have the XEN arch extras at the end of the original ubuntu config. If you try to build now, loads of things will fail. All I did was to remove the config for the items that failed. I didn't document each one, but I'll attach or paste my .config in due course. I also removed a lot of cruft I didn't need, and some of this may be important for ubuntu functions that you use (like a GUI). You might like to start with my .config, and if anything is broken, try to add things. Alternatively, start from the config built as above, and use make-2.6-xen-config then -build over and over again until you have removed offending items. See XenOnBreezyKernelConfig for my config which compiled and runs ubuntu breezy as dom0. Once the compile completes without errors, echo $? should give 0, do

sudo make linux-2.6-xen-install
sudo depmod 2.6.12.6-xen
cd /boot
mkinitramfs -k -o initrd-2.6.12.6-xen 2.6.12.6-xen

you may wish to symlink initrd 2.6.12 to 2.6.12.6 for consistency with the xen vmlinuz file. I inserted the following grub stanza in position 0 (before the AUTO CONFIGURE section):

title   Xen3.0
root    (hd0,0)
kernel /xen.gz
module /vmlinuz-2.6.12-xen root=/dev/mapper/Ubuntu-root ro console=tty0
module /initrd-2.6.12-xen.img
boot

then rebooted...

# uname -r
2.6.12.6-xen

Missing Packages

Depending on your install and packages added to Breezy, you may need to add packages to complete the ./install.sh step successfully. I found these are required for 5.10.

  • latex
  • fig2dev

XmTest test framework

A requirement to build the test framework using autoconf, please read the README:

  • ./autogen && ./configure

I received this error when using autogen, it did not stop the build but is noted here:

  • configure.ac: 61: automake requires `AM_PROG_LEX', not `AC_PROG_LEX'

Reference for more information:

Missing Packages

The test suite on the 3.0.1 unstable tree required the following missing packages:

  • flex
  • bison
  • gettext
  • g++

Additional Information

Below are some links to other pages from which I derived this method.