Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

A.11. (オプション) 正常なシャットダウンを許可する回避策

libvirt-guests サービスには、ゲストが適切にシャットダウンできるように設定できるパラメーターがあります。これは、libvirt インストールの一部で、デフォルトでインストールされるパッケージです。このサービスは、ホストのシャットダウン時にゲストをディスクに自動的に保存し、ホストの再起動時にゲストをシャットダウン前の状態に復元します。デフォルトでは、この設定はゲストを一時停止するように設定されています。ゲストを適切にシャットダウンするには、libvirt-guests 設定ファイルのパラメーターのいずれかを変更する必要があります。

手順A.5 ゲストの正常なシャットダウンを可能にするための libvirt-guests サービスパラメーターの変更

ここで説明する手順では、ホストの物理マシンが停止している場合、電源が切れている場合、または再起動が必要な場合に、ゲスト仮想マシンを正常にシャットダウンできるようにします。
  1. 設定ファイルを開きます。

    設定ファイルは /etc/sysconfig/libvirt-guests にあります。ファイルを編集し、コメントマーク (#) を削除して、ON_SHUTDOWN=suspendON_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. 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.
  2. libvirt-guests サービスを開始します。

    サービスを開始していない場合は、libvirt-guests サービスを開始します。サービスを再起動しないでください。再起動すると、実行中のゲスト仮想マシンがすべてシャットダウンします。