Saturday, April 16, 2011

How to Shutdown Windows Guest Gracefully in KVM

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:
  1. Ensure the ACPI is enabled in your virtual machine settings.
  2. Login to your Windows guest and launch Group Policy Object Editor (gpedit.msc).
  3. 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
    
  4. 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.

5 comments:

  1. even easier
    virsh shutdown Domain

    ReplyDelete
  2. Is there anything else that could control this? I have a Windows VM that I can easily shutdown, and neither of those two are set. The first is disabled, and the second is all f's (-1).

    ReplyDelete
  3. thank you very much

    ReplyDelete