diff options
Diffstat (limited to 'libraries/libvirt/rc.libvirt')
-rw-r--r-- | libraries/libvirt/rc.libvirt | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/libraries/libvirt/rc.libvirt b/libraries/libvirt/rc.libvirt index fb058a71896f..31ccfb1b7703 100644 --- a/libraries/libvirt/rc.libvirt +++ b/libraries/libvirt/rc.libvirt @@ -11,6 +11,7 @@ # script if this behaviour conflicts with anything else running # on your setup +VIRSH=/usr/bin/virsh MODULES="tun vhost_net" TIMEOUT=${TIMEOUT:-300} LIBVIRTD_PIDFILE="/var/run/libvirt/libvirtd.pid" @@ -22,16 +23,16 @@ VIRTLOCKD_OPTS=${VIRTLOCKD_OPTS:-" -f /etc/libvirt/virtlockd.conf -p $VIRTLOCKD_ guests_reboot() { - for machine in $(/usr/sbin/virsh list --name --state-running | grep -v ^$) ; do - /usr/sbin/virsh reboot $machine + for machine in $($VIRSH list --name --state-running | grep -v ^$) ; do + $VIRSH reboot $machine done } guests_shutdown() { - for machine in $(/usr/sbin/virsh list --name --state-running | grep -v ^$) ; do - /usr/sbin/virsh shutdown $machine & + for machine in $($VIRSH list --name --state-running | grep -v ^$) ; do + $VIRSH shutdown $machine & done sleep 2 @@ -40,7 +41,7 @@ guests_shutdown() { count=0 - while [ $(/usr/sbin/virsh list --name --state-running | grep -v ^$ | wc -l) -gt "0" ]; do + while [ $($VIRSH list --name --state-running | grep -v ^$ | wc -l) -gt "0" ]; do if [ "$count" -ge "$TIMEOUT" ];then break fi @@ -51,11 +52,11 @@ guests_shutdown() { echo "" - if [ $(/usr/sbin/virsh list --name --state-running | grep -v ^$ | wc -l) -gt "0" ];then + if [ $($VIRSH list --name --state-running | grep -v ^$ | wc -l) -gt "0" ];then echo -n "The following guests are still running after $TIMEOUT seconds; destroying them: " - for machine in $(/usr/sbin/virsh list --name --state-running | grep -v ^$) ; do - /usr/sbin/virsh destroy $machine + for machine in $($VIRSH list --name --state-running | grep -v ^$) ; do + $VIRSH destroy $machine echo -n "$machine " done @@ -73,8 +74,8 @@ guests_managedsave() { # apply managedsave on running and paused machines (as we can't distinguish between # the two states while managedsave is being applied, so won't know when to finish waiting) - for machine in $(/usr/sbin/virsh list --name | grep -v ^$) ; do - /usr/sbin/virsh managedsave $machine & + for machine in $($VIRSH list --name | grep -v ^$) ; do + $VIRSH managedsave $machine & done sleep 2 @@ -83,7 +84,7 @@ guests_managedsave() { count=0 - while [ $(/usr/sbin/virsh list --name | grep -v ^$ | wc -l) -gt "0" ]; do + while [ $($VIRSH list --name | grep -v ^$ | wc -l) -gt "0" ]; do if [ "$count" -ge "$TIMEOUT" ];then break fi @@ -94,11 +95,11 @@ guests_managedsave() { echo "" - if [ $(/usr/sbin/virsh list --name | grep -v ^$ | wc -l) -gt "0" ];then + if [ $($VIRSH list --name | grep -v ^$ | wc -l) -gt "0" ];then echo -n "Following guests are still running after $TIMEOUT seconds, destroying them: " - for machine in $(/usr/sbin/virsh list --name | grep -v ^$) ; do - /usr/sbin/virsh destroy $machine + for machine in $($VIRSH list --name | grep -v ^$) ; do + $VIRSH destroy $machine echo -n "$machine " done @@ -140,7 +141,7 @@ start_libvirtd() { exit 1 fi echo "Starting libvirtd: /usr/sbin/libvirtd -d " - mkdir -p $(dirname $LIBVIRTD_PIDFILE) + mkdir -p $(dirname $LIBVIRTD_PIDFILE) /run/libvirt/{lockd,lxc,network,qemu/swtpm} check_processor /sbin/modprobe -a $MODULES /usr/sbin/libvirtd -d -l $LIBVIRTD_OPTS @@ -154,8 +155,8 @@ stop_libvirtd() { guests_managedsave check_processor echo "Stopping libvirtd..." - for network in $(/usr/sbin/virsh net-list --name); do - /usr/sbin/virsh net-destroy "$network" + for network in $($VIRSH net-list --name); do + $VIRSH net-destroy "$network" done kill -TERM $(cat $LIBVIRTD_PIDFILE) sleep 3 |