aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-03-30 09:22:44 -0300
committerSilvio Rhatto <rhatto@riseup.net>2017-03-30 09:22:44 -0300
commit60cc0d039ca8325cf1b9a7e396ca4e5fc96eedcc (patch)
tree37919d70096e97e105ea16436bb0664231a16976
parent013b6f0697050532a9c62e7a62eb81025b9317b1 (diff)
downloadkvmx-60cc0d039ca8325cf1b9a7e396ca4e5fc96eedcc.tar.gz
kvmx-60cc0d039ca8325cf1b9a7e396ca4e5fc96eedcc.tar.bz2
Adds suspended action and check if machine is suspended at up action
-rwxr-xr-xkvmx23
1 files changed, 22 insertions, 1 deletions
diff --git a/kvmx b/kvmx
index db7514c..65c81ea 100755
--- a/kvmx
+++ b/kvmx
@@ -172,7 +172,15 @@ function kvmx_spice {
# Bring virtual machine up
function kvmx_up {
- if kvmx_running; then
+ if kvmx_suspended; then
+ $DIRNAME/$BASENAME resume $VM
+
+ if [ "$run_spice_client" == "1" ]; then
+ $DIRNAME/$BASENAME spice $VM
+ fi
+
+ exit
+ elif kvmx_running; then
echo "$BASENAME: guest $VM is already running"
exit 1
fi
@@ -388,6 +396,19 @@ function kvmx_running {
return $?
}
+# Check if a guest is running
+function kvmx_suspended {
+ if ! kvmx_running; then
+ return 1
+ else
+ if ps -p $PID -o stat --no-headers | grep -q 'Tl'; then
+ return 0
+ else
+ return 1
+ fi
+ fi
+}
+
# Resume the guest
function kvmx_resume {
if ! kvmx_running; then