diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 98f928111b45..c074bd35c7c0 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -3463,6 +3463,11 @@ class ComputeManager(manager.Manager): instance_type, quotas, request_spec, filter_properties, node) + # NOTE(dgenin): This is thrown in LibvirtDriver when the + # instance to be migrated is backed by LVM. + # Remove when LVM migration is implemented. + except exception.MigrationPreCheckError: + raise except Exception: # try to re-schedule the resize elsewhere: exc_info = sys.exc_info() diff --git a/nova/tests/virt/libvirt/test_driver.py b/nova/tests/virt/libvirt/test_driver.py index bb2c5266d195..27544adc2889 100644 --- a/nova/tests/virt/libvirt/test_driver.py +++ b/nova/tests/virt/libvirt/test_driver.py @@ -9380,6 +9380,46 @@ class LibvirtDriverTestCase(test.TestCase): self.assertFalse(self.copy_or_move_swap_called) self.assertEqual(disk_info_text, out) + def test_migrate_disk_and_power_off_lvm(self): + """Test for nova.virt.libvirt.libvirt_driver.LibvirtConnection + .migrate_disk_and_power_off. + """ + + self.flags(images_type='lvm', group='libvirt') + disk_info = [{'type': 'raw', 'path': '/dev/vg/disk', + 'disk_size': '83886080'}, + {'type': 'raw', 'path': '/dev/disk.local', + 'disk_size': '83886080'}] + disk_info_text = jsonutils.dumps(disk_info) + + def fake_get_instance_disk_info(instance, xml=None, + block_device_info=None): + return disk_info_text + + def fake_destroy(instance): + pass + + def fake_get_host_ip_addr(): + return '10.0.0.1' + + def fake_execute(*args, **kwargs): + pass + + self.stubs.Set(self.libvirtconnection, 'get_instance_disk_info', + fake_get_instance_disk_info) + self.stubs.Set(self.libvirtconnection, '_destroy', fake_destroy) + self.stubs.Set(self.libvirtconnection, 'get_host_ip_addr', + fake_get_host_ip_addr) + self.stubs.Set(utils, 'execute', fake_execute) + + ins_ref = self._create_instance() + flavor = {'root_gb': 10, 'ephemeral_gb': 20} + + # Migration is not implemented for LVM backed instances + self.assertRaises(exception.MigrationPreCheckError, + self.libvirtconnection.migrate_disk_and_power_off, + None, ins_ref, '10.0.0.1', flavor, None) + def test_migrate_disk_and_power_off_resize_error(self): instance = self._create_instance() flavor = {'root_gb': 5} diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 6c39391ac291..5154213a5f9e 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -5096,6 +5096,12 @@ class LibvirtDriver(driver.ComputeDriver): block_device_info=block_device_info) disk_info = jsonutils.loads(disk_info_text) + # NOTE(dgenin): Migration is not implemented for LVM backed instances. + if (CONF.libvirt.images_type == 'lvm' and + not self._is_booted_from_volume(instance, disk_info_text)): + reason = "Migration is not supported for LVM backed instances" + raise exception.MigrationPreCheckError(reason) + # copy disks to destination # rename instance dir to +_resize at first for using # shared storage for instance dir (eg. NFS).