From 2543705986789658725aac808e85e2cb638ea3dd Mon Sep 17 00:00:00 2001 From: Alex Handle Date: Mon, 22 Oct 2012 13:23:34 +0200 Subject: Fix live migration volume assignment. In pre_live_migration volumes should get assigned (self.volume_api.initialize_connection) to the live migration target host. In post_live_migration the volumes should get unassigned (self.volume_api.terminate_connection) from the live migration source host. Fixes bug 1066887 Change-Id: Ic2db456cd5efbdf15db92f843c92230489efc551 --- nova/compute/manager.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index eae7149e9..77ce04e0e 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -2218,6 +2218,13 @@ class ComputeManager(manager.SchedulerDependentManager): if not block_device_info['block_device_mapping']: LOG.info(_('Instance has no volume.'), instance=instance) + # assign the volume to host system + # needed by the lefthand volume driver and maybe others + connector = self.driver.get_volume_connector(instance) + for bdm in self._get_instance_volume_bdms(context, instance['uuid']): + volume = self.volume_api.get(context, bdm['volume_id']) + self.volume_api.initialize_connection(context, volume, connector) + network_info = self._get_instance_nw_info(context, instance) # TODO(tr3buchet): figure out how on the earth this is necessary @@ -2299,12 +2306,16 @@ class ComputeManager(manager.SchedulerDependentManager): instance=instance_ref) # Detaching volumes. + connector = self.driver.get_volume_connector(instance_ref) for bdm in self._get_instance_volume_bdms(ctxt, instance_ref['uuid']): # NOTE(vish): We don't want to actually mark the volume # detached, or delete the bdm, just remove the # connection from this host. - self.remove_volume_connection(ctxt, bdm['volume_id'], - instance_ref) + + # remove the volume connection without detaching from hypervisor + # because the instance is not running anymore on the current host + volume = self.volume_api.get(ctxt, bdm['volume_id']) + self.volume_api.terminate_connection(ctxt, volume, connector) # Releasing vlan. # (not necessary in current implementation?) -- cgit