diff options
-rw-r--r-- | nova/compute/manager.py | 18 | ||||
-rw-r--r-- | nova/tests/test_libvirt.py | 8 | ||||
-rw-r--r-- | nova/virt/driver.py | 9 | ||||
-rw-r--r-- | nova/virt/fake.py | 9 | ||||
-rw-r--r-- | nova/virt/hyperv/driver.py | 6 | ||||
-rw-r--r-- | nova/virt/libvirt/driver.py | 31 | ||||
-rw-r--r-- | nova/virt/xenapi/driver.py | 9 | ||||
-rw-r--r-- | nova/virt/xenapi/vmops.py | 3 |
8 files changed, 69 insertions, 24 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index a836a8f17..cd756af65 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -1445,8 +1445,12 @@ class ComputeManager(manager.SchedulerDependentManager): old_instance_type = migration_ref['old_instance_type_id'] instance_type = instance_types.get_instance_type(old_instance_type) + block_device_info = self._get_instance_volume_block_device_info( + context, instance['uuid']) + self.driver.finish_revert_migration(instance, - self._legacy_nw_info(network_info)) + self._legacy_nw_info(network_info), + block_device_info) # Just roll back the record. There's no need to resize down since # the 'old' VM already has the preferred attributes @@ -1558,9 +1562,13 @@ class ComputeManager(manager.SchedulerDependentManager): self._notify_about_instance_usage( context, instance, "resize.start", network_info=network_info) + block_device_info = self._get_instance_volume_block_device_info( + context, instance['uuid']) + disk_info = self.driver.migrate_disk_and_power_off( context, instance, migration_ref['dest_host'], - instance_type_ref, self._legacy_nw_info(network_info)) + instance_type_ref, self._legacy_nw_info(network_info), + block_device_info) self.db.migration_update(context, migration_id, @@ -1609,10 +1617,14 @@ class ComputeManager(manager.SchedulerDependentManager): context, instance, "finish_resize.start", network_info=network_info) + block_device_info = self._get_instance_volume_block_device_info( + context, instance['uuid']) + self.driver.finish_migration(context, migration_ref, instance, disk_info, self._legacy_nw_info(network_info), - image, resize_instance) + image, resize_instance, + block_device_info) instance = self._instance_update(context, instance['uuid'], diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 8e052a104..bca9544fc 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -3757,7 +3757,8 @@ class LibvirtDriverTestCase(test.TestCase): def fake_extend(path, size): pass - def fake_to_xml(instance, network_info): + def fake_to_xml(instance, network_info, image_meta=None, rescue=None, + block_device_info=None): return "" def fake_plug_vifs(instance, network_info): @@ -3823,6 +3824,11 @@ class LibvirtDriverTestCase(test.TestCase): def fake_get_info(instance): return {'state': power_state.RUNNING} + def fake_to_xml(instance, network_info, image_meta=None, rescue=None, + block_device_info=None): + return "" + + self.stubs.Set(self.libvirtconnection, 'to_xml', fake_to_xml) self.stubs.Set(self.libvirtconnection, 'plug_vifs', fake_plug_vifs) self.stubs.Set(utils, 'execute', fake_execute) fw = base_firewall.NoopFirewallDriver() diff --git a/nova/virt/driver.py b/nova/virt/driver.py index 1d8f94e9d..41df132fc 100644 --- a/nova/virt/driver.py +++ b/nova/virt/driver.py @@ -242,7 +242,8 @@ class ComputeDriver(object): raise NotImplementedError() def migrate_disk_and_power_off(self, context, instance, dest, - instance_type, network_info): + instance_type, network_info, + block_device_info=None): """ Transfers the disk of a running instance in multiple phases, turning off the instance before the end. @@ -261,7 +262,8 @@ class ComputeDriver(object): raise NotImplementedError() def finish_migration(self, context, migration, instance, disk_info, - network_info, image_meta, resize_instance): + network_info, image_meta, resize_instance, + block_device_info=None): """Completes a resize, turning on the migrated instance :param network_info: @@ -277,7 +279,8 @@ class ComputeDriver(object): # TODO(Vek): Need to pass context in for access to auth_token raise NotImplementedError() - def finish_revert_migration(self, instance, network_info): + def finish_revert_migration(self, instance, network_info, + block_device_info=None): """Finish reverting a resize, powering back on the instance""" # TODO(Vek): Need to pass context in for access to auth_token raise NotImplementedError() diff --git a/nova/virt/fake.py b/nova/virt/fake.py index db7f3a6ff..48ee67d5b 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -124,10 +124,12 @@ class FakeDriver(driver.ComputeDriver): pass def migrate_disk_and_power_off(self, context, instance, dest, - instance_type, network_info): + instance_type, network_info, + block_device_info=None): pass - def finish_revert_migration(self, instance, network_info): + def finish_revert_migration(self, instance, network_info, + block_device_info=None): pass def power_off(self, instance): @@ -252,7 +254,8 @@ class FakeDriver(driver.ComputeDriver): return def finish_migration(self, context, migration, instance, disk_info, - network_info, image_meta, resize_instance): + network_info, image_meta, resize_instance, + block_device_info=None): return def confirm_migration(self, migration, instance, network_info): diff --git a/nova/virt/hyperv/driver.py b/nova/virt/hyperv/driver.py index f385640f5..539794e48 100644 --- a/nova/virt/hyperv/driver.py +++ b/nova/virt/hyperv/driver.py @@ -207,12 +207,14 @@ class HyperVDriver(driver.ComputeDriver): """Confirms a resize, destroying the source VM""" LOG.debug(_("confirm_migration called"), instance=instance) - def finish_revert_migration(self, instance, network_info): + def finish_revert_migration(self, instance, network_info, + block_device_info=None): """Finish reverting a resize, powering back on the instance""" LOG.debug(_("finish_revert_migration called"), instance=instance) def finish_migration(self, context, migration, instance, disk_info, - network_info, image_meta, resize_instance=False): + network_info, image_meta, resize_instance=False, + block_device_info=None): """Completes a resize, turning on the migrated instance""" LOG.debug(_("finish_migration called"), instance=instance) diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index daa0840b6..41bbd2d22 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -2765,7 +2765,8 @@ class LibvirtDriver(driver.ComputeDriver): @exception.wrap_exception() def migrate_disk_and_power_off(self, context, instance, dest, - instance_type, network_info): + instance_type, network_info, + block_device_info=None): LOG.debug(_("Starting migrate_disk_and_power_off"), instance=instance) disk_info_text = self.get_instance_disk_info(instance['name']) @@ -2773,6 +2774,15 @@ class LibvirtDriver(driver.ComputeDriver): self.power_off(instance) + block_device_mapping = driver.block_device_info_get_mapping( + block_device_info) + for vol in block_device_mapping: + connection_info = vol['connection_info'] + mount_device = vol['mount_device'].rpartition("/")[2] + self.volume_driver_method('disconnect_volume', + connection_info, + mount_device) + # copy disks to destination # rename instance dir to +_resize at first for using # shared storage for instance dir (eg. NFS). @@ -2826,7 +2836,8 @@ class LibvirtDriver(driver.ComputeDriver): @exception.wrap_exception() def finish_migration(self, context, migration, instance, disk_info, - network_info, image_meta, resize_instance): + network_info, image_meta, resize_instance, + block_device_info=None): LOG.debug(_("Starting finish_migration"), instance=instance) # resize disks. only "disk" and "disk.local" are necessary. @@ -2863,18 +2874,21 @@ class LibvirtDriver(driver.ComputeDriver): '-O', 'qcow2', info['path'], path_qcow) utils.execute('mv', path_qcow, info['path']) - xml = self.to_xml(instance, network_info) + xml = self.to_xml(instance, network_info, + block_device_info=block_device_info) # assume _create_image do nothing if a target file exists. # TODO(oda): injecting files is not necessary self._create_image(context, instance, xml, network_info=network_info, block_device_info=None) - self._create_domain_and_network(xml, instance, network_info) + self._create_domain_and_network(xml, instance, network_info, + block_device_info) timer = utils.LoopingCall(self._wait_for_running, instance) timer.start(interval=0.5).wait() @exception.wrap_exception() - def finish_revert_migration(self, instance, network_info): + def finish_revert_migration(self, instance, network_info, + block_device_info=None): LOG.debug(_("Starting finish_revert_migration"), instance=instance) @@ -2882,9 +2896,10 @@ class LibvirtDriver(driver.ComputeDriver): inst_base_resize = inst_base + "_resize" utils.execute('mv', inst_base_resize, inst_base) - xml_path = os.path.join(inst_base, 'libvirt.xml') - xml = open(xml_path).read() - self._create_domain_and_network(xml, instance, network_info) + xml = self.to_xml(instance, network_info, + block_device_info=block_device_info) + self._create_domain_and_network(xml, instance, network_info, + block_device_info) timer = utils.LoopingCall(self._wait_for_running, instance) timer.start(interval=0.5).wait() diff --git a/nova/virt/xenapi/driver.py b/nova/virt/xenapi/driver.py index 09eba2489..3425c64f8 100644 --- a/nova/virt/xenapi/driver.py +++ b/nova/virt/xenapi/driver.py @@ -183,13 +183,15 @@ class XenAPIDriver(driver.ComputeDriver): # TODO(Vek): Need to pass context in for access to auth_token self._vmops.confirm_migration(migration, instance, network_info) - def finish_revert_migration(self, instance, network_info): + def finish_revert_migration(self, instance, network_info, + block_device_info=None): """Finish reverting a resize, powering back on the instance""" # NOTE(vish): Xen currently does not use network info. self._vmops.finish_revert_migration(instance) def finish_migration(self, context, migration, instance, disk_info, - network_info, image_meta, resize_instance=False): + network_info, image_meta, resize_instance=False, + block_device_info=None): """Completes a resize, turning on the migrated instance""" self._vmops.finish_migration(context, migration, instance, disk_info, network_info, image_meta, resize_instance) @@ -230,7 +232,8 @@ class XenAPIDriver(driver.ComputeDriver): self._vmops.unpause(instance) def migrate_disk_and_power_off(self, context, instance, dest, - instance_type, network_info): + instance_type, network_info, + block_device_info=None): """Transfers the VHD of a running instance to another host, then shuts off the instance copies over the COW disk""" # NOTE(vish): Xen currently does not use network info. diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index c76f9f425..d3cead640 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -189,7 +189,8 @@ class VMOps(object): self._start(instance, vm_ref) def finish_migration(self, context, migration, instance, disk_info, - network_info, image_meta, resize_instance): + network_info, image_meta, resize_instance, + block_device_info=None): root_vdi = vm_utils.move_disks(self._session, instance, disk_info) if resize_instance: |