Preparing Virtual Machine for Virsh Shutdown

One of the a bit tricky things with libvirt is to make guest OS support shutdown command directly, i.e. when you call virsh shutdown ${machine_name} the virtual machine shuts down gracefully and without any delay. 

Libvirt sends the an ACPI (see acpi.info for details)event to virtual machine when shutdown command is issued. Although delivering of ACPI events can be disabled in libvirt configuration, often the problem is that default settings of the most operating systems ignores the events or requires user interaction during their processing. That is undesired behavior for headless automated virtual machines -- below is how to configure some of the currently used operating systems to correctly shutdown when they receive the proper ACPI event. 

note: I intend to update this article when I get experience with any other operating system setup. Feel free to send me yous hands-on as comments.



  1. install acpid : apt-get install acpid
  2. start it : service acpid start
  3. Add it to default run level:  update-rc.d acpid enable
  4. disable confirmation dialogs by editing /etc/acpi/events/powerbtn
    1. add # to comment line: #action=/etc/acpi/powerbtn.sh
    2. add a new line: action=/sbin/poweroff

Windows Server

  1. change policies
    1. open the Group Policy Editor: gpedit.msc
    2. allow shutdown when an administrator is not logged in
      1. navigate to Local Computer Policy -> Computer Configuration -> Windows Settings -> Security Settings -> Local Policies -> Security Options
      2. find option: “Shutdown: Allow system to be shut down without having to log on” and set it to “Enabled”
    3. disable the “Shutdown Event Tracker” (the dialog that will be presented to the user when a shutdown is requested)
      1. navigate to Local Computer Policy -> Computer Configuration -> Administrative Templates -> System
      2. find option “Display Shutdown Event Tracker” and set it to “Disabled”
  2. set power button to shutdown
    1. open Control Panel
    2. select Power Options
    3. left pane select “Change what the power buttons do” and set it to “shutdown”
  3. disable monitor sleep
    1. open Control Panel
    2. select Power Options, select "Change power-saving settings"
    3. select “High performance”
    4. click on “Change plan settings” and disable monitor sleep by setting "Turn off display" option to 'Never"

No comments:

Post a Comment