4

I am using XEN on CentOS 6.5 64 I want a way to stop all virtual machine when XEN server shutdown I build service call in stop xm shutdown -a but not working

#!/bin/bash
# chkconfig: 2345 95 20
# description: 
# processname: 

stop()
{
    /usr/sbin/xm shutdown -a
   while [[ true ]]; do
     if [[ `virsh list|wc -l` == 4 ]]; then
       break
     fi
     sleep 1
   done
}

case "$1" in
  stop)
    stop
    ;;
  *)
    echo $"Usage: $prog {stop}"
esac

enter image description here

1 Answer 1

2

If you are using Xen4CentOS I would recommend using libvirt. Although it is using a xen driver to interface with xm and xl and not dedicated interface to the dom0 it will automate things like startup, shutdown, network interfaces and an easy installation interface. The trade-off for using an extra abstraction layer is compensated by having a system that is much closer to the default KVM virtualization which is default in CentOS (and RHEL).

When using libvirt the default shutdown action will be 'suspend' which is not supported by this software combination at this time. Changing /etc/sysconfig/libvirt-guests setting ON_SHUTDOWN=shutdown will provide a proper shutdown script for the VM's.

2
  • "suspend [...] is not supported by this software combination at this time" Is this still true today with CentOS 7? Commented Nov 7, 2018 at 20:44
  • @sauerburger, i'm not sure, but the documentation still states: "Since 0.10.2 it is possible to forcibly enable or disable BIOS advertisements to the guest OS. (NB: Only qemu driver support)", libvirt.org/formatdomain.html
    – Joffrey
    Commented Nov 22, 2018 at 16:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .