Virtual Machine stuck in amber state on XenServer 6.0.2

Sometimes a VM will get stucked, and you can see errors when trying to Force ShutDown or Restart like this:

08.08.2012 13:45:25 Error: Shutting down VM ‘NAME OF VIRTUAL MACHINE’ on ‘xenserver02’ – Another operation involving the object is currently in progress

This can happen to be a virtual machine. Typically you will not get access via XenCenter Console.

The Virtual Machine is in what we call an “Amber State” from the XenServer control domain. To fix this follow this procedure:

Step 1: 
Select the virtual machine in XenCenter and check the general tab to obtain the UUID of the virtual machine, which is in an unresponsive state:

Obtain UUID of XenServer VM

 

Step 2:

Run the following command to check the dom-id of the virtual machine in the XenServer control domain:

list_domains | grep 

Here is my sample example of the command:

[root@xenserver02 ~]# list_domains | grep 5e5af822-f38d-18ca-43c8-b1139351cd48

Output:

64 | 5e5af822-f38d-18ca-43c8-b1139351cd48 | H

64 = the domid of the VM

5e5af822-f38d-18ca-43c8-b1139351cd48 = the UUID of the VM

H – state of the virtual machine (H indicates that this is a HVM guest, typically it means this is a Windows virtual machine.)

 

Step 3:

Now, run the following command to destroy the domid of the virtual machine (it purges the current running data of that VM from memory, not any other vm or SR).

/opt/xensource/debug/xenops destroy_domain –domid 64