Citrix XenServer How to Force Shutdown Virtual Machines

Sometimes you just can’t get a VM to shutdown, it maybe an issue with XenTools or sun spots. Here is a list of commands that will help you get that damn thing shutdown.

  1. Disable High Availability (HA) so you don’t run into issues
  2. Log into the Xenserver host that is running your VM with issues via ssh or console via XenCenter
  3. Run the following command to list VMs and their UUIDs
    xe vm-list
  4. First you can try just the normal shutdown command with force
    xe vm-shutdown uuid=<UUID from step 3> force=true
  5. If that just hangs, use CONTROL+C to kill it off and try to reset the power state.  The force is required on this command
    xe vm-reset-powerstate  uuid=<UUID from step 3> force=true
  6. If the VM is still not shutdown, we may need to destroy the domain
  7. Run this command to get the domain id of the VM.  It is the number in the first row of output
    list_domains
  8. Now run this command using the domain ID from the output of step 7
    Before XenServer 7.x:
    /opt/xensource/debug/xenops destroy_domain -domid <DOMID from step 7>
    XenServer 7.x and greater:
    xl destroy <DOMID from step 7>

8 thoughts on “Citrix XenServer How to Force Shutdown Virtual Machines”

      1. Sorry, I don’t know of a way via Xen. Here is a quick script I wrote up. I haven’t tested it yet, as I don’t want to take down my VMs in the middle of the day 🙂

        for i in `xe vm-list |grep uuid | awk '{ print $5 }'`
        do
        xe vm-shutdown uuid=$i force=true
        done
        

        Good luck!

      2. xe vm-shutdown power-state=running –multiple will shut down all running VM’s that have xentools installed. You should be able to add force=true as well.

  1. Thanks!!! Following your instructions (I had to get to step 8) we could stop perfectly the machine!!! And restart ok later.

  2. Watch out guys, if you copy-paste the step 8 sometimes could happen that the “minus” symbol is not correct. Delete it and rewrite it. Will work well in this way!

Leave a Reply

Your email address will not be published.