Your Hyper-V Virtual Machine not stopping? Is it being a PITA even after rebooting? Do you just want to strangle the process until even it’s children become non-responsive (that wasn’t an unnecessarily dark comment – there IS a nerd joke hidden in there somewhere).
Then you’ve come to the right place!
I primarily use Hyper-V VMs (ask my bosses at VENZO why I’m not allowed to use
VirtualBox or Parallels anymore. Hint: it’s because we
Love-All-Things-Microsoft™) and routinely go through a whole bunch of them –
Checkpoints, Reverting, Wiping, Migrating, Moving, Deleting, and just plain ol’
fresh deployments when I just can’t be bothered anymore.
Did I ever mention that I was a
macOS user for almost two solid decades? In fact, I even ran macOS as my daily
driver even at the MSP I used to work at before I joined VENZO as a security
specialist. As much as enjoy working with Microsoft technology and Linux; what
I really liked about macOS was that shit just worked.
That said, said shit was severely limited. I
tend to do a fresh wipe on my Lenovo X1 at least every other month due
to the sheer abuse I throw at it. And that doesn’t even include stuff like
routine network resets every other week to counter whatever cockups I’ve made
in regards to my Hyper-V networking.
But there’s something in particular that just fucking
irks me no matter what. Stalled VMs. I’ve gone through this enough times
that I just thought fuck it – im writing a blog post next time it happens
because it’s easy low-hangning fruit for a post AND I can grab screenshots
while I’m fixing something I’d otherwise be fixing regardless!
So, with that said, onwards!
First thing to try – Restart the Service
First up, try restarting the vmms.exe (Hyper-V
Virtual Machine Management service) process. This is a safe operation and will
not interrupt the other running VMs. The easiest way to restart the vmms.exe
process is through the vmms service using the services.msc console or with the
PowerShell service management cmdlets.
Run Get-Service vmms | Restart-Service
No? Well, fuck you too.
Second thing to try - Killing a Frozen Hyper-VM
using PowerShell
Instead of restarting the whole service, let’s
target the bastard process:
$VMGUID = (Get-VM
"[NameOfYourVirtualMachine]").ID
$VMWMProc =
(Get-WmiObject Win32_Process | ? {$_.Name -match 'VMWP' -and $_.CommandLine
-match $VMGUID})
Stop-Process
($VMWMProc.ProcessId) –Force
Dammit!
OK, let’s try
this then. We’ll grab the GUID of the
process and terminate it directly from that. If you’re unsure what [NameOfYourVirtualMachine]
should be, then you
can either take a peek at what you named it in your Hyper-V manager or run Get-VM |
Select Name, Id.
Third thing to try – Kill it with fire! Going
straight for the PID
The only way to force shutdown restart such a
stuck VM without rebooting the whole Hyper-V host is to end its running
workflow in the guest OS. All VMs on the Hyper-V host are started using the
vmwp.exe process (Virtual Machine Worker Process). To search for a process, you
need to find out the GUID of the virtual machine.
We have the GUID from the previous step. In this
case, 8182a521-c026-438f-b8f3-014f7f1734c3.
Launch Task Manager and navigate to the Details
tab. Each virtual machine has its own instance of vmwp.exe running. You'll need
the GUID of the hung-up VM you got before to figure out which process is in
charge of your VM. Locate the process vmwp.exe that contains your VM's GUID in
the User name field. Stop this procedure (End Task).
Endtask that
badboy > Go into your Hyper-V Manager and shut it down again and…
WHO’S THE BADMAN NOW, HYPER-V? WHO IS THE BAD MAN NOW?
That’s
right. We are.
Happy
trails, kids.