]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Adds suspended action and check if machine is suspended at up action
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 30 Mar 2017 12:22:44 +0000 (09:22 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 30 Mar 2017 12:22:44 +0000 (09:22 -0300)
kvmx

diff --git a/kvmx b/kvmx
index db7514c52217bb81e0c53f8050fd6713569405b1..65c81ea624dcb4cd94f4021d43984a4780837459 100755 (executable)
--- 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