KVM uses
ACPI to send shutdown event to the guest virtual machine. But it can't do that in case your windows settings prohibit shutdown when there is no user logged in, you have to change this settings. Here is how:
-
Ensure the ACPI is enabled in your virtual machine settings.
-
Login to your Windows guest and launch Group Policy Object Editor (gpedit.msc).
- Locate the following key and change the settings to enabled.
Computer Configuration\Windows Settings\
Security Settings\Local Policies\Security Options\
Shutdown: Allow system to be shut down
without having to log on
- If you want to be able shutdown guest even there is a logged in user add the following to file ShutdownWarningDialogTimeout.reg and enter it into windows registry.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows]
"ShutdownWarningDialogTimeout"=dword:00000001
Finally here is a simple command using
virsh to shutdown guest:
virsh -c qemu:///system shutdown w2k3
Once the above settings is enabled you should be able gracefully shutdown your windows guests using virtual machine ACPI power management.