From f539bf7d0522f4a83a212534ec0dac988c36c87a Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Wed, 9 May 2012 04:34:40 +0000 Subject: Remove unnecessary shutdown argument to _destroy() Xen requires the VM power state be not running before it can be destroyed. Xen also requires the VM power state to be running to shutdown a VM. The shutdown argument was available to ensure that a shutdown was not attempted when the VM was not running. Since commit f5b051bbd0858294157f911ecbb04542fadbb38d, the _shutdown() method checks the power state and determines if it should issue the shutdown command or not. As a result, the shutdown argument is unnecessary and always calling the _shutdown() method will ensure the VM is in the proper state for the destroy to succeed. Change-Id: I9bc6007598da4ac69e8d463be9af51deaf5d6535 --- nova/virt/xenapi/vmops.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'nova') diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 205687fc9..6cc0e2554 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -190,7 +190,7 @@ class VMOps(object): def confirm_migration(self, migration, instance, network_info): name_label = self._get_orig_vm_name_label(instance) vm_ref = VMHelper.lookup(self._session, name_label) - return self._destroy(instance, vm_ref, network_info, shutdown=False) + return self._destroy(instance, vm_ref, network_info) def finish_revert_migration(self, instance): # NOTE(sirp): the original vm was suffixed with '-orig'; find it using @@ -630,7 +630,7 @@ class VMOps(object): finally: if template_vm_ref: self._destroy(instance, template_vm_ref, - shutdown=False, destroy_kernel_ramdisk=False) + destroy_kernel_ramdisk=False) LOG.debug(_("Finished snapshot and upload for VM"), instance=instance) @@ -800,7 +800,7 @@ class VMOps(object): finally: if template_vm_ref: self._destroy(instance, template_vm_ref, - shutdown=False, destroy_kernel_ramdisk=False) + destroy_kernel_ramdisk=False) return vdis @@ -1119,13 +1119,13 @@ class VMOps(object): if rescue_vm_ref: self._destroy_rescue_instance(rescue_vm_ref, vm_ref) - return self._destroy(instance, vm_ref, network_info, shutdown=True) + return self._destroy(instance, vm_ref, network_info) - def _destroy(self, instance, vm_ref, network_info=None, shutdown=True, + def _destroy(self, instance, vm_ref, network_info=None, destroy_kernel_ramdisk=True): """Destroys VM instance by performing: - 1. A shutdown if requested. + 1. A shutdown 2. Destroying associated VDIs. 3. Destroying kernel and ramdisk files (if necessary). 4. Destroying that actual VM record. @@ -1136,8 +1136,7 @@ class VMOps(object): instance=instance) return is_snapshot = VMHelper.is_snapshot(self._session, vm_ref) - if shutdown: - self._shutdown(instance, vm_ref) + self._shutdown(instance, vm_ref) # Destroy VDIs vdi_refs = VMHelper.lookup_vm_vdis(self._session, vm_ref) -- cgit