diff options
Diffstat (limited to 'nova/virt/xenapi/vmops.py')
-rw-r--r-- | nova/virt/xenapi/vmops.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index bf3f631b3..f1cf5fb69 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -1,7 +1,7 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright (c) 2010 Citrix Systems, Inc. -# Copyright 2010 OpenStack LLC. +# Copyright 2010 OpenStack Foundation # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -214,12 +214,22 @@ class VMOps(object): name_label = self._get_orig_vm_name_label(instance) vm_ref = vm_utils.lookup(self._session, name_label) - # Remove the '-orig' suffix (which was added in case the resized VM - # ends up on the source host, common during testing) - name_label = instance['name'] - vm_utils.set_vm_name_label(self._session, vm_ref, name_label) - - self._attach_mapped_block_devices(instance, block_device_info) + # NOTE(danms): if we're reverting migration in the failure case, + # make sure we don't have a conflicting vm still running here, + # as might be the case in a failed migrate-to-same-host situation + new_ref = vm_utils.lookup(self._session, instance['name']) + if vm_ref is not None: + if new_ref is not None: + self._destroy(instance, new_ref) + # Remove the '-orig' suffix (which was added in case the + # resized VM ends up on the source host, common during + # testing) + name_label = instance['name'] + vm_utils.set_vm_name_label(self._session, vm_ref, name_label) + self._attach_mapped_block_devices(instance, block_device_info) + elif new_ref is not None: + # We crashed before the -orig backup was made + vm_ref = new_ref self._start(instance, vm_ref) |