IT Blog

Linux Xen

XEN Virtualization notes

I have recently been working on virtualizing Windows and Linux machines using Xen. A few things popped up along the way and a bit of research was done to make things work properly, these are some of the notes I took.

Depending on the requirements, LVM may make sense for your implementation. One particular advantage is LVM snapshots for backups.

A setup I am working on now consists of 4 systems with a dedicated LVM device, and an lvm based mount point for file based VMs.

# vgs
VG #PV #LV #SN Attr VSize VFree
xen1vg 1 6 0 wz--n- 1.96T 1.47T

# lvs
LV VG Attr LSize Origin Snap% Move Log Copy%
vm1rootlv xen1vg -wi-a- 80.00G
vm2rootlv xen1vg -wi-a- 80.00G
vm3rootlv xen1vg -wi-a- 80.00G
vm4rootlv xen1vg -wi-a- 80.00G
xen_master_img-lv xen1vg -wi-a- 80.00G
xenimages1lv xen1vg -wi-ao 100.00G

If you decide to use a file based VM, but use a directory other than /var/lib/xen/images to store your image files, then selinux will get in the way. Use the following:

# semanage fcontext -a -t xen_image_t "/<new_directory>(/.*)?"

# restorecon -R /<new_directory>/
If something is not working check /var/log/audit/audit.log and ‘dmesg’, disable selinux: ‘setenforce 0’.
If your system is installing or using a file based cdrom device, and you need to insert or change to another disk:
# xm block-list <vmname>
Vdev BE handle state evt-ch ring-ref BE-path
768 0 0 1 -1 -1 /local/domain/0/backend/vbd/14/768
5632 0 0 1 -1 -1 /local/domain/0/backend/vbd/14/5632

# xm block-detach <vmname> 5632 -f

# xm block-attach <vmname> file:/xen-images/nextdisk.iso hdc:cdrom r

One thought on “XEN Virtualization notes”

  1. LVM works if you are just having one host, but for a hosting company providing Xen based virtualization to their customers LVM will not be good, as you want to be able to migrate a customer to a host which has the right capacity to run their VM and also when something goes wrong and the host dies, you want to get the VM’s up and running fast so that the customers will not have downtime, then you choose something more fit for the fight like a clustered file system for example clustrefs, glusterfs or ceph, for KVM solution you also have sheepdog as a good alternative.
    For those who just run a one host Xen, don’t forget to have a hardware raided disk in the bottom, RAID1 if you are cheap and RAID5 if you want to have it a bit more safe, as loosing a disk in a LVM can be really painful.
    Today you also have other options than LVM, for example zfs and btrfs, both supports snapshots too and zfs has deduplication too (with high I/O the deduplication may take a lot of performance).

Comments are closed.