From: Silvio Rhatto Date: Thu, 30 Mar 2017 12:22:44 +0000 (-0300) Subject: Adds suspended action and check if machine is suspended at up action X-Git-Tag: 0.1.0~501 X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=60cc0d039ca8325cf1b9a7e396ca4e5fc96eedcc;p=kvmx.git Adds suspended action and check if machine is suspended at up action --- 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