A.11. Optional Workaround to Allow for Graceful Shutdown The libvirt-guests service has parameter settings that can be configured to assure that the guest can shutdown properly. It is a package that is a part of the libvirt installation and is installed by default. This service automatically saves guests to the disk when the host shuts down, and restores them to their pre-shutdown state when the host reboots. By default, this setting is set to suspend the guest. If you want the guest to be gracefully shutdown, you will need to change one of the parameters of the libvirt-guests configuration file. Procedure A.5. Changing the libvirt-guests service parameters to allow for the graceful shutdown of guests The procedure described here allows for the graceful shutdown of guest virtual machines when the host physical machine is stuck, powered off, or needs to be restarted. Open the configuration file The configuration file is located in /etc/sysconfig/libvirt-guests . Edit the file, remove the comment mark (#) and change the ON_SHUTDOWN=suspend to ON_SHUTDOWN=shutdown . Remember to save the change. URIS - checks the specified connections for a running guest. The Default setting functions in the same manner as virsh does when no explicit URI is set In addition, one can explicitly set the URI from /etc/libvirt/libvirt.conf . Note that when using the libvirt configuration file default setting, no probing will be used. ON_BOOT - specifies the action to be done to / on the guests when the host boots. The start option starts all guests that were running prior to shutdown regardless on their autostart settings. The ignore option will not start the formally running guest on boot, however, any guest marked as autostart will still be automatically started by libvirtd . The START_DELAY - sets a delay interval in between starting up the guests. This time period is set in seconds. Use the 0 time setting to make sure there is no delay and that all guests are started simultaneously. ON_SHUTDOWN - specifies the action taken when a host shuts down. Options that can be set include: suspend which suspends all running guests using virsh managedsave and shutdown which shuts down all running guests. It is best to be careful with using the shutdown option as there is no way to distinguish between a guest which is stuck or ignores shutdown requests and a guest that just needs a longer time to shutdown. When setting the ON_SHUTDOWN=shutdown , you must also set SHUTDOWN_TIMEOUT to a value suitable for the guests. PARALLEL_SHUTDOWN Dictates that the number of guests on shutdown at any time will not exceed number set in this variable and the guests will be suspended concurrently. If set to 0 , then guests are not shutdown concurrently. Number of seconds to wait for a guest to shut down. If SHUTDOWN_TIMEOUT is enabled, this timeout applies as a timeout for shutting down all guests on a single URI defined in the variable URIS. If SHUTDOWN_TIMEOUT is set to 0 , then there is no timeout (use with caution, as guests might not respond to a shutdown request). The default value is 300 seconds (5 minutes). BYPASS_CACHE can have 2 values, 0 to disable and 1 to enable. If enabled it will by-pass the file system cache when guests are restored. Note that setting this may effect performance and may cause slower operation for some file systems. Start libvirt-guests service If you have not started the service, start the libvirt-guests service. Do not restart the service as this will cause all running guest virtual machines to shutdown.

Commands:
vi /etc/sysconfig/libvirt-guests URIs to check for running guests example: URIS='default xen:/// vbox+tcp://host/system lxc:///' #URIS=default action taken on host boot - start all guests which were running on shutdown are started on boot regardless on their autostart settings - ignore libvirt-guests init script won't start any guest on boot, however, guests marked as autostart will still be automatically started by libvirtd #ON_BOOT=start Number of seconds to wait between each guest start. Set to 0 to allow parallel startup. #START_DELAY=0 action taken on host shutdown - suspend all running guests are suspended using virsh managedsave - shutdown all running guests are asked to shutdown. Please be careful with this settings since there is no way to distinguish between a guest which is stuck or ignores shutdown requests and a guest which just needs a long time to shutdown. When setting ON_SHUTDOWN=shutdown, you must also set SHUTDOWN_TIMEOUT to a value suitable for your guests. ON_SHUTDOWN=shutdown If set to non-zero, shutdown will suspend guests concurrently. Number of guests on shutdown at any time will not exceed number set in this variable. #PARALLEL_SHUTDOWN=0 Number of seconds we're willing to wait for a guest to shut down. If parallel shutdown is enabled, this timeout applies as a timeout for shutting down all guests on a single URI defined in the variable URIS. If this is 0, then there is no time out (use with caution, as guests might not respond to a shutdown request). The default value is 300 seconds (5 minutes). #SHUTDOWN_TIMEOUT=300 If non-zero, try to bypass the file system cache when saving and restoring guests, even though this may give slower operation for some file systems. #BYPASS_CACHE=0