XEN Virtualization

Controlling domains

Start a guest	xm create {guest} -c
Stop a guest	xm shutdown {guest}
Force a guest shutdown	xm destroy {guest}

To access the Virtual Console of a Xen guest (aka DomU)

Gather a list of running domains or find one in particular	xm list
Connect to the ascii console of a running domain one of several ways	xm console {guest} or virsh console {guest}
Start a domain and connect to the console at boot	xm create -c {guest}
Connect to the GUI console of a running domain one of several ways, first on Dom0	export DISPLAY={yourworkstationIP}:0.0
Open a X11 window manager on your laptop	xming.exe
To show all virtual consoles, on Dom0 run	netstat -an | grep 590
OR do a	virsh vncdisplay {guest}
Cycle through and find the right one on Dom0	vncviewer localhost:590X &
Or navigate the virt-manager GUI and find your console	virt-manager &

Network Bridge Control

To view bridged networks

brctl show

To rename network bridge

Shutdown virtual using bridge	xm shutdown {guest}
Shutdown network bridge	ip link set {bridge} down
Rename bridge	ip link set {old_name} name {new_name}
Bring up bridge	ip link set {new_name} up
Edit xen config file with new bridge name	sed -i s/{old_name}/{new_name}/ /etc/xen/{guest}
Start virtual	xm create {guest}
Edit xen networking script	vi /etc/xen/scripts/{network_script}

To rename network bridge w/o domain restart

Find current vif for domain	xm network-list {guest}
Shutdown network bridge	ip link set {bridge} down
Rename bridge	ip link set {old_name} name {new_name}
Bring up bridge	ip link set {new_name} up
Edit xen config file with new bridge name	sed -i s/{old_name}/{new_name}/ /etc/xen/{guest}
Edit xen networking script	vi /etc/xen/scripts/{network_script}

XEN States

From a 'xm list' command

r	running	The domain is currently running on a CPU
b	blocked	The domain is blocked, and not running or runnable. This can be caused because the domain is waiting on IO (a traditional wait state) or has gone to sleep because there was nothing else for it to do.
p	paused	The domain has been paused, usually occurring through the administrator running xm pause. When in a paused state the domain will still consume allocated resources like memory, but will not be eligible for scheduling by the Xen hypervisor.
s	shutdown	The guest has requested to be shutdown, rebooted or suspended, and the domain is in the process of being destroyed in response.
c	crashed	The domain has crashed, which is always a violent ending. Usually this state can only occur if the domain has been configured not to restart on crash. See xmdomain.cfg for more info.
d	dying	The domain is in process of dying, but hasn't completely shutdown or crashed.

Note: Machines may be in “b” a lot, this is not a problem. The states other than “r” and “b” are ones which may require action.

Rescue Mode - Method One

This is the traditional option, meaning you end up with in linux rescue mode, but it requires network connectivity.

Edit virtual server Xen config file

Comment out this line #bootloader = “/usr/bin/pygrub”

Add these lines (substitute the kernel version as needed)

kernel = "/net/swdepot/software/linux/xen/kernels/v5.5/vmlinuz"
ramdisk = "/net/swdepot/software/linux/xen/kernels/v5.5/initrd.img"
extra = "rescue"

Boot the virtual server

When prompted to select resuce image, select NFS

Enter servers IP address, subnet, gateway, & DNS server

NFS server = kickstart

NFS directory = /kickstart/iso

Rescue Mode - Method Two

This is an alternate option that does not require network connectivity. You end up booting to a minimal RHEL install, from which you can work on your broken system.

Copy swdepot:/software/linux/xen/rescue/rescue.img to the Xen host (it is a 4GB file)

Edit virtual server Xen config file

Change the disk line to add the rescue image as the primary disk, with the original disk as the secondary disk.

disk = [ "file:/path-to-file/rescue.img,xvdb,w", "phy:/dev/vg(original)/lv(original),xvda,w" ]

Boot the virtual server

Root password on the rescue image is: rescueme

The root VG on the rescue image is {VolGroup00}, on the virtual server it is likely vgroot

Mount vgroot and begin rescue process

I/O Scheduler

Default scheduler is cfg however noop may show improvements for busy Xen hosts & guests.

To view:

# cat /sys/block/{disk}/queue/scheduler

To change:

# echo 'noop' > /sys/block/{disk}/queue/scheduler

To change permanently, add elevator=noop to grub.conf.