From 70677e81b74048931c4e87d3f5de5a19d0d3f6d4 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Mon, 7 May 2012 15:24:05 +0200 Subject: [PATCH] bug #1151: added switch to destroy kvm VMs with ACPI enabled Based on the patch provided by "jan horacek" http://dev.opennebula.org/issues/1151 --- src/vmm_mad/remotes/kvm/kvmrc | 4 ++++ src/vmm_mad/remotes/kvm/shutdown | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/vmm_mad/remotes/kvm/kvmrc b/src/vmm_mad/remotes/kvm/kvmrc index 8f36a9b9a0..99a66095df 100644 --- a/src/vmm_mad/remotes/kvm/kvmrc +++ b/src/vmm_mad/remotes/kvm/kvmrc @@ -26,3 +26,7 @@ export SHUTDOWN_TIMEOUT=300 # Uncomment this line to force VM cancellation after shutdown timeout #export FORCE_DESTROY=yes +# Uncomment this line to force VM's without ACPI enabled to be destroyed +# on shutdown +#CANCEL_NO_ACPI=yes + diff --git a/src/vmm_mad/remotes/kvm/shutdown b/src/vmm_mad/remotes/kvm/shutdown index 2e6b1099c3..8fbfebd63f 100755 --- a/src/vmm_mad/remotes/kvm/shutdown +++ b/src/vmm_mad/remotes/kvm/shutdown @@ -23,6 +23,16 @@ count=0 deploy_id=$1 +shutdown_command="virsh --connect $LIBVIRT_URI shutdown $deploy_id" + +if [ "x$CANCEL_NO_ACPI" = "xyes" ]; then + virsh --connect $LIBVIRT_URI dumpxml $deploy_id | grep -q acpi + + if [ "x$?" != "x0" ]; then + virsh --connect $LIBVIRT_URI destroy $deploy_id + fi +fi + if [ -z "$SHUTDOWN_TIMEOUT" ]; then TIMEOUT=120 else @@ -36,7 +46,7 @@ function monitor # Issue another shutdown to cover occasional libvirt lack of attention if [ "$count" -eq "$HALF_LOOP" ] then - virsh --connect $LIBVIRT_URI shutdown $deploy_id + $($shutdown_command) fi let count=count+1 @@ -48,7 +58,7 @@ function monitor [ "x$?" != "x0" ] } -exec_and_log "virsh --connect $LIBVIRT_URI shutdown $deploy_id" \ +exec_and_log "$shutdown_command" \ "Could not shutdown $deploy_id" retry $TIMEOUT monitor