aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-12-31 13:52:09 -0200
committerSilvio Rhatto <rhatto@riseup.net>2017-12-31 13:52:09 -0200
commit41176f764cf5d1c3140a9fdf21de7cfa41c6d99c (patch)
treeb99fce7a7fc0fb6d316f6f0a70d8f3c5ac2dda91
parentac369edea092ef40dcf021f3a6baabd63413ca2c (diff)
downloadkvmx-41176f764cf5d1c3140a9fdf21de7cfa41c6d99c.tar.gz
kvmx-41176f764cf5d1c3140a9fdf21de7cfa41c6d99c.tar.bz2
Adds restart action
-rwxr-xr-xkvmx37
1 files changed, 36 insertions, 1 deletions
diff --git a/kvmx b/kvmx
index 7d8dbc2..3db4844 100755
--- a/kvmx
+++ b/kvmx
@@ -697,7 +697,28 @@ function kvmx_poweroff {
fi
kvmx_xephyr_stop
- sleep 3
+
+ let poweroff_attempts="0"
+ echo -n "Waiting for machine to stop..."
+ while true; do
+ kvmx_running || break
+
+ echo -n "."
+ let poweroff_attempts++
+
+ if [ "$poweroff_attempts" == "20" ]; then
+ echo "$BASENAME: guest $VM is still running"
+ echo "$BASENAME: please consider to stop it using \"kvmx $VM stop\""
+ #kvmx_stop
+ exit 1
+ fi
+
+ sleep 3
+ done
+ echo " done."
+ #sleep 3
+ #echo ""
+
kvmx_status
}
@@ -1276,6 +1297,20 @@ function kvmx_run {
kvmx_up $*
}
+# Restart machine
+function kvmx_restart {
+ if ! kvmx_running; then
+ echo "Guest $VM was not running, so starting it anyway..."
+ kvmx_start
+ else
+ echo "Powering off guest $VM..."
+ kvmx_poweroff
+
+ echo "Starting guest $VM again..."
+ kvmx_start
+ fi
+}
+
# Connect to the guest using VNC
function kvmx_vnc {
if ! kvmx_running; then