2009-05-02
libvirt によるKVMのホストOSのシャットダウン時のオートシャットダウン(auto suspend)
ubuntu 9.04のKVM libvirtが思ったより良く出来ていていろいろ試してみた。
ホストOSを普通にシャットダウンすると、自動でゲストOS側もシャットダウンしてくれるんだろうな
と思い込んでいたが、違った。ゲストOS側はブッツリ切られてしまうようだ。
自動シャットダウン的なもの無いかと探したがなかなか見つからなくて
やっと見つけたのがこれだった。
http://www.vogelweith.com/debian_server/14_kvm.php#x1-170004
/usr/share/doc/libvirt-bin/examples/libvirt-suspendonreboot
こんなものが用意されてました。
中身は、↓の感じ。
#! /bin/bash # (c) Andi Barth <aba@not.so.argh.org> 2008 # Distributable under the terms of the GNU GPL version 2. # # copy to /etc/init.d/libvirt-suspendonreboot and use # update-rc.d libvirt-suspendonreboot defaults 21 19 # to enable PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin suspenddir=/var/lib/libvirt/autosuspend case "$1" in start) for domain in ${suspenddir}/*dump; do if [ -f $domain ]; then domain=$(basename $domain .dump) echo "resuming $domain ..." virsh restore ${suspenddir}/${domain}.dump && rm ${suspenddir}/${domain}.dump fi done ;; stop) for domain in /etc/libvirt/qemu/*xml; do domain=$(basename $domain .xml) state=$(virsh domstate $domain) if [ "$state" == "running" ]; then echo "suspending $domain ..." virsh save ${domain} ${suspenddir}/${domain}.dump fi done ;; reload|force-reload|restart) # No action, nothing to reload ;; *) echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2 exit 1 esac
使い方は、以下のようにしろと書いてます
cp /usr/share/doc/libvirt-bin/examples/libvirt-suspendonreboot /etc/init.d/ chmod 755 /etc/init.d/libvirt-suspendonreboot mkdir -p /var/lib/libvirt/autosuspend/ update-rc.d libvirt-suspendonreboot defaults 21 19
まだ試して無いですが・・・多分動くでしょう。 動きました。
トラックバック - http://d.hatena.ne.jp/desutai/20090502/1241248197
リンク元
- 117 http://clip.livedoor.com/page/4540539/ ubuntu 9.04 libvirtdによるKVMのホストOSのシャットダウン時のオート?%8
- 46 http://www.google.com/url?sa=t&source=web&cd=1&ved=0CBgQFjAA&url=http://d.hatena.ne.jp/desutai/20090502/1241248197&rct=j&q=libvirt kvm シャットダウン&ei=yQPBTduuH5GSuwPB0aGbBA&usg=AFQjCNHc6l
- 31 http://www.google.co.jp/url?sa=t&rct=j&q=kvm シャットダウン&source=web&cd=1&sqi=2&ved=0CCMQFjAA&url=http://d.hatena.ne.jp/desutai/20090502/1241248197&ei=HH6ETsu3Ga2emQXlwpH-Dw&usg=AFQjCNHc6lNL
- 29 http://d.hatena.ne.jp/ngyuki/20111111/p1
- 26 http://www.google.co.jp/search?q=kvm+シャットダウン&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a
- 26 http://www.google.co.jp/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CCcQFjAA&url=http://d.hatena.ne.jp/desutai/20090502/1241248197&ei=wrhmT9XnK4XnmAXawdGWCA&usg=AFQjCNHc6lNL4-ruymCFXmHAB-qrq9Gu_w
- 23 http://www.google.co.jp/search?sourceid=navclient&hl=ja&ie=UTF-8&rlz=1T4SKPB_jaJP316JP316&q=ubuntu+9.04+shutdown
- 20 http://www.google.co.jp/search?q=kvm+ゲスト+シャットダウン&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:ja:unofficial&client=firefox-a
- 18 http://b.hatena.ne.jp/entry/d.hatena.ne.jp/desutai/20090502/1241248197
- 18 http://oss.poyo.jp/pipermail/centos-users/2010-July/021972.html