aboutsummaryrefslogtreecommitdiff
path: root/libraries/libvirt
diff options
context:
space:
mode:
authorSebastian Arcus <s.arcus@open-t.co.uk>2018-03-05 23:18:02 -0600
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2018-03-10 07:11:13 +0700
commit480d09ca14814c7ab6e155d9a7a1b5ffaa47f974 (patch)
tree867f94ef06ae3c597357de36a0b15ad7183cb97f /libraries/libvirt
parent14c188e5af52bd73179e58acdb9cb2bf71af258c (diff)
libraries/libvirt: Properly initialize $count in rc.libvirt
This commit also contains some other minor fixups. Signed-off-by: Robby Workman <rworkman@slackbuilds.org>
Diffstat (limited to 'libraries/libvirt')
-rw-r--r--libraries/libvirt/rc.libvirt26
1 files changed, 20 insertions, 6 deletions
diff --git a/libraries/libvirt/rc.libvirt b/libraries/libvirt/rc.libvirt
index 8f62da5db8343..59d953918ad64 100644
--- a/libraries/libvirt/rc.libvirt
+++ b/libraries/libvirt/rc.libvirt
@@ -34,7 +34,11 @@ guests_shutdown() {
/usr/sbin/virsh shutdown $machine &
done
- echo -n "Waiting for guests to finish shutting down"
+ sleep 2
+
+ echo -n "Waiting for guests to finish shutting down..."
+
+ count=0
while [ $(/usr/sbin/virsh list --name --state-running | grep -v ^$ | wc -l) -gt "0" ]; do
if [ "$count" -ge "$TIMEOUT" ];then
@@ -49,13 +53,17 @@ guests_shutdown() {
if [ $(/usr/sbin/virsh list --name --state-running | grep -v ^$ | wc -l) -gt "0" ];then
- echo -n "The following guests are still running, destroying them: "
+ 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
echo -n "$machine "
done
sleep 2
+ else
+ # add back the seconds we waited before starting the count
+ count=$(expr $count + 2)
+ echo "Shutdown of guests took $count seconds..."
fi
}
@@ -65,13 +73,15 @@ 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)
- count=0
-
for machine in $(/usr/sbin/virsh list --name | grep -v ^$) ; do
/usr/sbin/virsh managedsave $machine &
done
- echo -n "Waiting for managedsave to finish on all guests"
+ sleep 2
+
+ echo -n "Waiting for managedsave to finish on all guests..."
+
+ count = 0
while [ $(/usr/sbin/virsh list --name | grep -v ^$ | wc -l) -gt "0" ]; do
if [ "$count" -ge "$TIMEOUT" ];then
@@ -86,13 +96,17 @@ guests_managedsave() {
if [ $(/usr/sbin/virsh list --name | grep -v ^$ | wc -l) -gt "0" ];then
- echo -n "The following guests are still running, destroying them: "
+ 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
echo -n "$machine "
done
sleep 2
+ else
+ # add back the seconds we waited before starting the count
+ count=$(expr $count + 2)
+ echo "Guests managed save took $count seconds..."
fi
}