14.9.3. 操控 libvirt-guests 配置设置
libvirt-guests
服务具有参数设置,可以配置为保证正确关闭 guest。它是 libvirt 安装的一部分的软件包,并被默认安装。当主机关闭时,这个服务会自动把客户机保存到磁盘,并在主机重启时将其恢复到其预sh状态。默认情况下,此设置设置为暂停 guest。如果您希望关闭 guest,则需要更改 libvirt-guests
配置文件中的一个参数。
过程 14.5. 更改 libvirt-guests 服务参数,以允许正常关闭 guest
此处描述的步骤可在主机物理机器卡、关机或需要重启时正常关闭 guest 虚拟机。
打开配置文件
该配置文件位于/etc/sysconfig/libvirt-guests
中。编辑该文件,删除注释标记(#)并将ON_SHUTDOWN=suspend
更改为ON_SHUTDOWN=shutdown
。请记住保存更改。$ 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. TheDefault
setting functions in the same manner asvirsh
does when no explicit URI is set In addition, one can explicitly set the URI from/etc/libvirt/libvirt.conf
. It should be noted 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. Thestart
option starts all guests that were running prior to shutdown regardless on their autostart settings. Theignore
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 andshutdown
which shuts down all running guests. It is best to be careful with using theshutdown
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 theON_SHUTDOWN=shutdown
, you must also setSHUTDOWN_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 to0
, 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. IfSHUTDOWN_TIMEOUT
is set to0
, 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). - ???
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.
启动 libvirt-guests 服务
如果您尚未启动该服务,请启动 libvirt-guests 服务。不要重启该服务,因为这会导致所有正在运行的域关闭。