From 60cc0d039ca8325cf1b9a7e396ca4e5fc96eedcc Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 30 Mar 2017 09:22:44 -0300 Subject: Adds suspended action and check if machine is suspended at up action --- kvmx | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3