How to close a hang virtual machine in XenServer

In XenServer, it is not so rare to encounter VM hang. However, VM hang for a long time will affect your mood and subsequent operations.

download-icon
Free Download
for VM, OS, DB, File, NAS, etc.
nick-zhao

Updated by Nick Zhao on 2021/09/17

In XenServer, it is not so rare to encounter VM hang. However, VM hang for a long time will affect your mood and subsequent operations.

In general, in order to shut down or restart the VM, we recommend the following operation sequence:

1. Enter the VM and use the system shutdown or restart function

2. Select shutdown or restart from the menu of XenCenter . Although this menu is implemented through the command of XenServer tool to control the system, it is not guaranteed that VM hang will be caused when XenServer tools work abnormally. Moreover, this should also be the main reason for VM hang (VM flag in XenCenter  is in yellow).

3. Force the operation through force shutdown and force restart in the XenCenter menu.

If the VM is suspended for a long time after these operations are performed, we have the following solutions to enable the VM to shut down, or force it to shut down to reset its state. The harm of these solutions will gradually increase. Therefore, please try in order:

1. Reset the power state of the VM

1
xe vm-reset-powerstate force=true vm=<vm name>

2. Reset toolstack

1
xe-toolstack-restart

3. Destroy domain

1
2
3
4
5
6
#First, get the UUID of the VM
xe vm-list name-label=<vm name> params=uuid
#Get the domain ID of the VM
list_domains | grep <VM-UUID>
#Reset hang state
/opt/xensource/debug/xenops destroy_domain -domid <vm domain id>

4. If still does not work, you can force the VM into a crash state

1
2
3
4
5
6
#First, get the UUID of the VM
xe vm-list name-label=<vm name> params=uuid
#Get the domain ID of the VM
list_domains | grep <VM-UUID>
#Manually trigger VM crash mechanism
/usr/lib/xen/bin/crash_guest <domain ID>

5. If the crash mechanism does not work, there is only one way to forcibly turn off the XenServer host

Note: after crashing the VM, the VM will be in the blue screen state. At this time, you can try the normal shutdown or forced shutdown command to shut down the virtual machine.

BTW: in some cases, operations such as shutdown may be delayed for some reasons, and cancellation will fail. At this time, it may be OK to wait a little longer.

Share on:

Categories: VM Tips