Binqbu2002:Xen installation

Download Xen source tarball and extract it.
 tar zxvf xen-<version>.tar.gz
NOTE: <version> represents the source code version.
==Step 1: Necessary tarball list for Xen-3.4.1/3.4.2==
:* newlib-1.16.0.tar.gz
:* lwip-1.3.0.tar.gz
:* zlib-1.2.3.tar.gz
:* pciutils-2.2.9.tar.bz2
:* grub-0.97.tar.gz
Download and place them in xen-<version>/stumdom/
==Step 2: Install dependence==
The necessary dependence are listed as following:
:* gcc v3.4 or later 
:* make
:* binutils
:* development install of zlib (e.g., zlib-dev)
:* development install of Python v2.3 or later (e.g., python-dev)
:* development install of curses (e.g., libncurses-dev)
:* development install of openssl (e.g., openssl-dev)
:* development install of x11 (e.g. xorg-x11-dev)
:* bridge-utils package (/sbin/brctl)
:* iproute package (/sbin/ip)
:* hotplug or udev
:* gawk
:* gettext
:* texinfo
:* transfig
:* development install of libssl (e.g. libssl-dev)
:* bcc
:* ACPI ASL compiler (iasl)
:* latex relevance (e.g. texlive-latex-xxx, tetex-xxx, latex2html, latex2pdf)
:* mercurial (NOTE: This can be unnecessary if you don't need the hg support.)
:* git (NOTE: This can be unnecessary if you don't need the Git support.)
==Step 3: Prepare some tarballs==
It is highly recommend to download ALL necessary tarballs manually. Otherwise, the compilation program will download them automatically during the compilation, which may extend the compilation time tremendously because the automatic internet connection could be of low performance. The necessary tarball names and version are described in the Makefile of the path below:
 xen-<version>/stubdom/Makefile
You could download these tarballs with the right version and place them under the stubdom directory.
==Step 4: Prepare domain0 kernel==
You can extract the domain0 kernel source, if any, to the xen root directory (xen-<version>) so that you can avoid the time consuming downloading within the compilation. The source directory name should be linux-2.6.18-xen.hg.
==Step 4.5: Patching work==
If you are playing vanilla Xen, this step could be skipped. 
On the contrary, some development work may need source patching, and do it now! 
==Step 5: Compile and Install==
When all things are ready, you need to obtain root permission. OK, start sailing!
 make clean
 make dist
 make install
After the installation finish, you can see "xend" and "xendomains" in /etc/init.d/ directory.
NOTE: 
1) It is not wise to run "make world" because it will remove the domain0 kernel source that you had just well prepared. In fact, the "world" could be seemed as a batch parameter which equals "clean + kdelete + dist". "make kdelete" is the bad guy who kick out your domain0 kernel source code. 
    If you insistent to use "make world", I can also offer you some tips. During the compilation, the kernel source of XenLinux (linux-2.6.18.8-xen) will be downloaded. Something command lines like
 hg clone http://xenbits.xensource.com/linux-2.6.18-xen.hg
This progress is very time-consuming without responce. Just keep waiting.
Alternatively, you could extract the backup one, if any, to the xen-<version> directory so that the downloading could be passed. It is advised to adopt this method in that the hg downloading could be time consuming without any response, even hang! However, the compilation program will detect and remove the existing linux-2.6.18.8 directory. Therefore, the extraction should be after it. Be careful to hold the timing.
2) The compilation procedure may involve an interactive section which asks the user to determine how to deal with some new feature support. Using most of the default options are ok. But, some features should be forced to "yes".
:* PCI relevance. It may affect the VT-d performance.
:* Ethernet relevance, as shown below. The default is "no" so that the dom0 fails to find eth0. You MUST choose "y" for them!
 Intel(R) 82575 Gigabit Ethernet support (IGB) [N/m/y/?] (NEW) y
 ......
 Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support (E1000E) [N/m/y/?] (NEW) y
 ......
 Intel(R) 10GbE PCI Express adapters support (IXGBE) [N/m/y/?] (NEW) y
 ......
==Step 5: Create a Ramdisk==
===Library===
*For centos/fedora and other linux using "yum" as package manager:
yum install binutils zlib-devel python-devel
yum install ncurses-devel openssl-devel bridge-utils 
yum install iproute gettext texinfo*
yum install transfig dev86 vnc
yum install latex*
yum install mercurial
* For "mercurial", you need to setup your yum first. Please refer to Qian's document:
* missings:
: development install of x11 (e.g. xorg-x11-dev) 
: gcc v3.4 or later
: make 
: latex related
===Create Boot===
su -
depmod 2.6.18.8-xen
mkinitrd -v -f --builtin=pata_marvell /boot/initrd-2.6.18.8-xen.img2.6.18.8-xen
==Step 6: Configure the Bootloader==
Currently, only grub legacy support Xen. Update grub configuration automatically:
 update-grub
or, add an entry in /boot/grub/menu.lst like
 title Xen Dom0, kernel 2.6.18.8-xen
 root (hd0,0)
 kernel /xen-3.4.gz dom0_mem=512M
 module /vmlinuz-2.6.18.8-xen root=<root-dev> ro
 module /initrd-2.6.18.8-xen.img
NOTE: Details should be similar to other entries, e.g. the value of root. 
Okey,reboot and Enter Xen3.4.2,Be careful!You should login as root!!!
==Create DomU==
* First, create a hard disk .img file in console, "qemu-img" is a tool, "create" is the subcommand, "xxx.img" is the target image file, "20G" is the size:
qemu-img create xxx.img 20G
or
# dd if=/dev/zero of=nbsd.img bs=1024k count=2048
* Download a template config file from the ftp (192.168.1.253:5501, tcserver, #####)I strongly recommand that you should download /tarball/Xen/vm_config/winxp2
modify the config file name"winxp2"to"winxp"( to the name of your domainU)
if re.search('64', arch):
 arch_libdir = 'lib64'
else:
 arch_libdir = 'lib'
kernel = "/usr/lib/xen/boot/hvmloader"
builder='hvm'
memory = 1024 
name = "winxp"
vcpus = 1
#cpus = ["2", "3"] # VCPU0 runs on CPU2, VCPU1 runs on CPU3
#vif = [ 'type=vnif, mac=00:16:3e:00:00:11' ]
disk = ['file:/home/root/xxx.img,hda,w', 'phy:/dev/cdrom,hdc:cdrom,r']
#disk = ['file:/var/lib/xen/images/winxp.img,hda,w','phy:/dev/cdrom,hdc:cdrom,r']
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'
boot="dc"
vnc=1
localtime=1
#cpuid = [ '0x40000002:edx=0x3' ]
#mouse adjustment
usb=1
usbdevice='tablet'
#guest os debug support
serial = 'pty'
#serial = 'tcp::4444,server,nowait'
Disk path should be notified to hard disk path you just create.Name is your domainU's name The kenel should use absolute path
* Modify the following line to the .img file you created. This allows Xen to use the image file you created:
disk = ['file:/home/root/1.img,hda,w', 'phy:/dev/cdrom,hdc:cdrom,r']
* launch xend
xend start
* Launch a console, cd to the config file directory, type in: (winxp is the name of the config file)
xm create winxp
* Type following to "see" domain U. "xm create" only launches the domainU and runs it at "background", so you need to use vnc (a remote desktop) to connect to domainU display.
xm vnc winxp
If everything goes well, you can see the black booting screen in the Domain U.
* Note: Sometimes, the domainU is created but disappear immediately. Please put a bootable CD in the CD-ROM in advance.
* If there is nothing, you can use:
xm list
to check if winxp has been launched.
OK,enjoy!