Merge "libvirt: fix DiskSmallerThanImage when block migrate ephemerals" into stable/newton
This commit is contained in:
commit
9d7ab8274c
@ -9252,10 +9252,11 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||||||
CONF.image_cache_subdirectory_name)
|
CONF.image_cache_subdirectory_name)
|
||||||
instance = objects.Instance(**self.test_instance)
|
instance = objects.Instance(**self.test_instance)
|
||||||
disk_info_byname = fake_disk_info_byname(instance)
|
disk_info_byname = fake_disk_info_byname(instance)
|
||||||
disk_info = disk_info_byname.values()
|
|
||||||
|
|
||||||
# Give the ephemeral disk a non-default name
|
|
||||||
disk_info_byname['disk.local']['backing_file'] = 'ephemeral_foo'
|
disk_info_byname['disk.local']['backing_file'] = 'ephemeral_foo'
|
||||||
|
disk_info_byname['disk.local']['virt_disk_size'] = 1 * units.Gi
|
||||||
|
|
||||||
|
disk_info = disk_info_byname.values()
|
||||||
|
|
||||||
with test.nested(
|
with test.nested(
|
||||||
mock.patch.object(libvirt_driver.libvirt_utils, 'fetch_image'),
|
mock.patch.object(libvirt_driver.libvirt_utils, 'fetch_image'),
|
||||||
@ -9283,8 +9284,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||||||
|
|
||||||
verify_base_size_mock.assert_has_calls([
|
verify_base_size_mock.assert_has_calls([
|
||||||
mock.call(root_backing, instance.flavor.root_gb * units.Gi),
|
mock.call(root_backing, instance.flavor.root_gb * units.Gi),
|
||||||
mock.call(ephemeral_backing,
|
mock.call(ephemeral_backing, 1 * units.Gi)
|
||||||
instance.flavor.ephemeral_gb * units.Gi)
|
|
||||||
])
|
])
|
||||||
|
|
||||||
def test_create_images_and_backing_disk_info_none(self):
|
def test_create_images_and_backing_disk_info_none(self):
|
||||||
|
@ -6587,12 +6587,19 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||||||
instance_disk,
|
instance_disk,
|
||||||
CONF.libvirt.images_type)
|
CONF.libvirt.images_type)
|
||||||
if cache_name.startswith('ephemeral'):
|
if cache_name.startswith('ephemeral'):
|
||||||
image.cache(fetch_func=self._create_ephemeral,
|
# The argument 'size' is used by image.cache to
|
||||||
fs_label=cache_name,
|
# validate disk size retrieved from cache against
|
||||||
os_type=instance.os_type,
|
# the instance disk size (should always return OK)
|
||||||
filename=cache_name,
|
# and ephemeral_size is used by _create_ephemeral
|
||||||
size=info['virt_disk_size'],
|
# to build the image if the disk is not already
|
||||||
ephemeral_size=instance.flavor.ephemeral_gb)
|
# cached.
|
||||||
|
image.cache(
|
||||||
|
fetch_func=self._create_ephemeral,
|
||||||
|
fs_label=cache_name,
|
||||||
|
os_type=instance.os_type,
|
||||||
|
filename=cache_name,
|
||||||
|
size=info['virt_disk_size'],
|
||||||
|
ephemeral_size=info['virt_disk_size'] / units.Gi)
|
||||||
elif cache_name.startswith('swap'):
|
elif cache_name.startswith('swap'):
|
||||||
inst_type = instance.get_flavor()
|
inst_type = instance.get_flavor()
|
||||||
swap_mb = inst_type.swap
|
swap_mb = inst_type.swap
|
||||||
|
Loading…
Reference in New Issue
Block a user