libvirt: partial fix for live-migration with config drive

In current version of nova, live-migration with config drive on
local disk is forbidden due to the bug of libvirt of copying readonly
disk. However, if we use vfat as the format of config drive,
the function of live-migration works well.

In this patch, we re-open the function of live-migration to admin users.
Notice you should add 'config_drive_format=vfat' in nova.conf explicitly.

This patch doesn't solve the problem fundamentally which need further
efforts, but offers a simple and feasible workaround to user.

DocImpact

Conflicts:
        nova/virt/libvirt/driver.py

NOTE(symonds): The conflicts are due to:
        not using is_shared_instance_path or is_shared_block_storage in stable/icehouse.

Conflicts:
        nova/tests/unit/virt/libvirt/test_driver.py

NOTE(symonds): The conflicts are due to:
        libvirt_driver.LibvirtDriver().pre_live_migration() returning None on success
            instead of Spice and VNC information.
        not using is_shared_instance_path or is_shared_block_storage in stable/icehouse.

Co-Authored-By: Davanum Srinivas <davanum@gmail.com>, Matt Riedemann <mriedem@us.ibm.com>
Change-Id: I7429e12766da7f7f8d484b3a9df6247e832816b0
Partial-Bug: #1246201
(cherry picked from commit 7c4be65733)
This commit is contained in:
Matt Symonds 2014-11-12 01:42:37 -08:00
parent e2ec8d89f9
commit 8876294fe6
2 changed files with 34 additions and 5 deletions

View File

@ -4326,6 +4326,33 @@ class LibvirtConnTestCase(test.TestCase):
conn.pre_live_migration, c, inst_ref, vol, None,
None, {'is_shared_storage': False})
@mock.patch('nova.virt.driver.block_device_info_get_mapping',
return_value=())
@mock.patch('nova.virt.configdrive.required_by',
return_value=True)
def test_pre_live_migration_block_with_config_drive_mocked_with_vfat(
self, mock_required_by, block_device_info_get_mapping):
self.flags(config_drive_format='vfat')
# Creating testdata
vol = {'block_device_mapping': [
{'connection_info': 'dummy', 'mount_device': '/dev/sda'},
{'connection_info': 'dummy', 'mount_device': '/dev/sdb'}]}
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
self.test_instance['name'] = 'fake'
self.test_instance['kernel_id'] = None
res_data = drvr.pre_live_migration(
self.context, self.test_instance, vol, [], None,
{'is_shared_storage': False})
block_device_info_get_mapping.assert_called_once_with(
{'block_device_mapping': [
{'connection_info': 'dummy', 'mount_device': '/dev/sda'},
{'connection_info': 'dummy', 'mount_device': '/dev/sdb'}
]}
)
self.assertIsNone(res_data)
def test_pre_live_migration_vol_backed_works_correctly_mocked(self):
# Creating testdata, using temp dir.
with utils.tempdir() as tmpdir:

View File

@ -4605,11 +4605,13 @@ class LibvirtDriver(driver.ComputeDriver):
instance_relative_path = migrate_data.get('instance_relative_path')
if not is_shared_storage:
# NOTE(mikal): block migration of instances using config drive is
# not supported because of a bug in libvirt (read only devices
# are not copied by libvirt). See bug/1246201
if configdrive.required_by(instance):
raise exception.NoBlockMigrationForConfigDriveInLibVirt()
# NOTE(dims): Using config drive with iso format does not work
# because of a bug in libvirt with read only devices. However
# one can use vfat as config_drive_format which works fine.
# Please see bug/1246201 for details on the libvirt bug.
if CONF.config_drive_format != 'vfat':
if configdrive.required_by(instance):
raise exception.NoBlockMigrationForConfigDriveInLibVirt()
# NOTE(mikal): this doesn't use libvirt_utils.get_instance_path
# because we are ensuring that the same instance directory name