Difference between revisions of "Xen Common Problems"

From Xen
m
(Removed inline copy of RHEL6Xen4Tutorial. I think this was added in error)
Line 2: Line 2:
 
<!-- Comment: Copied "Xend does not start when using pv_ops dom0 kernel?" from the Paravirt page in this. -->
 
<!-- Comment: Copied "Xend does not start when using pv_ops dom0 kernel?" from the Paravirt page in this. -->
 
<!-- WikiMedia name: XenCommonProblems -->
 
<!-- WikiMedia name: XenCommonProblems -->
<!-- Page revision: <!-- MoinMoin name: RHEL6Xen4Tutorial -->
+
<!-- Page revision: 00000167 -->
<!-- Comment: -->
 
<!-- WikiMedia name: RHEL6Xen4Tutorial -->
 
<!-- Page revision: 00000073 -->
 
<!-- Original date: Tue Aug 30 06:31:20 2011 (1314685880000000) -->
 
 
__NOTOC__
 
= Redhat Enterprise Linux 6 Xen 4.0 tutorial =
 
This tutorial explains how to install and configure RHEL6 to run as Xen dom0 (host), running Xen hypervisor 4.0. Note that this is unsupported by Redhat! See the end of this wiki page for more information about RHEL6 Xen binary rpm yum repository. This tutorial explains how to compile Xen and dom0 kernel from sources/srpms.
 
 
As a default RHEL6 does NOT:
 
 
* RHEL6 does not ship Xen hypervisor or tools.
 
* RHEL6 does not ship Xen dom0 capable kernel.
 
 
As a default RHEL6 DOES:
 
 
* RHEL6 runs as Xen PV (paravirtual) domU using the pvops framework in the default kernel.
 
* RHEL6 runs as Xen HVM (fully virtualized) guest.
 
* RHEL6 ships with optimized Xen PV-on-HVM drivers for RHEL6 Xen HVM guests.
 
 
Topics in this tutorial:
 
 
* How to install and configure RHEL6 system for running as Xen dom0 (host).
 
* How to get Xen src.rpm from Fedora and rebuild and install it on RHEL6.
 
* How to install upstream Xen dom0 capable kernel on RHEL6.
 
* How to update the dom0 kernel to a newer version from the upstream git tree.
 
* How to use libvirt and virt-manager to manage Xen on RHEL6.
 
* Binary rpm repositories for EL6.
 
* More information and links.
 
 
TODO list for this tutorial:
 
 
* Fix the src.rpm compilation examples, shouldn't build as root.
 
* Make sure everything works with SElinux enabled, and leave it enabled.
 
 
== RHEL6 installation and configuration ==
 
=== Installation: ===
 
* Download "rhel-server-6.0-x86_64-dvd.iso" from Redhat Network (RHN).
 
* Burn it to DVDR, or if you have a server with remote management, use virtual media ISO mapping.
 
* Boot from the DVD.
 
* Install as usual.
 
* Choose "Basic Server" install.
 
* Disk Partitioning: Create /boot partition as primary, make it ext3 and at least 2 GB in size. Create LVM PV (Physical Volume) and VG (Volume Group) to fill the rest of the disk space. Create root as LVM volume, make it ext4, and at least 36 GB in size. Create swap as LVM volume, make it at least as big as the amount of RAM in your server.
 
* IMPORTANT! Make sure you leave FREE space in the LVM volume group. You can use that free space later to create LVM volumes for Xen VM virtual disks.
 
* In this tutorial the hostname is set to "el6.localdomain".
 
Screenshot of disk partitioning: http://pasik.reaktio.net/rhel6/rhel6xen4tutorial/rhel6-xen4-tutorial-partitioning.jpg
 
 
=== Configuration after installation: ===
 
First fix networking by editing "/etc/sysconfig/network-scripts/ifcfg-ethX", usually "ifcfg-eth0", and make it look like:
 
 
 
<pre><nowiki>
 
[root@el6 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
 
DEVICE="eth0"
 
HWADDR="00:11:22:33:44:55"
 
NM_CONTROLLED="no"
 
ONBOOT="yes"
 
BOOTPROTO="dhcp"
 
</nowiki></pre>
 
 
ie. make sure NM_CONTROLLED="no" and ONBOOT="yes". Then run "ifup eth0" to activate networking.
 
 
Make sure network service is set to start automatically:
 
 
 
<pre><nowiki>
 
[root@el6 ~]# chkconfig --list network
 
</nowiki></pre>
 
 
Make sure your Internet connection works OK at this point! Next make sure "/etc/hosts" file has an entry for your hostname:
 
 
 
<pre><nowiki>
 
[root@el6 ~]# cat /etc/hosts
 
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
 
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
 
127.0.0.1 el6 el6.localdomain
 
</nowiki></pre>
 
 
Full FQDN hostname in this example is "el6.localdomain".
 
 
Disable SElinux by editing "/etc/selinux/config" and make it have:
 
 
 
<pre><nowiki>
 
SELINUX=disabled
 
</nowiki></pre>
 
 
Then it's time to register your system to RHN, so you can fetch updates and install additional packages using yum.
 
 
Run "rhn_register" and fill in your RHN username and password. When registration is OK, '''there's an important extra step do!'''
 
 
'''You need to login to RHN website and:'''
 
 
* Click "Manage Entitlements & Subscriptions".
 
* Click the correct (newly added) system.
 
* Click "(Alter Channel Subscriptions)".
 
* '''Select ""RHEL Server Optional (v. 6 64-bit x86_64)" channel.'''
 
* Click "Change Subscriptions".
 
Some required packages are '''only''' available in the "RHEL Server Optional (v. 6 64-bit x86_64)" channel. '''Failing to add that channel means you won't be able to install some required packages later on.'''
 
 
When you're done with RHN update the system and install latest (security) fixes:
 
 
 
<pre><nowiki>
 
[root@el6 ~]# yum update
 
</nowiki></pre>
 
 
Then install some commonly used tools:
 
 
 
<pre><nowiki>
 
[root@el6 ~]# yum install screen vim wget tcpdump ntp ntpdate man smartmontools links lynx ethtool xorg-x11-xauth</nowiki></pre>
 
 
Then increase grub timeout from grub.conf, and comment out "hiddenmenu" option:
 
 
 
<pre><nowiki>
 
[root@el6 ~]# cat /boot/grub/grub.conf
 
# grub.conf generated by anaconda
 
#
 
# Note that you do not have to rerun grub after making changes to this file
 
# NOTICE: You have a /boot partition. This means that
 
# all kernel and initrd paths are relative to /boot/, eg.
 
# root (hd0,0)
 
# kernel /vmlinuz-version ro root=/dev/mapper/vg00-lvroot
 
# initrd /initrd-[generic-]version.img
 
#boot=/dev/sda
 
default=0
 
timeout=10
 
splashimage=(hd0,0)/grub/splash.xpm.gz
 
#hiddenmenu
 
title Red Hat Enterprise Linux Server (2.6.32-71.7.1.el6.x86_64)
 
root (hd0,0)
 
kernel /vmlinuz-2.6.32-71.7.1.el6.x86_64 ro root=/dev/mapper/vg00-lvroot rd_LVM_LV=vg00/lvroot rd_LVM_LV=vg00/lvswap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=fi crashkernel=auto rhgb quiet
 
initrd /initramfs-2.6.32-71.7.1.el6.x86_64.img
 
title Red Hat Enterprise Linux (2.6.32-71.el6.x86_64)
 
root (hd0,0)
 
kernel /vmlinuz-2.6.32-71.el6.x86_64 ro root=/dev/mapper/vg00-lvroot rd_LVM_LV=vg00/lvroot rd_LVM_LV=vg00/lvswap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=fi crashkernel=auto rhgb quiet
 
initrd /initramfs-2.6.32-71.el6.x86_64.img
 
</nowiki></pre>
 
 
At this point you should reboot the system to the newest kernel.
 
 
== Installing required packages to compile Xen rpms ==
 
Install packages that are required to rebuild Xen src.rpm (all on one line):
 
 
 
<pre><nowiki>
 
[root@el6 ~]# yum groupinstall "Development tools" "Additional Development" "Debugging Tools" "System administration tools" "Compatibility libraries" "Console internet tools" "Desktop Platform Development"
 
</nowiki></pre>
 
 
This is around 212 MB of downloads.
 
 
Then install some additional packages that are required to build Xen with all features enabled:
 
 
 
<pre><nowiki>
 
[root@el6 ~]# yum install transfig wget texi2html libaio-devel dev86 glibc-devel e2fsprogs-devel gitk mkinitrd iasl xz-devel bzip2-devel pciutils-libs pciutils-devel SDL-devel libX11-devel gtk2-devel bridge-utils PyXML qemu-common qemu-img mercurial texinfo libuuid-devel
 
</nowiki></pre>
 
 
This is around 82 MB of downloads.
 
 
And finally 32bit version of glibc-devel is required aswell:
 
 
 
<pre><nowiki>
 
[root@el6 ~]# yum install glibc-devel.i686
 
</nowiki></pre>
 
 
Now you have all the basic tools, libraries and headers installed.
 
 
== Rebuilding and installing Xen src.rpm ==
 
Fedora xen-4.0.1-6 rpm package includes some additional patches and fixes backported from upstream Xen 4.0.2-rc*.
 
 
 
<pre><nowiki>
 
[root@el6 ~]# mkdir /root/src && cd /root/src
 
[root@el6 src]# wget http://ftp.funet.fi/pub/mirrors/fedora.redhat.com/pub/fedora/linux/releases/14/Everything/source/SRPMS/xen-4.0.1-6.fc14.src.rpm
 
[root@el6 src]# rpm -i xen-4.0.1-6.fc14.src.rpm
 
[root@el6 src]# cd /root/rpmbuild/SPECS
 
[root@el6 SPECS]# rpmbuild -bb xen.spec
 
</nowiki></pre>
 
 
After a while you should see output like:
 
 
 
<pre><nowiki>
 
Wrote: /root/rpmbuild/RPMS/x86_64/xen-4.0.1-6.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/xen-libs-4.0.1-6.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/xen-runtime-4.0.1-6.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/xen-hypervisor-4.0.1-6.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/xen-doc-4.0.1-6.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/xen-devel-4.0.1-6.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/xen-licenses-4.0.1-6.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/xen-debuginfo-4.0.1-6.el6.x86_64.rpm
 
</nowiki></pre>
 
 
Try installing the rpms:
 
 
 
<pre><nowiki>
 
[root@el6 SPECS]# cd /root/rpmbuild/RPMS/x86_64/
 
[root@el6 x86_64]# rpm -Uvh xen*4.0.1-6*.rpm
 
error: Failed dependencies:
 
/usr/bin/qemu-nbd is needed by xen-runtime-4.0.1-6.el6.x86_64
 
</nowiki></pre>
 
 
So what's happening here? It seems RHEL6 does not have "qemu-common" rpm available, which includes "qemu-nbd" binary. So we need to grab qemu src.rpm from Fedora and rebuild it for RHEL6 to get the required "qemu-common" rpm.
 
 
Verify the version of "qemu" in RHEL6:
 
 
 
<pre><nowiki>
 
[root@el6 x86_64]# rpm -qa | grep qemu
 
qemu-img-0.12.1.2-2.113.el6.x86_64
 
</nowiki></pre>
 
 
Ok, so it's version 0.12.x. Fedora 13 has qemu 0.12.5, so it's close enough:
 
 
 
<pre><nowiki>
 
[root@el6 x86_64]# cd /root/src
 
[root@el6 src]# wget http://ftp.funet.fi/pub/mirrors/fedora.redhat.com/pub/fedora/linux/updates/13/SRPMS/qemu-0.12.5-1.fc13.src.rpm
 
[root@el6 src]# rpm -i qemu-0.12.5-1.fc13.src.rpm
 
[root@el6 src]# cd /root/rpmbuild/SPECS
 
[root@el6 SPECS]# rpmbuild -bb qemu.spec
 
</nowiki></pre>
 
 
After a while you'll see:
 
 
 
<pre><nowiki>
 
Wrote: /root/rpmbuild/RPMS/x86_64/qemu-0.12.5-1.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/qemu-kvm-0.12.5-1.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/qemu-img-0.12.5-1.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/qemu-common-0.12.5-1.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/qemu-user-0.12.5-1.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/qemu-system-x86-0.12.5-1.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/qemu-system-ppc-0.12.5-1.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/qemu-system-sparc-0.12.5-1.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/qemu-system-arm-0.12.5-1.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/qemu-system-mips-0.12.5-1.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/qemu-system-cris-0.12.5-1.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/qemu-system-m68k-0.12.5-1.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/qemu-system-sh4-0.12.5-1.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/qemu-kvm-tools-0.12.5-1.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/qemu-debuginfo-0.12.5-1.el6.x86_64.rpm
 
</nowiki></pre>
 
 
So now we have the required "qemu-common" rpm. Let's install it to satisfy the package dependencies:
 
 
 
<pre><nowiki>
 
[root@el6 SPECS]# cd /root/rpmbuild/RPMS/x86_64
 
[root@el6 x86_64]# rpm -Uvh qemu-common-0.12.5-1.el6.x86_64.rpm
 
Preparing... ########################################### [100%]
 
1:qemu-common ########################################### [100%]
 
</nowiki></pre>
 
 
Now we can also install Xen rpms:
 
 
 
<pre><nowiki>
 
[root@el6 x86_64]# rpm -Uvh xen*4.0.1-6*.rpm
 
Preparing... ########################################### [100%]
 
1:xen-licenses ########################################### [ 13%]
 
2:xen-libs ########################################### [ 25%]
 
3:xen-hypervisor ########################################### [ 38%]
 
4:xen-runtime ########################################### [ 50%]
 
5:xen ########################################### [ 63%]
 
6:xen-devel ########################################### [ 75%]
 
7:xen-doc ########################################### [ 88%]
 
8:xen-debuginfo ########################################### [100%]
 
</nowiki></pre>
 
 
Now you're done installing Xen hypervisor, tools and libraries.
 
 
== Installing upstream Xen dom0 capable kernel ==
 
Note that we're installing upstream *Xen* kernel here, which is based on the long-term maintained kernel.org Linux 2.6.32.x kernel. This kernel is different from Redhat RHEL6 kernel. Many drivers are newer versions in Redhat's kernel, and Redhat's kernel might have more features than the kernel.org kernel. Due to the driver version differences you might experience problems on some hardware, for example on servers using LSI/DELL RAID adapters. You might need to manually update driver versions to fix these problems on affected systems. See the end of this wiki page for more information about kernel versions.
 
 
Clone the kernel git repository from kernel.org and check out the "xen/stable-2.6.32.x" long-term maintained branch.
 
 
 
<pre><nowiki>
 
[root@el6 x86_64]# mkdir /root/kernel && cd /root/kernel
 
[root@el6 kernel]# git clone git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git linux-2.6-xen
 
[root@el6 kernel]# cd linux-2.6-xen
 
[root@el6 linux-2.6-xen]# git checkout -b xen/stable-2.6.32.x origin/xen/stable-2.6.32.x
 
</nowiki></pre>
 
 
Now you have the kernel ready to be configured and compiled. Reference config-file used is for version "2.6.32.25". It should work with newer version aswell, "make oldconfig" takes care of that.
 
 
NOTE! The reference .config file has various debugging options enabled, so don't use this kernel config for performance benchmarks!
 
 
 
<pre><nowiki>
 
[root@el6 linux-2.6-xen]# wget -O .config http://pasik.reaktio.net/xen/kernel-config/config-2.6.32.25-pvops-dom0-xen-stable-x86_64
 
[root@el6 linux-2.6-xen]# make oldconfig
 
[root@el6 linux-2.6-xen]# make -j4 bzImage && make -j4 modules && make modules_install
 
</nowiki></pre>
 
 
Then let's install the kernel and generate initrd (initramfs) image for the new kernel. Kernel version in this example is "2.6.32.25":
 
 
 
<pre><nowiki>
 
[root@el6 linux-2.6-xen]# depmod -a 2.6.32.25
 
[root@el6 linux-2.6-xen]# cp -a arch/x86/boot/bzImage /boot/vmlinuz-2.6.32.25
 
[root@el6 linux-2.6-xen]# cp -a System.map /boot/System.map-2.6.32.25
 
[root@el6 linux-2.6-xen]# cp -a .config /boot/config-2.6.32.25
 
[root@el6 linux-2.6-xen]# cd /boot
 
[root@el6 boot]# dracut initramfs-2.6.32.25.img 2.6.32.25
 
</nowiki></pre>
 
 
NOTE! If you're using a system with LSI and/or Dell RAID adapters (using megaraid_sas driver) you need to manually update the driver version at this point! Linux 2.6.32.25 ships with too old driver version, and it wont' work (disks won't get enabled on system startup). See this email for information about updating the driver version: http://lists.xensource.com/archives/html/xen-devel/2010-11/msg00250.html .
 
 
Then it's time to modify "grub.conf" and add an entry for the Xen+dom0 combination:
 
 
 
<pre><nowiki>
 
[root@el6 ~]# cat /boot/grub/grub.conf
 
# grub.conf generated by anaconda
 
#
 
# Note that you do not have to rerun grub after making changes to this file
 
# NOTICE: You have a /boot partition. This means that
 
# all kernel and initrd paths are relative to /boot/, eg.
 
# root (hd0,0)
 
# kernel /vmlinuz-version ro root=/dev/mapper/vg00-lvroot
 
# initrd /initrd-[generic-]version.img
 
#boot=/dev/sda
 
default=0
 
timeout=10
 
splashimage=(hd0,0)/grub/splash.xpm.gz
 
#hiddenmenu
 
title Red Hat Enterprise Linux Server (2.6.32-71.7.1.el6.x86_64)
 
root (hd0,0)
 
kernel /vmlinuz-2.6.32-71.7.1.el6.x86_64 ro root=/dev/mapper/vg00-lvroot rd_LVM_LV=vg00/lvroot rd_LVM_LV=vg00/lvswap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=fi crashkernel=auto rhgb quiet
 
initrd /initramfs-2.6.32-71.7.1.el6.x86_64.img
 
title Red Hat Enterprise Linux (2.6.32-71.el6.x86_64)
 
root (hd0,0)
 
kernel /vmlinuz-2.6.32-71.el6.x86_64 ro root=/dev/mapper/vg00-lvroot rd_LVM_LV=vg00/lvroot rd_LVM_LV=vg00/lvswap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=fi crashkernel=auto rhgb quiet
 
initrd /initramfs-2.6.32-71.el6.x86_64.img
 
title Xen 4.0 with Linux 2.6.32.25 dom0
 
root (hd0,0)
 
kernel /xen.gz dom0_mem=1024M loglvl=all guest_loglvl=all
 
module /vmlinuz-2.6.32.25 ro root=/dev/mapper/vg00-lvroot rd_LVM_LV=vg00/lvroot nomodeset
 
module /initramfs-2.6.32.25.img
 
</nowiki></pre>
 
 
Then let's disable KSM services, those don't work with Xen currently:
 
 
 
<pre><nowiki>
 
[root@el6 ~]# chkconfig ksm off
 
[root@el6 ~]# chkconfig ksmtuned off
 
</nowiki></pre>
 
 
And then it's time to reboot into Xen ! Remember to choose the Xen entry from grub:
 
 
 
<pre><nowiki>
 
[root@el6 ~]# reboot</nowiki></pre>
 
 
== Verifying Xen after reboot ==
 
 
<pre><nowiki>
 
[root@el6 ~]# xm list
 
Name ID Mem VCPUs State Time(s)
 
Domain-0 0 1024 4 r----- 93.9
 
 
[root@el6 ~]# xm info
 
host : el6.localdomain
 
release : 2.6.32.25
 
version : #1 SMP Sun Nov 14 21:50:39 EET 2010
 
machine : x86_64
 
nr_cpus : 4
 
nr_nodes : 1
 
cores_per_socket : 4
 
threads_per_core : 1
 
cpu_mhz : 2826
 
hw_caps : bfebfbff:20100800:00000000:00000940:0008e3fd:00000000:00000001:00000000
 
virt_caps : hvm
 
total_memory : 8190
 
free_memory : 7070
 
node_to_cpu : node0:0-3
 
node_to_memory : node0:7070
 
node_to_dma32_mem : node0:3259
 
max_node_id : 0
 
xen_major : 4
 
xen_minor : 0
 
xen_extra : .1
 
xen_caps : xen-3.0-x86_64 xen-3.0-x86_32p hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64
 
xen_scheduler : credit
 
xen_pagesize : 4096
 
platform_params : virt_start=0xffff800000000000
 
xen_changeset : unavailable
 
xen_commandline : dom0_mem=1024M loglvl=all guest_loglvl=all
 
cc_compiler : gcc version 4.4.4 20100726 (Red Hat 4.4.4-13) (GCC)
 
cc_compile_by : root
 
cc_compile_domain :
 
cc_compile_date : Sun Nov 14 21:41:09 EET 2010
 
xend_config_format : 4
 
 
[root@el6 ~]# uname -a
 
Linux el6.localdomain 2.6.32.25 #1 SMP Sun Nov 14 21:50:39 EET 2010 x86_64 x86_64 x86_64 GNU/Linux
 
 
</nowiki></pre>
 
 
From the output above we can see we're running Xen hypervisor version 4.0.1 (xen_major, xen_minor, xen_extra) with Linux 2.6.32.25 dom0 kernel.
 
 
== Updating the dom0 kernel ==
 
Linux 2.6.32.x is the long-term supported and maintained kernel from both kernel.org and xen.org, so it gets pretty frequent updates. Here are the steps to update your kernel tree so you don't have to clone the whole tree again.
 
 
Clean up and update the git tree, then check the changelog for the recent changes:
 
 
 
<pre><nowiki>
 
[root@el6 ~]# mkdir /root/kernel/linux-2.6-xen
 
[root@el6 linux-2.6-xen]# make clean
 
[root@el6 linux-2.6-xen]# git pull
 
[root@el6 linux-2.6-xen]# git log | less
 
</nowiki></pre>
 
 
And then follow the steps in the previous chapters to build and install the new kernel version.
 
 
Online changelog for the "xen/stable-2.6.32.x" branch of the kernel git tree is located here: http://git.kernel.org/?p=linux/kernel/git/jeremy/xen.git;a=shortlog;h=xen/stable-2.6.32.x .
 
 
== Using libvirt and virt-manager with Xen ==
 
Install libvirt and virt-manager:
 
 
 
<pre><nowiki>
 
[root@el6 ~]# yum install libvirt virt-manager xorg-x11-xauth</nowiki></pre>
 
 
The default version of libvirt in RHEL6 is not compiled with Xen support. You can verify this by using ssh with X11 forwarding from your laptop/desktop to your dom0, and trying to run "virt-manager":
 
 
 
<pre><nowiki>
 
[root@el6 ~]# virt-manager &
 
[1] 2867
 
 
Unable to open connection to hypervisor URI 'xen:///':
 
no connection driver available for xen:///
 
Traceback (most recent call last):
 
File "/usr/share/virt-manager/virtManager/connection.py", line 992, in _try_open
 
None], flags)
 
File "/usr/lib64/python2.6/site-packages/libvirt.py", line 111, in openAuth
 
if ret is None:raise libvirtError('virConnectOpenAuth() failed')
 
libvirtError: no connection driver available for xen:///
 
</nowiki></pre>
 
 
This can be fixed by rebuilding libvirt rpms with Xen support enabled.
 
 
'''NOTE! Before rebuilding libvirt src.rpm you need to boot into non-Xen environment!''' This is because some of the automated RHEL6 libvirt Xen-specific tests seem to fail in Xen dom0 environment, but work OK in baremetal.
 
 
Verify libvirt version in RHEL6:
 
 
 
<pre><nowiki>
 
[root@el6 ~]# rpm -qa | grep libvirt</nowiki></pre>
 
 
RHEL 6.0 seems to have libvirt version 0.8.1.
 
 
Let's download the src.rpm from Redhat ftp server, patch the spec file to enable Xen support, and try rebuilding it.
 
 
 
<pre><nowiki>
 
[root@el6 ~]# cd /root/src
 
[root@el6 src]# wget ftp://ftp.redhat.com/pub/redhat/linux/enterprise/6Server/en/os/SRPMS/libvirt-0.8.1-27.el6.src.rpm
 
[root@el6 src]# rpm -i libvirt-0.8.1-27.el6.src.rpm
 
[root@el6 src]# wget http://pasik.reaktio.net/xen/patches/libvirt-spec-rhel6-enable-xen.patch
 
[root@el6 src]# cd /root/rpmbuild/SPECS
 
[root@el6 SPECS]# cp -a libvirt.spec libvirt.spec.orig
 
[root@el6 SPECS]# patch -p0 < ~/src/libvirt-spec-rhel6-enable-xen.patch
 
patching file libvirt.spec
 
 
[root@el6 SPECS]# rpmbuild -bb libvirt.spec
 
error: Failed build dependencies:
 
libnl-devel >= 1.1 is needed by libvirt-0.8.1-27.el6.x86_64
 
xhtml1-dtds is needed by libvirt-0.8.1-27.el6.x86_64
 
libudev-devel >= 145 is needed by libvirt-0.8.1-27.el6.x86_64
 
libpciaccess-devel >= 0.10.9 is needed by libvirt-0.8.1-27.el6.x86_64
 
yajl-devel is needed by libvirt-0.8.1-27.el6.x86_64
 
libpcap-devel is needed by libvirt-0.8.1-27.el6.x86_64
 
avahi-devel is needed by libvirt-0.8.1-27.el6.x86_64
 
parted-devel is needed by libvirt-0.8.1-27.el6.x86_64
 
device-mapper-devel is needed by libvirt-0.8.1-27.el6.x86_64
 
numactl-devel is needed by libvirt-0.8.1-27.el6.x86_64
 
netcf-devel >= 0.1.4 is needed by libvirt-0.8.1-27.el6.x86_64
 
</nowiki></pre>
 
 
Ok, so we need more packages installed:
 
 
 
<pre><nowiki>
 
[root@el6 SPECS]# yum install libnl-devel xhtml1-dtds libudev-devel libpciaccess-devel yajl-devel libpcap-devel avahi-devel parted-devel device-mapper-devel numactl-devel netcf-devel
 
</nowiki></pre>
 
 
After that let's try again:
 
 
 
<pre><nowiki>
 
[root@el6 SPECS]# rpmbuild -bb libvirt.spec</nowiki></pre>
 
 
After a while you'll see:
 
 
 
<pre><nowiki>
 
Wrote: /root/rpmbuild/RPMS/x86_64/libvirt-0.8.1-27.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/libvirt-client-0.8.1-27.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/libvirt-devel-0.8.1-27.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/libvirt-python-0.8.1-27.el6.x86_64.rpm
 
Wrote: /root/rpmbuild/RPMS/x86_64/libvirt-debuginfo-0.8.1-27.el6.x86_64.rpm
 
</nowiki></pre>
 
 
Then let's install the xen-enabled rpms (note you need to use --force because the same version of libvirt is already installed):
 
 
 
<pre><nowiki>
 
[root@el6 ~]# cd /root/rpmbuild/RPMS/x86_64/
 
[root@el6 x86_64]# rpm -Uvh --force libvirt-0.8.1-27.el6.x86_64.rpm libvirt-client-0.8.1-27.el6.x86_64.rpm libvirt-python-0.8.1-27.el6.x86_64.rpm
 
Preparing... ########################################### [100%]
 
1:libvirt-client ########################################### [ 33%]
 
2:libvirt ########################################### [ 67%]
 
3:libvirt-python ########################################### [100%]
 
</nowiki></pre>
 
 
Now make sure "libvirtd" is set to automatically start on boot:
 
 
 
<pre><nowiki>
 
[root@el6 ~]# chkconfig --list libvirtd
 
libvirtd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
 
</nowiki></pre>
 
 
Then it's time to reboot back to Xen !
 
 
== Verifying libvirt with Xen ==
 
 
<pre><nowiki>
 
[root@el6 ~]# virsh list
 
Id Name State
 
----------------------------------
 
0 Domain-0 running
 
 
[root@el6 ~]# xm list
 
Name ID Mem VCPUs State Time(s)
 
Domain-0 0 1024 4 r----- 52.8
 
 
</nowiki></pre>
 
 
So it seems to work. Now you're also able to use graphical "virt-manager" to manage Xen on RHEL6.
 
 
== Bridge problems and errors with custom dom0 kernel ==
 
 
<pre><nowiki>
 
# brctl show
 
bridge name    bridge id              STP enabled    interfaces
 
virbr0Â Â Â Â Â Â Â Â Â /sys/class/net/virbr0/bridge: No such file or directory
 
/sys/class/net/virbr0/bridge: No such file or directory
 
/sys/class/net/virbr0/bridge: No such file or directory
 
/sys/class/net/virbr0/bridge: No such file or directory
 
/sys/class/net/virbr0/bridge: No such file or directory
 
/sys/class/net/virbr0/bridge: No such file or directory
 
/sys/class/net/virbr0/bridge: No such file or directory
 
/sys/class/net/virbr0/bridge: No such file or directory
 
/sys/class/net/virbr0/bridge: No such file or directory
 
/sys/class/net/virbr0/bridge: No such file or directory
 
/sys/class/net/virbr0/bridge: No such file or directory
 
/sys/class/net/virbr0/bridge: No such file or directory
 
8000.000000000000Â Â Â Â Â Â yes
 
</nowiki></pre>
 
 
 
This problem happens because Redhat added bridge IGMP snooping support to rhel6 2.6.32 kernel, and also to rhel6 bridge-utils. If you use mainline or custom Linux 2.6.32 kernel with el6 distro then you won't have that bridge IGMP snooping support in the kernel, and bridge-utils (brctl) will give errors like above.
 
 
There are two workarounds:
 
* Use Xen dom0 kernel based on actual rhel6 kernel/patches, mayoung does have "xendom0" kernel available for el6 distros based on actual rhel6 kernel, with xen dom0 pvops patches added on top, so it includes bridge IGMP snooping support and the default el6 bridge-utils works OK without errors. See the end of this wiki tutorial page for links to xendom0 kernel rpms.
 
* If using custom dom0 kernel (xen.git xen/stable-2.6.32.x) then rebuild the el6 bridge-utils src.rpm and remove the IGMP snooping patch from the spec file: http://lists.xensource.com/archives/html/xen-devel/2011-02/msg00760.html .
 
 
== Using graphical virt-manager to manage Xen on RHEL6 ==
 
Some screenshots of using virt-manager with Xen on RHEL6 and installing Fedora 14 Xen PV domU. Note that you don't need (and probably shouldn't) run Xserver on dom0! You can use ssh X11 forwarding to run virt-manager on dom0 but display the virt-manager GUI on your local laptop/desktop. See the Fedora 13 tutorial link in the end of this page for more information about using ssh X11 forwarding.
 
 
http://pasik.reaktio.net/rhel6/rhel6xen4tutorial/rhel6-virtmanager01.png
 
 
http://pasik.reaktio.net/rhel6/rhel6xen4tutorial/rhel6-virtmanager02.png
 
 
http://pasik.reaktio.net/rhel6/rhel6xen4tutorial/rhel6-virtmanager03.png
 
 
http://pasik.reaktio.net/rhel6/rhel6xen4tutorial/rhel6-virtmanager04.png
 
 
http://pasik.reaktio.net/rhel6/rhel6xen4tutorial/rhel6-virtmanager05.png
 
 
http://pasik.reaktio.net/rhel6/rhel6xen4tutorial/rhel6-virtmanager06.png
 
 
http://pasik.reaktio.net/rhel6/rhel6xen4tutorial/rhel6-virtmanager07.png
 
 
http://pasik.reaktio.net/rhel6/rhel6xen4tutorial/rhel6-virtmanager08.png
 
 
http://pasik.reaktio.net/rhel6/rhel6xen4tutorial/rhel6-virtmanager09.png
 
 
http://pasik.reaktio.net/rhel6/rhel6xen4tutorial/rhel6-virtmanager10.png
 
 
http://pasik.reaktio.net/rhel6/rhel6xen4tutorial/rhel6-virtmanager12.png
 
 
http://pasik.reaktio.net/rhel6/rhel6xen4tutorial/rhel6-virtmanager13.png
 
 
== Network setup details and troubleshooting ==
 
 
See [[Fedora13Xen4Tutorial:]] for more information about virbr0 setup/configuration for NAT/DHCP, routing, firewall rules, etc.
 
 
== Binary Xen rpm repositories for EL6 ==
 
 
Take a look at these repositories:
 
* Michael Young's EL6 Xen rpm repository (also includes xen dom0 capable kernel based on rhel6 2.6.32 kernel):
 
* http://xenbits.xen.org/people/mayoung/EL6.xen/
 
* http://xenbits.xen.org/people/mayoung/testing/
 
* Gitco.de repository is based on this tutorial, but contains xen dom0 capable kernel rpm based on the xen/kernel.org kernel (not rhel6 kernel):
 
* http://www.gitco.de/linux/x86_64/centos/6/
 
* http://www.gitco.de/linux/x86_64/centos/6/gitco-centos6-x86_64.repo
 
 
Additional repositories:
 
* Fedora xendom0 kernel rpms by Michael Young: http://repos.fedorapeople.org/repos/myoung/dom0-kernel/
 
* http://wiki.alteeve.com/files/an-cluster/rhel6/
 
 
== Links for more information ==
 
See this Fedora 13 Xen 4.0 tutorial for more information about installing different kinds of Xen guest VMs and other tips: [[Fedora13Xen4Tutorial]] .
 
 
More information about RHEL and Xen:
 
 
* RHEL5 Xen/Virtualization guide: http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5/html/Virtualization/index.html
 
* RHEL6 release notes, Xen guest support: http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Release_Notes/virtualization.html
 
* RHEL6 Xen PV-on-HVM drivers: http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Technical_Notes/virt.html
 
More information about Xen:
 
 
* http://wiki.xensource.com/xenwiki/Xen4.0
 
* http://wiki.xensource.com/xenwiki/XenParavirtOps
 
* http://wiki.xensource.com/xenwiki/XenBestPractices
 
* http://wiki.xensource.com/xenwiki/XenCommonProblems
 
* http://wiki.xensource.com/xenwiki/XenDom0Kernels
 
* http://wiki.xensource.com/xenwiki/XenKernelFeatures
 
 
Additional links:
 
* Script to automate this tutorial: http://wiki.alteeve.com/index.php/Pxdi
 
* Tutorial how to rebuild the Fedora 12 xendom0 kernel src.rpm: http://bderzhavets.wordpress.com/2010/11/29/rebuild-kernel-2-6-32-26-174-xendom0-fc12-src-rpm-on-rhel-server-6/
 
* Worth checking out is the Fedora Xen dom0 feature page: http://fedoraproject.org/wiki/Features/XenPvopsDom0 .
 
 
End of tutorial.
 
00000167 -->
 
 
<!-- Original date: Wed Oct 26 18:28:24 2011 (1319653704000000) -->
 
<!-- Original date: Wed Oct 26 18:28:24 2011 (1319653704000000) -->
   
Line 1,490: Line 841:
   
   
It's possible that dom0 is using most of your memory and Xen hypervisor doesn't have any free memory left. You should use "dom0_mem=" setting for Xen in grub to configure dom0 a fixed/dedicated amount of memory, so the rest of the memory is free for other VMs to use. See [[XenBestPractices]] wiki page for more info about configuring "dom0_mem=" option for Xen.
+
It's possible that dom0 is using most of your memory and Xen hypervisor doesn't have any free memory left. You should use "dom0_mem=" setting for Xen in grub to configure dom0 a fixed/dedicated amount of memory, so the rest of the memory is free for other VMs to use. See [[XenBestPractices:]] wiki page for more info about configuring "dom0_mem=" option for Xen.
   
 
== Error: (4, 'Out of memory', 'panic: xc_dom_core.c:442: xc_dom_alloc_segment: segment ramdisk too large (0xee93 > 0x8000 - 0x1755 pages)') ==
 
== Error: (4, 'Out of memory', 'panic: xc_dom_core.c:442: xc_dom_alloc_segment: segment ramdisk too large (0xee93 > 0x8000 - 0x1755 pages)') ==

Revision as of 10:13, 21 December 2011


Icon todo.png Needs Refactor

This page has some issues with syntax and formatting: [[[XenConfigurationFileOptions]]]should be XenConfigurationFileOptions, etc. The page will also benefit from being broken into smaller FAQs along topics and merged with XenFAQ and XenFAQ2.


Answers to some common problems and questions about Xen

Contents

I'd like to contribute to the Xen wiki pages, I have something to add/edit/fix, how can I do it?

Contributions are very welcome! You should create yourself a wiki account, and then send an email to Todd Deshane asking for edit permissions. Please include your Xen wiki username in the email. Email address for Todd Deshane is todd dot deshane at xen dot org.

I'd like to read some kind of overview about Xen

See the [[[XenOverview]]] wiki page. Also check the following PDF documents:

Where can I read about the history of Xen?

Please see: http://www.xen.org/community/xenhistory.html

I'm interesting in being a Xen developer! Are there projects to work on?

Yes! Please check the XenDevelopmentProjects wiki page for more information!

How does Xen compare to KVM? Which one is better?

Please see this blog post for more information: http://blog.xen.org/index.php/2010/05/07/xen-%E2%80%93-kvm-linux-%E2%80%93-and-the-community/

Also check these documents:

Is there a "Best Practices" document available?

See the [[[XenBestPractices]]] wiki page.

Where can I find a list of available Xen dom0 kernels?

See the [[[XenDom0Kernels]]] wiki page.

Where can I find a list of available features in different Xen kernels?

See the XenKernelFeatures wiki page.

I have problems getting Xen or dom0 kernel to boot, how can I set up a serial console to log and troubleshoot the boot process?

See the [[[XenSerialConsole]]] wiki page.

Where can I find a list of all the available domU configuration options in /etc/xen/<guest> cfgfile?

See the [[[XenConfigurationFileOptions]]] wiki page.

Is there a list of all available Xen hypervisor (xen.gz) commandline boot options for grub.conf?

Yes, please see the XenHypervisorBootOptions wiki page.

Can I passthrough an USB device connected to dom0 to a Xen guest?

Yes, please see the XenUSBPassthrough wiki page.

Can I passthrough a PCI device to Xen guest?

Yes, please see the XenPCIpassthrough wiki page.

Can I passthru a VGA graphics adapter to Xen guest?

Yes, please see the XenVGAPassthrough wiki page.

I have problems using my graphics card in Xen dom0, with the pvops dom0 kernel.. any tips?

Yes, please see the XenPVOPSDRM wiki page.

Is there more information about Xen PVSCSI passthrough functionality?

Yes, please see the XenPVSCSI wiki page.

Is there more information about Xen "blktap" disk backend?

Yes, Xen actually has two blktap backends:

  • blktap1: please see the blktap wiki page for more information.
  • blktap2: please see the blktap2 wiki page for more information.

blktap2 supports VHD images, and is considered much more robust than the old blktap1 qemu/qcow image file support. Xen 4.0 includes blktap2 support. Note that also the dom0 kernel needs to have the blktap2 driver.

Is there a list of various 3rd party management tools and (web) interfaces for Xen or XCP?

Yes, please see the XenManagementTools wiki page.

Is there more information about Xen Fault Tolerance, aka Remus Transparent High Availability (HA) for VMs?

Yes, please see the Remus wiki page for more information.

Where can I find optimized Xen PV-on-HVM drivers for Linux HVM (fully virtualized) guests?

Please see the XenLinuxPVonHVMdrivers wiki page.

Do you have a list of Xen related research papers?

Yes, please see http://www.xen.org/community/xenpapers.html

Where can I find information about Xen on RISC CPUs?

  • Please see XenPPC wiki page for Xen on PowerPC CPUs. XenPPC project is not active anymore.
  • Please see XenARM wiki page for Xen on ARM CPUs. Xen ARM project is actively developed.

What's the difference between Xen hypervisor (from xen.org) and Citrix XenServer or XCP?

Xen hypervisor from xen.org is the core hypervisor used in many different products. It includes basic command line management tools. It is distributed as a tarball and from mercurial source code repositories. You need to compile and install Xen hypervisor from sources, and combine it with a kernel of your choice. It can be thought as the "core engine" you can use to build your own virtualization platform.

Many Linux distributions package Xen and distribute it as prebuilt binaries, combined with Xen capable kernels of their choice. There are many additional thirdparty management tools available to manage the Xen hypervisor.

There are multiple companies shipping products based on the Xen hypervisor, including Citrix, Oracle, Novell, Redhat, and others.

Citrix XenServer is a commercial product that includes the core Xen hypervisor from xen.org, combined with CentOS-based dom0 distro, management toolstack, and everything else required to build a ready made virtualization platform. Citrix XenServer is a dedicated virtualization platform (not a general purpose Linux distro), and it is shipped as a ready to install ISO-image that contains everything you need out-of-the-box. Citrix XenServer includes the XAPI management toolstack (which not included in the core Xen hypervisor from xen.org), allowing you to pool multiple Xen hosts together and manage them centrally using either the graphical Citrix XenCenter management tool, the 'xe' commandline tool or using the XenAPI directly from your scripts. Citrix XenCenter graphical management tool is only available for Windows.

Xen Cloud Platform (XCP) was announced in 2009, and it is the opensourced version of Citrix XenServer, including the XAPI management toolstack. XCP and XAPI are now developed on xen.org repositories. XCP is shipped as ready to install ISO-images, just like Citrix XenServer. Citrix is basing their new Citrix XenServer releases on XCP. XCP includes the XenAPI provided by the XAPI toolstack and the 'xe' commandline tool. XCP does not include Citrix XenCenter and Citrix XenCenter cannot be used to manage XCP. XCP users can use the opensource OpenXenManager instead, which runs on Linux. See http://www.xen.org/products/cloudxen.html for more information about XCP.

How can I check the version of Xen hypervisor?

Run "xm info" in dom0. You can find the hypervisor version in "xen_major", "xen_minor" and "xen_extra" fields. The version is major.minor.extra.

Determining the version from within a domU is dependent on the guest operating system. For Linux guests:


$ dmesg | grep Xen\ version
Xen version: 3.4.2 (preserve-AD)


How can I check if I'm able to run Xen HVM (fully virtualized) guests?

Xen requires CPU virtualization support/extensions (Intel VT, AMD-V) for running HVM guests (=Windows). Virtualization support needs to be enabled in the system BIOS. Intel calls this feature also as "VT-x". Also note that Intel "VT-x" is different from "VT-d", which is a totally different feature (see the next section below).

NOTE that Linux dom0 kernel doesn't see 'vmx' or 'svm' CPU flags in "/proc/cpuinfo" because Xen *hypervisor* (xen.gz) is using the hardware virtualization features and hiding the flags from dom0! Xen dom0 is actually a virtual machine, so it doesn't see all the cpu flags as Xen hypervisor is hiding some flags from dom0.

You can run "xm info" in dom0 and check from the 'xen_caps' line if Xen is able to run hvm guests. Also Xen hypervisor boot messages in "xm dmesg" show if hardware virtualization (HVM) is enabled or disabled.

Example "xm dmesg | grep -i hvm" output for an Intel system where HVM is supported by the CPU:


(XEN) HVM: VMX enabled

Example "xm dmesg" output for an Intel system where HVM is supported by the CPU but it's disabled in the system BIOS:


(XEN) VMX disabled by Feature Control MSR.

Example "xm dmesg | grep -i hvm" output for an AMD system where HVM is supported:


(XEN) HVM: SVM enabled

You can also see the HVM support status from the "xen_caps" line on Xen hypervisor "xm info | grep xen_caps" output:


xen_caps               : xen-3.0-x86_64 xen-3.0-x86_32p hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64

If your CPU supports Hardware Assisted Paging (HAP, Intel EPT or AMD NPT) you'll see a line like this in "xm dmesg" output:


(XEN) HVM: Hardware Assisted Paging detected and enabled.

How can I check if my hardware has an IOMMU?

Hardware IOMMU (Intel VT-d) is required for hardware assisted PCI passthru (I/O virtualization) to Xen HVM (fully virtualized) guest VMs. You can check for IOMMU status from "xm dmesg" output.

Example "xm dmesg" output for a system where IOMMU is supported:


(XEN) I/O virtualisation enabled

Example "xm dmesg" output for a system where IOMMU is not supported:


(XEN) I/O virtualisation disabled

You might also see additional output like:


(XEN) Intel VT-d Snoop Control supported.
(XEN) Intel VT-d DMA Passthrough not supported.
(XEN) Intel VT-d Queued Invalidation supported.
(XEN) Intel VT-d Interrupt Remapping not supported.

And if hardware IOMMU is used for PV guest PCI passthru or not:


(XEN) I/O virtualisation for PV guests enabled

Xen doesn't require hardware IOMMU for PCI passthru to PV guests, but having an IOMMU makes it more secure. PCI passthru to Xen HVM guests requires hardware IOMMU.

Xen complains about "hotplug scripts not working"

This problem is often related to udev. Do you have udev installed? Is your udev the correct/supported version? This error usually has more information in the end revealing the real reason.. for example:


Error: Device 0 (vif) could not be connected. Could not find bridge device br0.


Which means exactly what it says.. the guest is configured to to use a bridge called "br0", but there's no such bridge in dom0. Run "brctl show" to verify what bridges you have. Create the missing bridge, or edit the VM cfgfile and make it use another (correct) bridge.


Error: Device 0 (vif) could not be connected. Hotplug scripts not working.


This problem is often caused by not having "xen-netback" driver loaded in dom0 kernel.

The hotplug scripts are located in /etc/xen/scripts by default, and are labeled with the prefix vif-*. Those scripts log to /var/log/xen/xen-hotplug.log, and more detailed information can be found there.


Error: Device 5632 (vbd) could not be connected. Path closed or removed during hotplug add: backend/vbd/2/5632 state: 1"


This problem can be caused by not having "xen-blkback" driver loaded in dom0 kernel.

So when dealing with these problems always check you have all the required xen backend driver modules loaded in dom0 kernel! netbk or xen-netback for networking, and blkbk or xen-blkback for block devices (virtual disks).

Also read the full "xm log", it most probably includes additional information about the problem and the error messages.

I upgraded PV domU from old Xenlinux kernel to new pvops kernel, and now the domU doesn't work anymore!

Many people seem to upgrade their Xen guest PV kernels at the same time they upgrade from older Xen version to Xen 3.4.x or Xen 4.0.x. This is actually not a required step! You can still use your old domU kernels with the new Xen version, and with a new dom0 kernel version. Xen hypervisor is the compatibility layer, so dom0 and domUs can have totally different kernels.

Old Xenlinux PV kernels (linux-2.6.18-xen, ubuntu 2.6.24, debian 2.6.26, sles11 2.6.27, sles11 sp1 2.6.32, opensuse 2.6.31 etc) have different device names for virtual disks and virtual console than the new pvops (upstream kernel.org) Linux kernels. The old device names in Xenlinux kernels usually are:

  • /dev/sdX for virtual disks, for example /dev/sda
  • /dev/xvc0 for the virtual console

The new device names in pvops kernels are:

  • /dev/xvdX for virtual disks, for example /dev/xvda. XVD = Xen Virtual Disk.
  • /dev/hvc0 for the virtual console

So you need to do changes in the guest for it to boot up and work properly with the new kernel:

  • Fix "/etc/xen/<guest>" configuration file and change the virtual disks from /dev/sdX to /dev/xvdX
  • Fix domU kernel root filesystem parameter, ie. change root=/dev/sda1 to root=/dev/xvda1
  • Fix domU kernel console parameter, ie. have "earlyprintk=xen console=hvc0" in the extra="" section.
  • If you use pygrub to load the kernel/initrd from the guest filesystem then you need to make the changes above in the domU /boot/grub/grub.conf (or menu.lst).
  • Make sure the domU kernel has xen-blkfront driver built-in, or if it's built as a module (most common option), then you need to have a proper initrd (ramdisk) image for the domU kernel that actually loads the xen-blkfront driver so that the guest kernel can access the root filesystem! Failing to do this will cause the domU kernel to crash on boot because it can't find the root filesystem!
  • Note that you usually can't use the dom0 initrd image for a domU! dom0 initrd is generated for *dom0*, so it tries to load all the drivers for the *physical* hardware, while you have only virtual hardware in the domU! initrd ramdisk images are system specific, where dom0 and domU are different systems. Usually it's easiest to build an initrd/initramfs image for the domU in the *domU*. So boot the domU up with the old kernel, and generate an initrd image for the new pvops kernel. Make sure the new generated initrd-image loads xen-blkfront driver!
  • You need set up (or modify) a getty for the new console device in the domU init/inittab settings, so you can get a login prompt on the "xm console" session.
  • You need to add the console device name to "/etc/securetty" in the domU so root is allowed to login from the console.
  • If you're having networking problems with the new pvops domU kernels make sure you have "xen-netfront" driver loaded in the new kernel. It's usually built as a module in the recent pvops/upstream/distro kernels.

Also see Migrate_from_Linux_2.6.18_to_2.6.31_and_higher wiki page for more information.

I can't connect to the console of my guest using "xm console <guest>"

Do you have "xenconsoled" process running in dom0? If you do, did you try killing it and restarting it? Also, only one console session per domU can exist at a time. Currently, attempting to use more than one console session per domU will not raise an error, but will result in strange behavior.

Console of my PV guest shows kernel boot messages and then it stops and doesn't work anymore

Do you have a getty configured for the console device in the guest? You usually need to add an entry to /etc/inittab in the guest to make the guest present login prompt on the "xm console" session. Is the getty configured for a correct console device? See the chapter below for correct guest console devices.

Example "/etc/inittab" entry for Debian Lenny (linux-image-2.6.26-2-xen) guest, write this on a new (last) line:


vc:2345:respawn:/sbin/getty 38400 hvc0

Example "/etc/inittab" entry for CentOS 5 (kernel-xen-2.6.18) guest:


co:2345:respawn:/sbin/agetty xvc0 9600 vt100-nav

After modifying /etc/inittab in the guest, run "kill -1 1" to make init (process id 1) reload the configuration file on-the-fly, or reboot the guest. This should make the console work and login prompt appear on the "xm console" session.

NOTE! Some distros (like newer Ubuntu) don't use "/etc/inittab" anymore, but instead you have to configure the gettys in other places!

Ubuntu 6.06 LTS is the last ubuntu version to use "/etc/inittab" configuration file. Ubuntu 6.10 to 9.04 use "/etc/event.d/*" configuration files to configure init. Ubuntu 9.10 and newer use "/etc/init/*.conf".

Example "/etc/init/hvc0.conf" entry for Ubuntu 10.04 Xen PV (linux-image-2.6.32) guest:


# hvc0 - getty
#
# This service maintains a getty on hvc0 from the point the system is
# started until it is shut down again.
start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]
respawn exec /sbin/getty -L hvc0 9600 linux

Console of my PV guest is totally empty, it doesn't show anything, not even kernel boot messages!

This usually means your PV (paravirtual) guest is using a newer pv_ops (upstream Linux kernel.org) kernel that has different console device name. You need to add "console=hvc0" to the guest kernel command line options.

If you're using Xen pygrub or pv-grub to load the kernel from guests filesystem, then you need to configure the guest kernel settings in the guest /boot/grub/grub.conf (or menu.lst), not in dom0! So edit the guest /boot/grub/grub.conf (or menu.lst) and add the "console=hvc0" option there for the default kernel.

If you're not using pygrub or pv-grub, aka you're configuring everything in /etc/xen/<guest> configuration file in dom0, and you have the kernel/initrd in dom0 filesystem, then you can specify the additional "console=hvc0" parameter in the /etc/xen/<guest> configuration file in dom0, on the extra="" line.

What's the correct console device name for my Xen PV guest

  • Xenlinux ("xenified") kernels use "xvc0" as the console device.
  • Upstream kernel.org pv_ops kernels use "hvc0" as the console device

Examples of Xenlinux kernels using "xvc0" console:

  • xen.org linux-2.6.18-xen
  • RHEL5 / CentOS5 kernel-xen 2.6.18
  • Debian Etch 2.6.18-6-xen
  • Debian Lenny 2.6.26-2-xen
  • Ubuntu 8.04 LTS "hardy heron" 2.6.24 xen kernel
  • Gentoo Xenlinux kernels
  • Novell SLES 10 and SLES 11 xen kernels
  • OpenSUSE xen kernels
  • Various "xenified" forward-ports of the Novell SLES/OpenSUSE Xenlinux patches (2.6.27, 2.6.29, 2.6.30, 2.6.31, 2.6.32, 2.6.33, 2.6.34)

Examples of pv_ops domU kernels using "hvc0" console:

  • All upstream/mainline kernel.org Linux kernels since 2.6.26.
  • Fedora 10, Fedora 11, Fedora 12, Fedora 13 kernels
  • Ubuntu 8.10 2.6.27 server-kernel
  • Ubuntu 9.04 2.6.28 linux-image-server
  • Ubuntu 9.10 2.6.31 ec2-kernel
  • Ubuntu 10.04 ("Lucid Lynx") 2.6.32 kernel
  • Debian 6.0 ("Squeeze") 2.6.32 kernels

How do I exit domU "xm console" session

Press ctrl+] or if you're using Putty press ctrl+5.

Everything seems OK but I still can't access the domU "xm console"!

A couple of things to check:

  • Do you have some old already running "xm console" session running on the host? possibly stuck in some dead ssh connection?
  • Do you have virt-manager running on the host 'reserving' the guest console?
  • Did it work earlier?
  • Do you have problems with only one guest, or with all guests?
  • Does shutting down and then re-starting the guest help?
  • Are you really sure you are running a getty in the guest for the correct console device? :)
  • Is the guest really up and running? Can you access it over the network with ssh? Can you ping it?

Xen network-bridge script not working in Debian Lenny, errors about eth0

You edited "/etc/xen/xend-config.sxp" in your Debian Lenny dom0/host, and changed the default "network-dummy" to "network-bridge". When you reboot dom0, and xend is started, it gives error like this:

ifdown: interface eth0 not configured

RTNETLINK answers: Device or resource busy

This error can be caused by non-common settings for eth0 in "/etc/network/interfaces" configuration file. Try cleaning up the configuration, and having only a very basic ipv4-only configuration with a static IP, to begin with. Remove IPV6 configuration. Remove all the IP aliases. Reboot and try again. First get it working, then possibly later modify the configuration to be more advanced.

Xend does not start when using pv_ops dom0 kernel?

You need to have Xen event channel (evtchn) driver included in your dom0 kernel for xend to be able to start. If Xen event channel support is compiled as a module, use "lsmod" to check that you have xen-evtchn (or xen_evtchn) driver module loaded. It not, use "modprobe" to load it. If Xen event channel support is statically built-in to the dom0 kernel then you don't need to load any modules.

You also need xen-gntdev driver loaded.

In December 2009 pv_ops dom0 kernel modules were renamed to have a "xen-" prefix in them, ie. "evtchn.ko" became "xen-evtchn.ko", and "gntdev.ko" became "xen-gntdev.ko".

This makes Xen 3.4.x xend fail to start, because it tried to load "evtchn.ko", but that doesn't exist. You need to load "xen-evtchn.ko" and then start xend. Fedora 12 xen-3.4.2-2 rpms have this problem fixed. If your xend does not automatically load evtchn or xen-evtchn driver module, please load it manually with modprobe.

Also make sure you have xenfs mounted to "/proc/xen", that's needed aswell. Do you have files under "/proc/xen/" directory? You should have for example:


# ls /proc/xen/
capabilities  privcmd  xenbus  xsd_kva  xsd_port
# cat /proc/xen/capabilities
control_d

"control_d" value in "/proc/xen/capabilities" means you're in Xen dom0 ("control domain").

Do you have files under "/dev/xen/" ? You should have there at least the following device nodes:


# ls -la /dev/xen
total 0
drwxr-xr-x  2 root root     80 Jun 19 19:17 .
drwxr-xr-x 20 root root   4580 Jun 19 19:33 ..
crw-rw----  1 root root 10, 58 Jun 19 19:17 evtchn
crw-rw----  1 root root 10, 57 Jun 19 19:17 gntdev

If you're missing those device nodes you can use "mknod" to create them manually. Creating those device nodes should happen automatically by udev when you have xen-evtchn and xen-gntdev driver modules loaded.

You can see the correct major/minor for the device nodes from "/proc/misc":


# cat /proc/misc
 57 xen/gntdev
 58 xen/evtchn

Note how they match the values from the previous "ls -la /dev/xen". If the major/minor numbers don't match then xenstored and xend won't be able to start/function. Note the major/minor numbers for device nodes are dynamic nowadays, so you need to verify they're properly set up for your system.

How can I limit the number of vcpus my dom0 has?

The recommended way is to use "dom0_max_vcpus=X" boot time option for Xen hypervisor (xen.gz) in grub.conf. You need to reboot after modifying grub.conf. Using this method makes sure you allocate resources only for the actual number of vcpus you need in dom0.

Another option is to configure "(dom0-cpus X)" option in /etc/xen/xend-config.sxp, but it works in a different way: dom0 boots up with all the cpus visible to it, and when xend starts, it'll hot-remove the extra vcpus from dom0, and only leaves the number of vcpus specified in (dom0-cpus) to dom0. This option has the benefit that vcpus can be later added to dom0, if needed.

Can I dedicate a cpu core (or cores) only for dom0?

Yes, you can. It might a good idea especially for systems running IO intensive guests. Dedicating a CPU core only for dom0 makes sure dom0 always has free CPU time to process the IO requests for the domUs. Also when dom0 has a dedicated core there are less CPU context switches to do, giving better performance.

Specify "dom0_max_vcpus=X dom0_vcpus_pin" options for Xen hypervisor (xen.gz) in grub.conf and reboot.

After rebooting you can verify with "xm vcpu-list" that dom0 vcpus are pinned to only use the matching physical cpus.

The next step is to configure all the guests (domUs) to NOT use those same physical cpus. This can be done by specifying for example cpus="2-7" to all /etc/xen/<guest> cfgfiles. This example would leave physical cpus/cores 0 and 1 only for dom0, and make the guests use cpus/cores 2 to 7.

Booting Xen with GRUB2 fails?

It seems GRUB2 destroys the first parameter from Xen hypervisor "multiboot" and dom0 kernel "module" lines. For dom0 kernel this usually means root= parameter gets lost and thus dom0 kernel fails to set up the root filesystem and the boot fails. For xen.gz this usually means parameters like "dom0_mem=" or "dom0_vcpus" will get lost, whatever is the first parameter.

You can work around this problem by specifying "dummy=dummy" as the first parameter in grub2 config file for "multiboot" and "module" lines. This will fix the problem with Xen 4.0.0 and older hypervisor versions.

See this link for a working GRUB2 + Xen example:http://old.nabble.com/Strange-interaction-from-grub2-and-XEN-td26464067.html

The dummy workaround is not required anymore with Xen 4.0.1 and newer versions. See this patch for the Xen GRUB2 fix: http://xenbits.xen.org/xen-unstable.hg?rev/4207549948a4 and http://xenbits.xen.org/xen-4.0-testing.hg?rev/1da5224a2875 .

Other things that could go wrong. Did you modify the config file manually? If yes, you might need to add "insmod multiboot" (or "insmod multiboot2")

32bit Xen hypervisor crashes when using GRUB2

You get the following messages on the (serial) console when GRUB2 boots 32bit PAE Xen hypervisor:


(XEN) ****************************************
(XEN) Panic on CPU 0:
(XEN) Cannot access memory beyond end of bootstrap direct-map area
(XEN) ****************************************
(XEN)
(XEN) Reboot in five seconds...
(XEN) Unknown interrupt (cr2=00000000)

This is because your version of GRUB2 dumps the dom0 kernel and initrd image to a memory region that Xen cannot access. Changing to different GRUB2 version fixes the problem. Another option is to switch to 64 bit Xen hypervisor. Note that you can still run 32bit dom0 on 64bit Xen hypervisor.

This problem has been fixed in Xen 4.0.0-rc8 and newer versions. You can use new enough 32bit PAE Xen hypervisor with GRUB2. See these changesets for patches: http://xenbits.xen.org/xen-unstable.hg?rev/bcc09eb7379f and http://xenbits.xen.org/xen-unstable.hg?rev/377433a77d70

In dom0 how can I access and mount partitions inside a Xen disk image?

The easiest way is to use "kpartx" in dom0. It allows you to easily access all the partitions inside an image file or inside LVM volume.

You can use "kpartx -l /path/guestdisk" to list the partitions the image has, and "kpartx -a /path/guestdisk" to add the partition mappings. After the device mapper (dm) mappings have been added, you can access the partitions using "/dev/mapper/guestdiskpX" block devices. There's a separate block device for each partition. You can mount, copy, format, or whatever you need to do and it works just like for "real" partitions.

When you're done using the partitions in dom0, and you have unmounted them, you have to remove the kpartx mappings by running "kpartx -d /path/guestdisk". It's important to do this before using the image again for other purposes or starting the guest again! If you forget to remove the mappings the image might get corrupted when you access the image with other tools or start the guest.

Another neat way which works for me, is to simply attach the block device to dom0 as you would to a domU. e.g.:


xm block-attach Domain-0 file:/disk/image/for/domU xvda w

I have found this to work for OSs which use slices (such as Solaris and *BSD), and are not picked up using kpartx. You should check dmesg and see which device nodes were created for you. Once you are done working with the disk image you can:


xm block-detach Domain-0 xvda

If your domU is LVM-based, see Access_Disk_from_DomUs_when_Xen_was_installed_with_LVM

Xen dom0 complains about not enough free loop devices when trying to start a new domU or when trying to "mount -o loop" from the cmdline

Linux "loop" module has max 8 loop devices (/dev/loop*) as a default. Every Xen "file:" backed domU disk uses one loop device in dom0, and if you do "mount -o loop disk.img /mnt" in dom0 that uses a loop device aswell.

You can check all the loop devices in use by running "losetup -a". You can detach a loop device (free it) by running "losetup -d /dev/loopX" when it's not mounted or otherwise in use.

You can increase the amount of available loop devices by loading the linux "loop" module with an option "max_loop=X", for example "modprobe loop max_loop=128". You can add "max_loop=X" option to /etc/modprobe.conf, /etc/modules (or whatever cfgfile your dom0 distribution uses for module options) to make it boot time default.

You can also use Xen "phy:" backed LVM volumes instead of disk images. "phy:" doesn't require loop devices.

As an example for Debian Lenny check this: http://www.howtoforge.com/virtualization-with-xen-on-debian-lenny-amd64

Such an error message may also be indicative of other issues (such as the guest crashing and restarting so quickly that xend does not have time to free the older loopback device).

Debian Lenny Xen PV domU doesn't start, in the console it says "Waiting for root file system" and then drops to a busybox shell

Is your root device set correctly for the guest (domU) kernel? Most probably you're using a wrong root= parameter, and thus the system cannot mount the root device and start. Check the early boot messages from the kernel, there should be a line starting with "Command line:". There you can see the parameters passed to the domU kernel. Do you see the correct root device there?

Remember the root= passed to a PV domU must be a path accessible from within the guest

You can set and edit the root device in dom0 from /etc/xen/<guest> configuration file. root device is specified either in "root=" line, or on "extra=" line. The configured root device should match the disk configuration for the guest.

Another problem can be that you're using wrong initrd image for the domU kernel. You should use an initrd generated for the guest, not the same initrd as you use to boot the dom0.

My Xen PV guest kernel crashes, how can I debug it and get a stack/call trace?

Edit "/etc/xen/<guest>" cfgfile, and set:


on_crash="preserve"

Then when your domU guest crashes, run this in dom0:


/usr/lib/xen/bin/xenctx -s System.map-domUkernelversion <domUid> <vcpu-number>

If you're running 64bit dom0, then xenctx might be under "/usr/lib64/". This command will give you a stack trace of the crashed domU kernel on the specified vcpu, allowing you to see where it crashes. You should get the stack trace for every vcpu your guest has! Vcpu numbers start from 0.

Note that you need to use the "System.map" file from the exact kernel version the domU is running, otherwise the stack trace results are not correct!

Can I run graphical X applications in Xen dom0 without installing X server and display drivers?

Yes, you can. Many people prefer to not install any graphical drivers or X on dom0 for maximum stability. You can still run graphical applications using ssh X11 forwarding. You can run for example "virt-manager" in dom0 and display the GUI on your desktop/laptop over ssh.

1) Install "xorg-x11-xauth" package in dom0 (centos/rhel/fedora, "xauth" in debian/ubuntu, other distros might have different name for it).

2) Log in to dom0 from your Linux workstation like this: ssh -X root@dom0.

3) After the password is accepted you should notice ssh setting up the ssh X11 forwarding like this:


/usr/bin/xauth:  creating new authority file /root/.Xauthority

4) You can now run graphical X applications, for example vnc viewer, virt-viewer etc, and the GUI will be tunneled securely over ssh to your local X desktop.

If you're using Windows you can install "xming" and "putty". Start Xming, and after that enable X11 forwarding in putty settings (Connection -> ssh -> X11 -> Enable X11 forwarding) and then connect to your dom0.

What emulated NIC types/models are available in Xen HVM fully virtualized guests?

The following emulated network interface cards are available for Xen HVM guests in Xen 3.4:

  • e100
  • e1000
  • rtl8139
  • ne2k_pci
  • pcnet

Emulation is done by Qemu-dm running for each Xen HVM guest. Intel e1000 is known to be the best performing emulated NIC. Even faster is to use PV-on-HVM drivers, which totally bypasses emulation.

Older Xen versions might not have all the above NIC options available.

Can I set up Xen HVM Linux guest to display the kernel boot messages on "xm console" ?

Yes, you can. You need to add this line to the "/etc/xen/<hvmguest>" configuration file in dom0:


serial='pty'


And then in the HVM guest grub.conf (inside the HVM VM) configure kernel logging to the (virtual) serial port like this:


#============================================================
# display the grub kernel selector menu on the serial console
serial --unit=0 --speed=9600
terminal --timeout=5 serial console
# kernel entries title openSUSE 11.1 - 2.6.27.29-0.1
root (hd0,1)
kernel /boot/vmlinuz-2.6.27.29-0.1-default root=LABEL=ROOT resume=LABEL=SWAP splash=silent showopts console=tty1 console=ttyS0
initrd /boot/initrd-2.6.27.29-0.1-default
#================================================


So basicly you need to add "console=ttyS0" to the kernel line, and also configure grub to display the kernel selector on the (virtual) serial console using "serial" and "terminal" settings.

After these settings "xm console <hvmguest>" works just like it does for PV (paravirtual) guests and allows you to see grub and the Linux kernel boot messages of the HVM guest. You can also use other tools (minicom, screen, etc) in dom0 to access the VM console pty device directly.

Also remember to set up a getty in the guest for the serial console device, ttyS0, so that you can also login from the serial console! See above for tips about that.

How can I boot Xen HVM guest from a virtual emulated floppy, using an image file as the floppy?

This is the required configuration in "/etc/xen/<hvmguest>" cfgfile:


fda = '/path/to/floppy.img' boot=a

You can also use this cmdline method while creating the guest:


xm create /etc/xen/hvmguest.cfg fda=/path/to/floppy.img boot=a

Important note: Make sure SElinux access restrictions are not blocking access to /path/to/floppy.img!

How do I change virtual/emulated CD .iso image for a Xen HVM guest?

First check "/etc/xen/<guest>" cfgfile and check what is your cdrom device in the guest. It's usually "/dev/hdc".

An example to swap the emulated CD using an iso image:


xm block-configure <guest> file:/path/to/new/cd.iso hdc:cdrom r

Are there FreeBSD Xen PV kernels/images available?

Please check the following links: http://wiki.freebsd.org/AdrianChadd/XenImages and http://wiki.freebsd.org/AdrianChadd/XenHackery .

FreeBSD Xen wiki: http://wiki.freebsd.org/FreeBSD/Xen .

Tutorial how to install 32bit Xen PV FreeBSD domU on a Debian Lenny Xen dom0, using LVM volumes: http://silverwraith.com/blog/?p=83 . Another Freebsd Xen PV domU tutorial: http://forums.freebsd.org/showthread.php?t=10268 .

Where can I find information about NetBSD Xen support?

NetBSD supports both Xen dom0 and PV domUs. For more information see: http://www.netbsd.org/ports/xen/

What's Xen pygrub?

Pygrub allows you to simply specify in Xen PV guest "/etc/xen/<guest>" cfgfile:


bootloader = "/usr/bin/pygrub"

Which replaces all these options:


kernel = "vmlinuz-2.6.32.12"
ramdisk = "initrd-2.6.32.12.img"
root = "/dev/xvda1"
extra = "earlyprintk=xen console=hvc0"

When you start a Xen PV guest pygrub will be executed in dom0 and it'll access the guest disk configured in the "/etc/xen/<guest>" cfgfile, find "/boot/grub/grub.conf" (or menu.lst) from the guest filesystem, parse it, fetch the kernel, initrd image and kernel parameters configured in the guest to dom0, and then boot up the guest using those kernel + initrd + parameters. All the domU specific settings are configured inside the domU, in grub.conf.

Requirements for using pygrub for Xen PV domUs:

  • Pygrub binary available in dom0, installed together with Xen.
  • Pygrub configured for the guest in "/etc/xen/<guest>" cfgfile
  • Guest has /boot/grub/grub.conf (or menu.lst) with proper entries in it. There's actually no need to install the real grub to the MBR of the guest disk, it's enough to just have the grub.conf/menu.lst in the guest.
  • If the guest has GRUB2 configuration file (for example Ubuntu 10.04 or Debian Squeeze 6.0) then you need to have new enough Xen pygrub in dom0. Pygrub versions included in Xen 4.0.2 and 4.1.1 and newer properly support parsing GRUB2 guest config files.

So pygrub makes it much easier to:

  • Manage the guest kernels inside every guest, keeping the guest distribution package managers (dpkg,rpm) and package dependencies happy.
  • Upgrade guest kernels without touching dom0 or guest configuration files in "/etc/xen/" in dom0.
  • Each guest distribution can easily use the default kernel provided by the distribution.
  • Pygrub allows you to select which kernel to boot, in the "xm console <guest>" session. It's easiest to start the guest with "xm create -f /etc/xen/guest -c" to attach to the console immediate for selecting the kernel from pygrub menu. If nothing is chosen then the default entry will be booted automatically.

Management tools like "virt-install" and "virt-manager" will use Xen pygrub as a default when you install new guests using them.

What's Xen pvgrub?

Xen pvgrub is like pygrub but more secure.

Pygrub is executed in dom0, so it could have security concerns/issues, if bugs were found from it. Pvgrub is executed in the Xen PV guest, so there are no such security issues with it.

Pvgrub is included in Xen 3.3 and newer versions. Pvgrub is a separate build and separate tool, so usually it's easier to begin with pygrub, and then later switch to pvgrub.

See PvGrub wiki page for more information and usage of pvgrub.

Does Xen pygrub support booting PV guests using GRUB2 config files?

Yes, pygrub in Xen 4.0.1 supports guests using GRUB2 config files (Ubuntu 10.04 LTS "Lucid Lynx"). Later the format of GRUB2 config files was changed, and Xen 4.0.2 and 4.1.1 (or newer versions) properly support this newest version of GRUB2 config files (Debian 6.0 "Squeeze").

Also there's a patch for RHEL/CentOS 5.5 version of pygrub to support GRUB2 (Ubuntu 10.04) guests: https://bugzilla.redhat.com/show_bug.cgi?id=577511 and latest version of GRUB2 config files (Debian 6.0 "Squeeze"): https://bugzilla.redhat.com/show_bug.cgi?id=675733 . These RHEL5 Xen pygrub patches are included in RHEL5.6 (first patch, Ubuntu 10.04) and RHEL5.7 (second patch, Debian 6.0).

Can I browse the Xen source trees online?

Yes, you can browse the source tree and see the changelogs/summaries and track changes online from the XenRepositories wiki page.

Can I browse the Xen Qemu-dm (HVM guest ioemu) source repositories online?

Yes, you can see the changelogs/summaries and track changes online from the XenRepositories wiki page.

I'm using Xen 4.0.0 with the latest pvops 2.6.32.x dom0 kernel (2.6.32.15+) and xend/xenstored doesn't start anymore?

Yes, this is a known issue. pvops dom0 kernel in xen/stable-2.6.32.x branch changed to using proper evtchn and gntdev device node names ("/proc/xen/*") in June 2010, which triggers a bug in libxc in Xen 4.0.0. This bug has been fixed in Xen 4.0.1-rc2 and newer versions. So please upgrade your Xen to 4.0.1-rc2 or newer version.

Alternatively you can apply this patch if you want to keep using Xen 4.0.0: http://xenbits.xen.org/xen-4.0-testing.hg?rev/0e1521f654f2 .

Another option is to manually fix the device node major/minor numbers by re-creating the device nodes manually and then re-starting xenstored and xend. You can see the proper major/minor for "/dev/xen/evtchn" and "/dev/xen/gntdev" from "/proc/misc":


# cat /proc/misc | grep xen
57 xen/gntdev
58 xen/evtchn

# ls -la /dev/xen
total 0
drwxr-xr-x  2 root root     80 Jun 19 19:17 .
drwxr-xr-x 20 root root   4580 Jun 19 19:33 ..
crw-rw----  1 root root 10, 58 Jun 19 19:17 evtchn
crw-rw----  1 root root 10, 57 Jun 19 19:17 gntdev

Check the proper major/minor values from "/proc/misc" and then use mknod to create the device nodes manually using the proper values. After that xenstored and xend should start normally. For more information see this email: http://lists.xensource.com/archives/html/xen-devel/2010-06/msg01129.html and XenParavirtOps wiki page.

Arp change notification problems after live migration when using pvops 2.6.32.x dom0 kernel

You need to have new enough version of pvops dom0 kernel (xen/stable-2.6.32.x branch, Aug 2010 or newer) and then you can enable "net.ipv4.conf.<dev>.arp_notify" sysctl setting for the devices where you want to send the arp notifications (gratuitous ARP). See this email for more information: http://lists.xensource.com/archives/html/xen-devel/2010-08/msg01595.html .

Starting xend fails?

"ERROR Internal error: Could not obtain handle on privileged command interface (2 = No such file or directory)".

or "xm" commands give the following error message: "Error: Unable to connect to xend: No such file or directory. Is xend running?".

Please check these things:

  • First of all - are you actually running Xen? Did you modify grub.conf to boot Xen hypervisor (xen.gz)? You can verify with "dmesg | grep -i xen" or "grep -i xen /var/log/dmesg" - you should see at least a line like "Booting paravirtualized kernel on Xen" when you've actually booted into Xen dom0.
  • Do you have xenfs mounted? Check "/proc/xen" directory, you absolutely NEED to have files there.

Value of "control_d" in file "/proc/xen/capabilities" means you're in Xen dom0:

# ls /proc/xen/
capabilities  privcmd  xenbus  xsd_kva  xsd_port

# cat /proc/xen/capabilities
control_d

Maybe you need a line like this in "/etc/fstab":

none /proc/xen xenfs defaults 0 0

After adding that line to "/etc/fstab" reboot or run "mount /proc/xen".

  • Do you have "xen-evtchn" driver loaded? Check with "lsmod | grep -i xen" and load with "modprobe xen-evtchn".
  • Do you have "xen-gntdev" driver loaded? Check with "lsmod | grep -i xen" and load with "modprobe xen-gntdev"
  • Do you have the required device nodes under "/dev/xen/" directory? An example:
# ls -la /dev/xen
total 0
drwxr-xr-x  2 root root     80 Jun 19 19:17 .
drwxr-xr-x 20 root root   4580 Jun 19 19:33 ..
crw-rw----  1 root root 10, 58 Jun 19 19:17 evtchn
crw-rw----  1 root root 10, 57 Jun 19 19:17 gntdev
  • Correct major/minor numbers for those device nodes can be checked from file "/proc/misc", the values are dynamic and might change from system to system:
# cat /proc/misc | grep xen
57 xen/gntdev
58 xen/evtchn
  • Do you have SElinux running? Did you try turning it off? Run "setenforce 0" or disable it in "/etc/selinux/config" and reboot dom0.
  • Do you have xenstored or oxenstored running? xend required xen store daemon to be running before starting xend.
  • If you're using certain Debian or Ubuntu (10.04+) versions, and you're compiling Xen from source (.tar.gz), you might need to run "make install-tools PYTHON_PREFIX_ARG=" to install Xen.. notice the empty argument to PYTHON_PREFIX_ARG to get the Xen python modules installed to correct directory location.
  • If you upgraded from older Xen version, did you first make sure all the files from earlier Xen versions were completely removed before installing the new version? Xend might fail to start when there's a bad installation mixing files from multiple Xen versions.

For other troubleshooting tips related to pvops dom0 kernels try reading XenParavirtOps wiki page.

How to specify custom (non-default) vif-script for some domU network interface?

Here's an example how to have 2 nics (vifs) for the domU, each using different vif-script:


vif = [ 'mac=00:16:5e:72:04:01,bridge=xenbr0,script=your_custom_script1', 'mac=00:16:5e:72:04:02,bridge=xenbr1,script=your_custom_script2' ]


Problems with Xen on Redhat Enterprise Linux 5 (RHEL5) or CentOS5

Try these links:

I'd like to run Xen hypervisor/dom0 on Redhat Enterprise Linux 6 (RHEL6)

See this wiki page for a Xen 4.0 with RHEL6 tutorial and more info: RHEL6Xen4Tutorial .

Starting Xen HVM guests fails when using Xen 4.x and gcc 4.6

When Xen 4.x is compiled with gcc 4.6 compiler it seems Xen hvmloader binary gets miscompiled and makes it impossible to run HVM VMs. This issue does not happen when using gcc 4.5 or older gcc versions. The error message might be something like this:


(XEN) io.c:194:d18358 MMIO emulation failed @ 0018:9ffff: 00 e0 de be 00 83
(XEN) hvm.c:1099:d18358 Triple fault on VCPU0 - invoking HVM system reset.


or then just a line with words "HVM Loader" and nothing more, followed by a VM crash a couple of seconds after it started. This bug is fixed in xen.org repositories, but the fix is not yet in Xen 4.0.2 or 4.1.1, because the bug was found and fixed after the release of Xen 4.0.2 and Xen 4.1.1. See this email for info about the bugfix changesets: http://lists.xensource.com/archives/html/xen-devel/2011-07/msg00922.html . Especially users of Debian Wheezy, Ubuntu 11.10+ and Fedora 15/16 have seen this issue.

xm: ImportError: No module named xen.xm

After installing Xen from source (either mercurial/hg repository or from .tar.gz) you get an error when trying to start xend or run "xm" commands. The error looks like:

ImportError: No module named xen.xm


This means Xen python modules are not installed to correct directory. Debian/Ubuntu changed the location of python modules include directory, so you need to use the following when installing Xen:


make install-tools PYTHON_PREFIX_ARG=


Notice the empty parameter to PYTHON_PREFIX_ARG. Re-install the modules/tools and the problem should get fixed.

With Linux 3.0 as a dom0 kernel using dom0_mem=<xyz> option for Xen in grub.conf doesn't work

This is a known bug in Linux 3.0 kernel. It is fixed in Linux 3.1 and Linux 3.0.5 stable update. If using 3.0 older than 3.0.5 the workaround is to use, in addition to "dom0_mem=2048M" for Xen hypervisor (xen.gz), also "mem=2048M" option for dom0 Linux kernel (vmlinuz) in grub.conf.

Also see Linux_30_bugs: wiki page for other known issues in upstream Linux 3.0 kernel.

How do I change the resolution of Xen PV domU vfb graphical VNC console?

You can specify the pvfb (paravirtual framebuffer) resolution and bpp (amount of colors) for the VM while loading the xen-fbfront driver in the domU kernel.

If xen-fbfront is built as a module, use the following options:

modprobe xen-fbfront video="32,1024,768"

Or add the options to "/etc/modprobe.conf", or whatever file your domU distro uses for driver module options. Note that you might need to regenerate the initrd/initramfs image for the domU kernel if the xen-fbfront driver is auto-loaded at boot time.

Or if xen-fbfront driver is built-in to the domU kernel, use the following cmdline options for the domU kernel:

xen-fbfront.video=32,1024,768

If you're using Xen pygrub you can place that option to grub configfile inside the domU "/boot/grub/" directory, or if you're using kernel/ramdisk from dom0, then add those options to "extra" line on /etc/xen/<domU> on dom0.

How can I get resolutions larger than 800x600 for Xen HVM guest graphical VNC console?

Edit "/etc/xen/<hvmvm>" cfgfile and add the following options:

stdvga=1
videoram=16

This will increase the amount of virtual video memory in the HVM VM, allowing it to use bigger resolutions, up to 2048x1536 @ 32bpp. If you don't specify "stdvga=1", ie. you keep using the Cirrus emulated graphics adapter, resolutions up to 1280x1024 are possible with "videoram=16".

After increasing the size of vram configure the resolution from inside the HVM guest in the usual way, just like you'd do on baremetal/native, using the resolution selector or configfile provided by the operating system in the VM.

I'm trying to create a new Xen VM but I get error there's not enough free memory

Tools like "free" or "top" in Xen dom0 show that you have a lot of free memory, but Xen still complains that there's not enough free memory to create/start a new VM, giving errors such as "Out of memory". This usually happens because dom0 is using all the memory, so there's no free memory in the Xen hypervisor (xen.gz) for other VMs. Note that dom0 is actually a Xen virtual machine!

Xen hypervisor dedicates physical memory for each VM, so you need to have actual free unallocated memory in the hypervisor to start a VM. You can check the Xen hypervisor memory usage with the following commands:

Check the amount of total, used and free memory in Xen hypervisor:

xm info


and check how much memory each VM is using:


xm list


It's possible that dom0 is using most of your memory and Xen hypervisor doesn't have any free memory left. You should use "dom0_mem=" setting for Xen in grub to configure dom0 a fixed/dedicated amount of memory, so the rest of the memory is free for other VMs to use. See XenBestPractices: wiki page for more info about configuring "dom0_mem=" option for Xen.

Error: (4, 'Out of memory', 'panic: xc_dom_core.c:442: xc_dom_alloc_segment: segment ramdisk too large (0xee93 > 0x8000 - 0x1755 pages)')

Getting this error when trying to start a new VM (running "xm create") means you're trying to use too big ramdisk image (initrd/initramfs file) for the domU. The ramdisk image configured is bigger than the amount of available memory for the VM. Remember the ramdisk images are compressed, and they need to fit as uncompressed to the domU memory. The solution is to edit "/etc/xen/<domU>" configuration file and increase the amount of memory for the VM, or switch to using a smaller ramdisk image for the domU kernel.