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