this is obsolete doc -- see http://doc.nethence.com/ instead
XEN usage and tweaks
Custom XEN guest wrappers
Install custom XEN guest wrappers,
cd ~/
mkdir -p bin
cd bin
wget http://pbraun.nethence.com/code/sysutils_xen/...
wget http://pbraun.nethence.com/code/sysutils_xen/...
wget http://pbraun.nethence.com/code/sysutils_xen/...
#for f in `ls -1 ~/code/sysutils_xen/`; do
# ln -s ~/code/sysutils_xen/$f
#done
Making a guest template or backup
Remove the SSH keys from the guest,
rm -f /etc/ssh/*key*
ll /etc/ssh/
Tar up the guest,
tar czSf centos5x32.tar.gz centos5x32
Note. -S, --sparse for sparse file virtual disk
Then extract it elsewhere and use the following clone procedure, but use 'mv' instead of 'cp'.
Cloning / renaming a guest
Make sure the source guest is shut down and proceed,
cd /data/guests/
cp -R centos5x32 newguest
#mv centos5x32 newguest
cd newguest
sed 's/centos5x32/newguest/g;
s/ip=[^,]*,/ip=192.168.11.12,/;
s/vifname=[a-z0-9]*/vifname=vnewguest_0/;
' centos5x32 > newguest
rm -f centos5x32
mv centos5x32.disk newguest.disk
Note. 'cp' is sparse capable by default
You can then start the guest and change its network configuration.
Launch guests at boot time
Enable guests at boot time,
cd /etc/xen/auto/
ln -s /data/guests/guestX/guestX
Troubblshooting
When starting a domU, if you get this error msg while "/kern" is mounted,
Error: [Errno 2] No such file or directory: '/kern/xen/balloon'
It means there's not enough memory left for the guest.
When starting a domU, if you get this error msg,
Error: (22, 'Invalid argument')
the dom0 and domU kernels don't match (PAE vs. non-PAE).
If you get this error when trying to launch a guest,
xc_dom_boot_mem_init: can't allocate low memory for domain
just make sure the guest architecture is supported by the dom0 :-) (e.g. a x86_64 guest might not be supported on x86 host)
Hot migration
Once your XEN farm is configured (IP settings and shared disk filesystem), edit the configuration,
vi xend-config.sxp
like,
(xend-http-server yes)
(xend-relocation-server yes)
(xend-port 8000)
(xend-relocation-port 8002)
(xend-relocation-address '')
### (xend-relocation-hosts-allow '')
Basic dom0 management
On RHEL5 there's a graphical interface,
virt-manager
Note. press "Ctrl" to release the mouse from the guest console
Back to the terminal, list the currently started virtual machines,
xm list
Note. dom0 is the base system, not a VM.
Start a vm,
xm create path/to/vmconfig
to get its console immediately,
xm create path/to/vmconfig -c
or once the VM is started, you can get the console afterwards,
xm console vmname
To exit from the console,
ctrl-altgr-] (something like that)
Besides, it's very convenient to use VM consoles inside a screen session, having a different VM console on each screen window. It's possible to kill the console simply by killing the screen window,
^A k
GNU Screen configuration : http://pbraun.nethence.com/doc/misc/screen.html
To stop a VM,
xm shutdown vmname
Note "xm destroy" will act the same as an immediate poweroff, while "xm sh" should tell the system to shutdown properly. Check wheter it behaves correctly within both, HVM and paravirtualized guests.
Note. it's possible to use shortcuts. Instead of the full xm commande, do
xm cr <vmname> # create
xm co <vmname> # console
xm sh <vmname> # shutdown
xm de <vmname> # destroy
xm li # list
Advanced dom0 management
Detailed information,
xm list -ll
xm info
See what's going on,
xm vcpu-list
xm tmem-list
xm network-list
Set dom0's allocated memory dynamically,
xm mem-set 0 512M
References
RHEL Kernel Performance Optimization and Characterization and Tuning : http://people.redhat.com/dshaks/Larry_Shak_Perf_Summit08.pdf
Xen Disk I/O Benchmarking: NetBSD dom0 vs Linux dom0 : http://users.piuha.net/martti/comp/xendom0/xendom0.html
Xen Virtualization on Linux and Solaris : http://bderzhavets.blogspot.com/
XEN: Install SLES 9 SP3 domU on SLES 10 XEN dom0 : http://www.novell.com/coolsolutions/feature/18236.html
Xen DomU Linux Installer Creation : http://emmeff.blogspot.com/2006/07/howto-install-opensuse-10.html
Virtualization in Fedora 8 : http://fedoraproject.org/wiki/Docs/Fedora8VirtQuickStart
Xen3 on CentOS4 : http://www.karan.org/blog/index.php/2005/12/06/xen3_on_centos4
Xen, Virtualization on Linux : http://www.redhat.com/magazine/004feb05/features/virtualization/
(FR) Virtualisation avec Xen : http://www.bortzmeyer.org/xen.html
Management tools
Virt-manager : http://virt-manager.et.redhat.com/
Convirt GUI : http://xenman.sourceforge.net/
virsh : http://www.redhat.com/docs/manuals/enterprise/RHEL-5-manual/Virtualization-en-US/ch-virt-task-virsh.html
Enoalism GUI : http://www.enomalism.com/
Clobber : http://cobbler.et.redhat.com/