Created
December 4, 2013 11:45
-
-
Save pgrm/7786286 to your computer and use it in GitHub Desktop.
Automatically saves the state of all running KVM guests when the system is shut down
put into /etc/init.d and reference from /etc/rc0.d and name it with a prefix which makes it execute before any of the other scripts (for instance K01)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
suspend_vms () { | |
for output in $(virsh list --state-running --uuid) | |
do | |
exec virsh managedsave $output --bypass-cache | |
done | |
} | |
case "$1" in | |
start) | |
# No-op | |
;; | |
restart|reload|force-reload) | |
echo "Error: argument '$1' not supported" >&2 | |
exit 3 | |
;; | |
stop) | |
suspend_vms | |
;; | |
*) | |
echo "Usage: $0 start|stop" >&2 | |
exit 3 | |
;; | |
esac | |
: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment