A.11. Optional Workaround to Allow for Graceful Shutdown
libvirt-guestsservice 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
Procedure A.5. Changing the libvirt-guests service parameters to allow for the graceful shutdown of guests
Open the configuration fileThe configuration file is located in
/etc/sysconfig/libvirt-guests. Edit the file, remove the comment mark (#) and change the
ON_SHUTDOWN=shutdown. Remember to save the change.
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
URIS- checks the specified connections for a running guest. The
Defaultsetting functions in the same manner as
virshdoes 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
startoption starts all guests that were running prior to shutdown regardless on their autostart settings. The
ignoreoption will not start the formally running guest on boot, however, any guest marked as autostart will still be automatically started by
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:
suspendwhich suspends all running guests using
shutdownwhich shuts down all running guests. It is best to be careful with using the
shutdownoption 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_TIMEOUTto a value suitable for the guests.
PARALLEL_SHUTDOWNDictates 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_TIMEOUTis enabled, this timeout applies as a timeout for shutting down all guests on a single URI defined in the variable URIS. If
SHUTDOWN_TIMEOUTis 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_CACHEcan 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 serviceIf you have not started the service, start the
libvirt-guestsservice. Do not restart the service as this will cause all running guest virtual machines to shutdown.