Merge "Fix processing of libvirt disk.info in non-disk-image cases" into stable/liberty
This commit is contained in:
commit
475b255862
|
@ -12887,16 +12887,23 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
|
|||
mock_path.return_value = instance_base
|
||||
mock_shared.return_value = False
|
||||
|
||||
src_disk_info_path = os.path.join(instance_base + '_resize',
|
||||
'disk.info')
|
||||
|
||||
with mock.patch.object(os.path, 'exists', autospec=True) \
|
||||
as mock_exists:
|
||||
# disk.info exists on the source
|
||||
mock_exists.side_effect = \
|
||||
lambda path: path == src_disk_info_path
|
||||
self.drvr.migrate_disk_and_power_off(context.get_admin_context(),
|
||||
instance, mock.sentinel,
|
||||
flavor_obj, None)
|
||||
self.assertTrue(mock_exists.called)
|
||||
|
||||
src_disk_info_path = os.path.join(instance_base + '_resize',
|
||||
'disk.info')
|
||||
dst_disk_info_path = os.path.join(instance_base, 'disk.info')
|
||||
mock_copy.assert_any_call(src_disk_info_path, dst_disk_info_path,
|
||||
host=mock.sentinel, on_execute=mock.ANY,
|
||||
on_completion=mock.ANY, compression=mock.ANY)
|
||||
on_completion=mock.ANY)
|
||||
|
||||
def test_wait_for_running(self):
|
||||
def fake_get_info(instance):
|
||||
|
|
|
@ -6814,6 +6814,11 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
dest = None
|
||||
utils.execute('mkdir', '-p', inst_base)
|
||||
|
||||
on_execute = lambda process: \
|
||||
self.job_tracker.add_job(instance, process.pid)
|
||||
on_completion = lambda process: \
|
||||
self.job_tracker.remove_job(instance, process.pid)
|
||||
|
||||
active_flavor = instance.get_flavor()
|
||||
for info in disk_info:
|
||||
# assume inst_base == dirname(info['path'])
|
||||
|
@ -6832,10 +6837,6 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
if not (fname == 'disk.swap' and
|
||||
active_flavor.get('swap', 0) != flavor.get('swap', 0)):
|
||||
|
||||
on_execute = lambda process: self.job_tracker.add_job(
|
||||
instance, process.pid)
|
||||
on_completion = lambda process: self.job_tracker.\
|
||||
remove_job(instance, process.pid)
|
||||
compression = info['type'] not in NO_COMPRESSION_TYPES
|
||||
libvirt_utils.copy_image(from_path, img_path, host=dest,
|
||||
on_execute=on_execute,
|
||||
|
@ -6845,11 +6846,12 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
# Ensure disk.info is written to the new path to avoid disks being
|
||||
# reinspected and potentially changing format.
|
||||
src_disk_info_path = os.path.join(inst_base_resize, 'disk.info')
|
||||
if os.path.exists(src_disk_info_path):
|
||||
dst_disk_info_path = os.path.join(inst_base, 'disk.info')
|
||||
libvirt_utils.copy_image(src_disk_info_path, dst_disk_info_path,
|
||||
libvirt_utils.copy_image(src_disk_info_path,
|
||||
dst_disk_info_path,
|
||||
host=dest, on_execute=on_execute,
|
||||
on_completion=on_completion,
|
||||
compression=compression)
|
||||
on_completion=on_completion)
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception():
|
||||
self._cleanup_remote_migration(dest, inst_base,
|
||||
|
|
Loading…
Reference in New Issue