Forum Discussion
Windows Server 2022 Hyper-V guest state not saved on host reboot
Hello Reinhard Schuerer,
You will see the complete text of the Hyper-V VM stuck error message displayed when you try to start or stop a VM in Hyper-V as displayed below:
It will encounter an error while trying to change the state of the virtual machine as "VM-name Failed to change state."
The common reasons on every reboot, the VMs lose their state are incorrect network configuration, storage failure, VM power options Routing, and Remote Access configuration, and insufficient permissions to access VM files.
We can encounter the problem using two methods:
Method 1: By using native GUI tools
We can use the (GUI) of Hyper-V and windows to identify the needed vmwp.exe process and end its process. Hyper-V Manager is a tool for virtual machine management in the Windows Hyper-V environment.
Get the VM GUID in Hyper-V Manager.
Right-click the name of your Hyper-V host from Hyper-V Manager
In the context menu, select Hyper-V Settings.
From the Hyper-V Settings window,
Now, click on the Virtual Machines under the left pane to find a path where files of VM are located by default on the Hyper-V host.
Go to Windows Explorer to find the subfolder where the files of the frozen VM are located.
Now, Open the VM folder, and you should see a subfolder and files with a long name consisting of digits and letters.
Thus from there, you can end the vmwp exe task related to the problematic Hyper-V VM.
Now Open Windows Task Manager in the host operating system. Click Start > Run, type taskmgr, and press enter.
You can find the vmwp.exe process with the needed GUID and Right-click the appropriate vmwp exe process in the context menu, select End task to power off the VM, and get the correct stop VM state.
Method 2: By using Process Explorer Tool
You can identify the needed instance for the vmwp exe process related to the problematic VM with the help of Process Explorer.
Now, Unzip the Process Explorer files to a custom folder.
Then, From Hyper-V Manager, open VM settings for your problematic VM, and select VHD options. Then, copy the full path to a virtual hard disk file.
Start the Process Explorer by running the appropriate execution file.
Click on the binocular icon and paste the path to the virtual disk file of the stuck VM in the DLL or Handle substring field, then click on Search.
You have to Right-click the selected vmwp.exe process, and in the context menu, click Kill Process.
Method 3: By using PowerShell to kill the VM process
Open PowerShell and fix the error and run Stop-VM -Force command. You can use the below command to get the unique ID of the VM,
Get-VM "VM-name" | fl *
Now, run these commands to kill the process and stop VM:
$VMWMProc = (Get-WmiObject Win32_Process | ? {$_.Name -match 'VMWP' -and $_.CommandLine -match $VMGUID})
Stop-Process ($VMWMProc.ProcessId) -Force
Now the problematic VM process is killed, and the VM will get stopped. Thus, you can try to edit the VM state from the settings and run the VM again.
Hope the information above helps you to recover back the VMs state.
------------------------
Regards,
Austin_M