From c0f472b76878a0453d93cfff2b7e0318afce7d70 Mon Sep 17 00:00:00 2001 From: Kelven Yang Date: Wed, 14 Sep 2011 16:12:58 -0700 Subject: [PATCH] bug 11286: ensure VM is powered off before we tear down devices --- client/tomcatconf/components-premium.xml.in | 2 ++ .../com/cloud/hypervisor/vmware/resource/VmwareResource.java | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/client/tomcatconf/components-premium.xml.in b/client/tomcatconf/components-premium.xml.in index 82a903864c4..873a0d0601b 100755 --- a/client/tomcatconf/components-premium.xml.in +++ b/client/tomcatconf/components-premium.xml.in @@ -15,10 +15,12 @@ + + diff --git a/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java index 1fc661b42f6..45a99643ac4 100755 --- a/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/core/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -2614,7 +2614,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa HostMO hostMo = vmMo.getRunningHost(); List networks = vmMo.getNetworksWithDetails(); - // tear down all devices first before we destroy the VM to avoid accidently delete disk backing files + // tear down all devices first before we destroy the VM to avoid accidently delete disk backing files + if (getVmState(vmMo) != State.Stopped) + vmMo.safePowerOff(_shutdown_waitMs); vmMo.tearDownDevices(new Class[] { VirtualDisk.class, VirtualEthernetCard.class }); vmMo.destroy();