How to forcibly shutdown VMs from command line

How to forcibly shutdown VMs from command line

book

Article ID: CTX220777

calendar_today

Updated On:

Description

To shutdown VMs that are not responding to a shutdown command from XenCenter or the xe CLI.


Instructions

  1. Disable High Availability (HA).
  2. Log into the XenServer host that is running your VM with issues through SSH or go to the host console in XenCenter.
  3. Run the following command to list VMs and their UUIDs:

    xe vm-list resident-on=<uuid_of_host>

  4. Try the shutdown command with force:

    xe vm-shutdown uuid=<uuid_of_vm> force=true

    If this command hangs, use Ctrl+C to cancel the command.

If the VM does not respond to the shutdown command with force=true specified, consider contacting support to report a product bug. Ensure that you provide a server status report taken from the host that is running the VM.

You can now attempt the following commands in order. If one succeeds in shutting down the VM, you do not need to continue to the next.

  1. Restart the toolstack on the host by using the following command:

    xe-toolstack-restart

    After restarting the toolstack, attempt the shutdown command with force again.

  2. If possible, and there are no other important VMs running on the XenServer host. Restart the host.

    shutdown -r now

If the VM is still not shutdown, you might need to destroy the domain. However, the steps given below can cause problems for your VM and should only be done as a last resort.

  1. Run the following command to get the domain ID of the VM. The domain ID is the number in the first row of output. The list will be the VMs on the host. Dom0 is be the host itself and all numbers after are VMs running on the host.

    list_domains

  2. Run the following command using the domain ID from the output of the previous step:

    xl destroy <domain_id>

  3. After destroying the domain, reset the power state.  The force is required on this command.

    xe vm-reset-powerstate uuid=<uuid_of_vm> force=true

Issue/Introduction

How to use the force, reset power state, and also destroy domain commands on VMs