On a rare occassion, you may encounter a XenServer-based VM that is stuck in a “Pending” state. Recently I came across a VM that was stuck with a pending “Shutdown” task. Within XenCenter, the VM was “unresponsive” and the Shutdown and Reboot buttons were greyed out.

A couple of potential causes for this condition include:

1. Taken from the comments of the following post

I’ve since found that the most common reason my VM’s won’t shut down is that they’re using a storage repository (such as an ISO library) that is offline.

In other words, if the virtual cd of a VM is pointing at an ISO that’s on an offline storage repository, then that VM can’t be shut down! (bug)”

2. From Citrix:

Windows being Windows. At times, when a server executes shutdown, it hangs, spinning it’s wheels. XenServer waits for a confirmation from XenTools that the shutdown is proceeding before it completes the task. If there are problems during the Shutdown, XenServer does not consider the task completed leading to a loss of connectivity to the XenServer tools. If connectivity between XenServer and XenTools is lost during the shutdown process meaning XenServer never receives a proper signal from Xentools about the state of the shutdown, you get that “stuck” symptom and the only thing you can do is force-kill the task and down a Force Reboot.

In this case, I had to force-kill the task from the XenServer console CLI using the following commands:

1. xe task-list to view the Pending tasks

2. xe task-cancel force=true uuid=<UUID> to cancel a specific task

Attempting a shutdown or a reboot using the xe vm-reboot or xe vm-shutdown commands did nothing but create another pending task. xe-toolstack-restart and xe task-cancel uuid=<UUID> (without the force=true) had no effect.

Once I cancelled the Pending task affecting the VM, the VM rebooted and worked normally; I did not have to run xe-toolstack-restart after cancelling the task(s), but this instance may be the exception and not the rule.