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.
Ubuntu
- install acpid : apt-get install acpid
- start it : service acpid start
- Add it to default run level: update-rc.d acpid enable
- disable confirmation dialogs by editing /etc/acpi/events/powerbtn
- add # to comment line: #action=/etc/acpi/powerbtn.sh
- add a new line: action=/sbin/poweroff
Windows Server
- change policies
- open the Group Policy Editor: gpedit.msc
- allow shutdown when an administrator is not logged in
- navigate to Local Computer Policy -> Computer Configuration -> Windows Settings -> Security Settings -> Local Policies -> Security Options
- find option: “Shutdown: Allow system to be shut down without having to log on” and set it to “Enabled”
- disable the “Shutdown Event Tracker” (the dialog that will be presented to the user when a shutdown is requested)
- navigate to Local Computer Policy -> Computer Configuration -> Administrative Templates -> System
- find option “Display Shutdown Event Tracker” and set it to “Disabled”
- set power button to shutdown
- open Control Panel
- select Power Options
- left pane select “Change what the power buttons do” and set it to “shutdown”
- disable monitor sleep
- open Control Panel
- select Power Options, select "Change power-saving settings"
- select “High performance”
- click on “Change plan settings” and disable monitor sleep by setting "Turn off display" option to 'Never"