Skip to content

Commit

Permalink
Merge "Revert "libvirt: support live migrate of instances with conf d…
Browse files Browse the repository at this point in the history
…rives""
  • Loading branch information
Jenkins authored and openstack-gerrit committed Sep 25, 2014
2 parents 956e8e7 + 97a5578 commit 9bc59c0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 26 deletions.
6 changes: 6 additions & 0 deletions nova/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,12 @@ class InvalidWatchdogAction(Invalid):
msg_fmt = _("Provided watchdog action (%(action)s) is not supported.")


class NoLiveMigrationForConfigDriveInLibVirt(NovaException):
msg_fmt = _("Live migration of instances with config drives is not "
"supported in libvirt unless libvirt instance path and "
"drive data is shared across compute nodes.")


class LiveMigrationWithOldNovaNotSafe(NovaException):
msg_fmt = _("Host %(server)s is running an old version of Nova, "
"live migrations involving that version may cause data loss. "
Expand Down
27 changes: 20 additions & 7 deletions nova/tests/virt/libvirt/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -5753,6 +5753,26 @@ def fake_none(*args, **kwargs):
'vnc': '127.0.0.1'}}
self.assertEqual(result, target_res)

def test_pre_live_migration_block_with_config_drive_mocked(self):
# Creating testdata
vol = {'block_device_mapping': [
{'connection_info': 'dummy', 'mount_device': '/dev/sda'},
{'connection_info': 'dummy', 'mount_device': '/dev/sdb'}]}
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)

def fake_true(*args, **kwargs):
return True

self.stubs.Set(configdrive, 'required_by', fake_true)

inst_ref = {'id': 'foo'}
c = context.get_admin_context()

self.assertRaises(exception.NoLiveMigrationForConfigDriveInLibVirt,
conn.pre_live_migration, c, inst_ref, vol, None,
None, {'is_shared_instance_path': False,
'is_shared_block_storage': False})

def test_pre_live_migration_vol_backed_works_correctly_mocked(self):
# Creating testdata, using temp dir.
with utils.tempdir() as tmpdir:
Expand Down Expand Up @@ -12030,13 +12050,6 @@ def test_rescue_config_drive(self):
cdb.make_drive(mox.Regex(configdrive_path))
cdb.__exit__(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()
).AndReturn(None)

imagebackend.Backend.image(instance, 'disk.config.rescue', 'raw'
).AndReturn(fake_imagebackend.Raw())
imagebackend.Image.cache(fetch_func=mox.IgnoreArg(),
context=mox.IgnoreArg(),
filename='disk.config.rescue')

image_meta = {'id': 'fake', 'name': 'fake'}
self.libvirtconnection._get_guest_xml(mox.IgnoreArg(), instance,
network_info, mox.IgnoreArg(),
Expand Down
27 changes: 8 additions & 19 deletions nova/virt/libvirt/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3083,16 +3083,6 @@ def clone_fallback_to_fetch(*args, **kwargs):
'with error: %s'),
e, instance=instance)

def dummy_fetch_func(target, *args, **kwargs):
# NOTE(sileht): this is never called because the
# the target have already been created by
# cdb.make_drive call
pass

raw('disk.config').cache(fetch_func=dummy_fetch_func,
context=context,
filename='disk.config' + suffix)

# File injection only if needed
elif inject_files and CONF.libvirt.inject_partition != -2:
if booted_from_volume:
Expand Down Expand Up @@ -3478,19 +3468,11 @@ def _get_guest_storage_config(self, instance, image_meta,
block_device.prepend_dev(diskswap.target_dev))

if 'disk.config' in disk_mapping:
# NOTE(sileht): a configdrive is a raw image
# it works well with rbd, lvm and raw images_type
# but we must force to raw image_type if the desired
# images_type is qcow2
if CONF.libvirt.images_type not in ['rbd', 'lvm']:
image_type = "raw"
else:
image_type = None
diskconfig = self._get_guest_disk_config(instance,
'disk.config',
disk_mapping,
inst_type,
image_type)
'raw')
devices.append(diskconfig)

for vol in block_device.get_bdms_to_connect(block_device_mapping,
Expand Down Expand Up @@ -5440,6 +5422,13 @@ def pre_live_migration(self, context, instance, block_device_info,
is_block_migration = migrate_data.get('block_migration', True)
instance_relative_path = migrate_data.get('instance_relative_path')

if not (is_shared_instance_path and is_shared_block_storage):
# NOTE(mikal): live 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.NoLiveMigrationForConfigDriveInLibVirt()

if not is_shared_instance_path:
# NOTE(mikal): this doesn't use libvirt_utils.get_instance_path
# because we are ensuring that the same instance directory name
Expand Down

0 comments on commit 9bc59c0

Please sign in to comment.