Ubuntu 16.04: ホストマシン再起動時にゲストマシンを自動的にサスペンド・リジュームする


Table of Contents

1 libvirt-binのインストール

libvirt-guestsを含むlibvirt-binパッケージをインストールします。

$ sudo apt install -y libvirt-bin

2 /etc/default/libvirt-guestsの編集

/etc/default/libvirt-guestsを以下のように編集します。

$ diff -uprN /etc/default/libvirt-guests{.org,}— /etc/default/libvirt-guests.org 2016-10-19 01:40:53.356931551 +0900+++ /etc/default/libvirt-guests 2016-10-19 01:41:15.228674533 +0900@@ -8,7 +8,7 @@ # – 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=ignore+ON_BOOT=start # Number of seconds to wait between each guest start. Set to 0 to allow # parallel startup.@@ -22,7 +22,7 @@ # 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+ON_SHUTDOWN=suspend # 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.@@ -33,7 +33,7 @@ PARALLEL_SHUTDOWN=10 # 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=120+#SHUTDOWN_TIMEOUT=120 # If non-zero, try to bypass the file system cache when saving and # restoring guests, even though this may give slower operation for

ホストマシンを再起動します。

$ sudo reboot

再起動後、ゲストマシンを動かしたままホストマシンを再起動すると、ゲストマシンがサスペンドされ、起動後に自動的にリジュームします。

Android | Linux | SDL - Narrow Escape