Tuesday, 5 January 2016

Powering OFF a virtual machine fails with the error: Another task is already in progress.

Written by Suhas Savkoor

When you try to Power OFF a virtual machine, you might receive the following error:

Method 1:
Powering OFF the virtual machine from the command line:

From the SSH of the host where this VM resides:
1. Get the VM ID by running the below command:
# vim-cmd vmsvc/getallvms | grep -i <VM_Name>
2. Once the VM ID is obtained, Shutdown the VM guest using the command:
#vim-cmd vmsvc/power.shutdown <VM_ID>
3. If this fails, try a hard shut down of the vvirtual machine using Power OFF command:
#vim-cmd vmsvc/power.off <VM_ID>
4. If this fails as well, perform a vMotion of this VM to another host and perform Method 1 again. If vMotion fails with an error, "This operation is not allowed in the current state", then proceed to step 2, to kill the process

Method 2:
Kill the VM process:

1. Run the command:
ps | grep vmx
The output will be a long list of all the virtual machines vmx process IDs. You need to isolate the part which includes the virtual machine which you want to Power OFF. The output in my environment for a particular VM looks like:

4324194   4324194   vmx                  /bin/vmx
4324200   4324194   vmx-vthread-5:Windows 2008 /bin/vmx
4324201   4324194   vmx-vthread-6:Windows 2008 /bin/vmx
4324202   4324194   vmx-mks:Windows 2008 /bin/vmx
4324203   4324194   vmx-svga:Windows 2008 /bin/vmx
4324204   4324194   vmx-vcpu-0:Windows 2008 /bin/vmx
4324205   4324194   vmx-vcpu-1:Windows 2008 /bin/vmx

The first column contains the Process ID, and second column is Parent Process ID. We need to Kill the parent Process ID. In this example, the Parent Process ID is 4324194.

2. Run the command to kill the process
# kill <process_ID>
3. Also, you can try the below command:
# kill -9 <process_ID>

"-9" is a signal Kill, which sends a sigkill signal to the process that is specified.

Now, all these "kill" command might fail with a message,

"No such process found"Unable to kill Virtual Machine. Error was : Unable to kill virtual machine. Error returned was No such process"

In this case, the only solution to kill this stale process is to Reboot the host having this virtual machine, and this should let us Power OFF the virtual machine.

1 comment: