Xen/Source

From Segfault
< Xen
Jump to navigation Jump to search

We'll build our Dom0 kernel and the hypervisor separately and won't care about DomU kernels at all. We also need a HVM (Hardware Virtual Machine) and a qemu binary to handle all the non-paravirt DomU domains.

Dom0 kernel

Get the xen/next branch of Jeremy's kernel tree:

 $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git -b xen/next linux-xen-next-git
 $ cd linux-xen-next-git
 $ make menuconfig
 $ make
 $ sudo make modules_install
 $ sudo cp arch/x86/boot/bzImage /boot/2.6/bzImage
 $ sudo cp .config /boot/2.6/config

Hypervisor

 $ sudo apt-get install bin86 bcc iasl python-dev
 $ hg clone http://xenbits.xen.org/xen-4.0-testing.hg xen-4.0-testing-hg
 $ cd xen-4.0-testing-hg
 
 $ sed 's/dist-stubdom //' -i.orig Makefile
 
 $ make
 $ sudo make install DESTDIR=/opt/xen
  • During "make world" it will fetch the xen-pvops Git tree again, go through configure and will interactively ask for missing/new options. We have to find out how to pass a working config to their make-magic...
  • If you're building with "make world" and the build fails, DO NOT issue "make world" again, as it will clean up the build directory, including those large SCM trees - they'd have to be fetched again! Instead, use just "make" or "make install" to try again.

Postinstall

Installing from source always requires a bit more work:

 # cat > /etc/profile.d/xen.sh
 export PYTHONPATH=/opt/xen/usr/lib/python2.6/site-packages
 export LD_LIBRARY_PATH=/opt/xen/usr/lib64
 export PATH=$PATH:/opt/xen/usr/bin:/opt/xen/usr/sbin
 ^D
 
 # echo 'none  /proc/xen  xenfs  nosuid,nodev,noexec  0 0' >> /etc/fstab
 # tar -C /opt/xen/etc -cf - . | tar -C /etc --keep-old-files -xf -

Yes, --keep-old-files is a GNU option. But since we're on GNU/Linux, we don't care for portability anyway :)

 # sed 's/xend [sr]/\/opt\/xen\/usr\/sbin\/&/' -i /etc/init.d/xend
 # update-rc.d xend defaults
 Adding system startup for /etc/init.d/xend ...
  /etc/rc0.d/K20xend -> ../init.d/xend
  /etc/rc1.d/K20xend -> ../init.d/xend
  /etc/rc6.d/K20xend -> ../init.d/xend
  /etc/rc2.d/S20xend -> ../init.d/xend
  /etc/rc3.d/S20xend -> ../init.d/xend
  /etc/rc4.d/S20xend -> ../init.d/xend
  /etc/rc5.d/S20xend -> ../init.d/xend

Actually I had to make a few more alterations to the initscript. In short, I added:

 [ -f /etc/profile.d/xen.sh ] && . /etc/profile.d/xen.sh

...and then removed all the "mount /proc/xen" cruft, that's what fstab(5) is for.


If all went well, it may look like this:

# ps -ef | grep [x]en
root        20     2  0 19:47 ?        00:00:00 [xenwatch]
root        21     2  0 19:47 ?        00:00:00 [xenbus]
root      4259     1  0 19:49 ?        00:00:00 xenstored --pid-file /var/run/xenstore.pid
root      4264     1  0 19:49 ?        00:00:00 xenconsoled 
root      4266     1  0 19:49 ?        00:00:00 /usr/bin/python /opt/xen/usr/sbin/xend start
root      4268  4266  0 19:49 ?        00:00:00 /usr/bin/python /opt/xen/usr/sbin/xend start

# xm info
host                   : alice
release                : 2.6.32
version                : #2 SMP Fri Apr 23 19:43:52 PDT 2010
machine                : x86_64
nr_cpus                : 2
nr_nodes               : 2
cores_per_socket       : 1
threads_per_core       : 1
cpu_mhz                : 2191
hw_caps                : 078bf3ff:e1d3fbff:00000000:00000010:00000000:00000000:00000000:00000000
virt_caps              : 
total_memory           : 8127
free_memory            : 261
node_to_cpu            : node0:0
                         node1:1
node_to_memory         : node0:130
                         node1:131
node_to_dma32_mem      : node0:130
                         node1:0
max_node_id            : 1
xen_major              : 4
xen_minor              : 0
xen_extra              : .1-rc1-pre
xen_caps               : xen-3.0-x86_64 xen-3.0-x86_32p 
xen_scheduler          : credit
xen_pagesize           : 4096
platform_params        : virt_start=0xffff800000000000
xen_changeset          : Wed Apr 21 08:36:58 2010 +0100 21120:88d9619e21c3
xen_commandline        : 
cc_compiler            : gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 
cc_compile_by          : joe
cc_compile_domain      : example.com
cc_compile_date        : Fri Apr 23 04:28:31 PDT 2010
xend_config_format     : 4

Problems

 > make[4]: Entering directory `tools/firmware'
 > Require dev86 rpm or bin86 & bcc debs version >= 0.16.14 to build firmware!
 > make[8]: Entering directory `tools/firmware/hvmloader/acpi'
 > ACPI ASL compiler (iasl) is needed
  • The stubdom target is currently broken and we're disabling it:
 $ mv Makefile Makefile.orig
 $ sed 's/dist-stubdom //' Makefile.orig > Makefile
  • The 2.6.31 Dom0 kernel crashed under Xen 4.0 :-\

Links