There is a well known problem using virsh to shut down a running virtual machine. In many cases the VM seems to ignore the ACPI shutdown event even when the ACPI daemon is running. This can occur on just about any guest operating system and there are a number of reasons for the event being ignored. I want to discuss some potential solutions here.
My Fedora 17 server performs software builds on a nightly basis using virtual machines to create the installation files (RPMs, DEBs, EXEs, etc) for a specific OS. Currently there are 24 VMs that are involved in this process. Each VM is powered on, the build is performed, and then it is shut down. These actions are performed serially on each VM.
I first ran into the shutdown problem on Ubuntu guests. Even though the ACPI daemon was running the VM would not shut down. It turns out that when I installed the OS I did NOT select to automatically log in a user on boot. Once I went in and selected a default user to be logged in at boot time the VM could be successfully shut down by the virsh shutdown command.
Next I ran into this problem after I upgraded my Fedora 17 VMs and some openSUSE VMs. I tried the auto login trick but that did not work for these VMs. So I began to look at the action script that was being invoked for an ACPI power event.
The script invoked for an ACPI power event is different from OS to OS but the gist is the same in all cases. The script checks to see if there is a power manager currently running and if there is then the ACPI power event is ignored. Before I began modifying the script I did some serious thinking about the consequences of what my modifications would impact and I came to some rather startling conclusions.
1. These VMs have no actual user except me, and then only when performing admin tasks on them.
2. 99% of the time the VM never has interaction with a human once they are initially installed and set up.
3. These really are Virtual Machines. That means there is no real hardware that can create ACPI events. The only thing that can create those events is the host libvirt library (which virsh uses).
So the bottom line for me was that when one of these VMs receive an ACPI event I want that event to be recognised and acted on unconditionally. In other words, I want full program control over my VMs when it comes to start up and shut down.
WARNING!!!!! Do not perform the following without reading the above and understanding the consequences.
My solution was to make a backup of the original script and then remove everything in the original ACPI action script except the shutdown command itself. This will cause the VM to be shut down unconditionally from a virsh shutdown command.
You can find the location of the action script in the /ect/acpi/events subdirectory files.
I hope this tip can provide you with a solution that you can live with. It woks well for my situation but your mileage may vary.
Good luck.
My Fedora 17 server performs software builds on a nightly basis using virtual machines to create the installation files (RPMs, DEBs, EXEs, etc) for a specific OS. Currently there are 24 VMs that are involved in this process. Each VM is powered on, the build is performed, and then it is shut down. These actions are performed serially on each VM.
I first ran into the shutdown problem on Ubuntu guests. Even though the ACPI daemon was running the VM would not shut down. It turns out that when I installed the OS I did NOT select to automatically log in a user on boot. Once I went in and selected a default user to be logged in at boot time the VM could be successfully shut down by the virsh shutdown command.
Next I ran into this problem after I upgraded my Fedora 17 VMs and some openSUSE VMs. I tried the auto login trick but that did not work for these VMs. So I began to look at the action script that was being invoked for an ACPI power event.
The script invoked for an ACPI power event is different from OS to OS but the gist is the same in all cases. The script checks to see if there is a power manager currently running and if there is then the ACPI power event is ignored. Before I began modifying the script I did some serious thinking about the consequences of what my modifications would impact and I came to some rather startling conclusions.
1. These VMs have no actual user except me, and then only when performing admin tasks on them.
2. 99% of the time the VM never has interaction with a human once they are initially installed and set up.
3. These really are Virtual Machines. That means there is no real hardware that can create ACPI events. The only thing that can create those events is the host libvirt library (which virsh uses).
So the bottom line for me was that when one of these VMs receive an ACPI event I want that event to be recognised and acted on unconditionally. In other words, I want full program control over my VMs when it comes to start up and shut down.
WARNING!!!!! Do not perform the following without reading the above and understanding the consequences.
My solution was to make a backup of the original script and then remove everything in the original ACPI action script except the shutdown command itself. This will cause the VM to be shut down unconditionally from a virsh shutdown command.
You can find the location of the action script in the /ect/acpi/events subdirectory files.
I hope this tip can provide you with a solution that you can live with. It woks well for my situation but your mileage may vary.
Good luck.