Xen VM Check After Rebooting

From MyWiki

Jump to: navigation, search

After rebooting the xen Dependable Grids servers (pkirack5, 6, 7, and quasi), the individual xen domains (dg-000 to dg-099) are brought up too quickly and do not bind to their IP addresses properly.

To check on each physical server:

 xm list

which will return a list like:

 Name                                      ID Mem(MiB) VCPUs State   Time(s)
 Domain-0                                   0     1674     8 r-----    348.1
 dg-050                                     1      255     8 -b----     95.8
 dg-051                                     2      255     8 -b----     96.7
 dg-052                                     3      255     8 -b----     94.9
 dg-053                                     4      255     1 r-----  13513.8
 dg-054                                     5      255     8 -b----     95.8
 ...etc...

dg-053 might or might not respond to a ping, but should be restarted.

 xm shutdown dg-053
 xm create /var/vm/dg-053/dg-053.conf

A one line bash script to bring them all back online would be:

 for f in `ls /var/vm/dg*/dg*.conf`; do xm create $f; sleep 5; done

This is also handy if several VMs were destroyed, because xen will not recreate VMs that are already running. The individual VMs take a minute or more to bind to their IP adresses.

Here are 2 one-line bash scripts to check if the VMs are online:

 for (( i=0; $i < 10; i++ )) ; do ping -c 2 dg-00$i; done
 for (( i=10; $i < 100; i++ )) ; do ping -c 2 dg-0$i; done
Personal tools