Quantcast
Channel: IT From All Angles
Viewing all articles
Browse latest Browse all 4

KVM Guests: Graceful Shutdown

$
0
0

So a fairly trivial (but critical) aspect of using KVM is of course performing graceful shutdowns of your domains, without having to reach inside of the guest to perform the shutdown.  Now when it comes to turning off your guests you have two ways of proceeding (with virsh)…

# virsh destroy vmname

Which is a HARD power off of your guest.  This is the same as pulling the power cord from the wall, nothing is shutdown, but the noise stops just the same.  This method can result in data corruption if writes are interrupted.

# virsh shutdown vmname

Now in theory this will perform a graceful shutdown, or more importantly it sends a signal to the guest which results in the guest initiating a shutdown.  However this is not guaranteed, if your virtual machine configuration or guest OS is not configured to acknowledge or even receive these signals then nothing will happen.

Enable ACPI on the Virtual Hardware

Now the signal that is sent is an ACPI signal, this means that we need to configure the virtual machine to have acpi on the virtual processor.  This is accomplished by adding <acpi/> inside the features section of the virtual machines XML file.

This will print just the features block out of the XML file, it will not make any changes.

# awk '/<features>/,/<\/features>/' /etc/libvirt/qemu/vmname.xml
<features>
<acpi/>
<apic/>
<pae/>
</features>

Configure the Guest Operating System (Linux)

Linux is pretty simple, just make sure that acpid is installed.

Using APT

# apt-get install acpid

Using YUM

# yum install acpid

Configure the Guest Operating System (Windows)

Post Server 2000 Microsoft decided that by default servers should not respond to any idiot in a Datacenter with at least one finger.  Which is not an unreasonable assumption.  This had the unintended consequence of hamstringing virtualization, since obviously virtual machines don’t have the weakness of a power button which can be “bumped” by a one-fingered idiot.

I have seen different behavior based on the version of the OS you use, as I assume Microsoft has tried to make the behavior a bit more friendly and workable.  Basically as I have noticed.  Windows 2003 has to be logged on fully to have a virsh shutdown be successful.  Windows 2008 has to have the console open and the user has to have pressed CTRL-ALT-DEL, but not necessarily logged in.  Windows 2008 R2 simply needs the console open.

Regardless if you’d like to disable this protection on your VMs there is a registry change which can be made, of course this can also be made via a group policy.

HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\Shutdownwithoutlogon

0=disabled
1=enabled

This of course needs to be done on all of your Windows guests.


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images