Shutting down servers is a common operations for managing a cluster. However, if this server is configured to a Xen Dom0 and has Xen VMs (DomUs), the VMs should be shutdown first to avoid data lost on these VMs.
xm supports a
-a option to shutdown all VMs:
# xm shutdown -a
-w if you want to make it wait for the domain to complete shutdown before returning
I wrote a Bash script to automatically list all running VMs and shutdown them down by calling
xm which I use to shutdown VMs on servers before turning them off.
xen-shutdown-all.sh script is on github:
This script use the
xm command for management. If you are using a newer version of Xen which possibly uses
xl for VM management, you can easily change the script by replacing
xl and make other possibly required changes.