libvirt: Don't disregard cache mode for instance boot disks
One of the things this commit: commit14c38ac0f2
Author: Kashyap Chamarthy <kchamart@redhat.com> Date: Thu Jul 20 19:01:23 2017 +0200 libvirt: Post-migration, set cache value for Cinder volume(s) [...] did was to supposedly remove "duplicate" calls to _set_cache_mode(). But that came back to bite us. Now, while the Cinder volumes are taken care of w.r.t handling its cache value during migration, but the above referred commit (14c38ac
) seemed to introduce a regression because it disregards the 'disk_cachemodes' Nova config parameter altogether for boot disks -- i.e. even though if a user set the cache mode to be 'writeback', it's ignored and instead 'none' is set unconditionally. Add the _set_cache_mode() calls back in _get_guest_storage_config(). Co-Authored-By: melanie witt <melwittt@gmail.com> Closes-Bug: #1727558 Conflicts: nova/tests/unit/virt/libvirt/test_driver.py NOTE(melwitt): The conflict is from unit tests in pike that don't exist in ocata. Change-Id: I7370cc2942a6c8c51ab5355b50a9e5666cca042e (cherry picked from commit24e79bcbf7
) (cherry picked from commit60d6e87cac
)
This commit is contained in:
parent
735f484ac8
commit
fc10b54f25
|
@ -4947,6 +4947,49 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||
self.assertEqual(10000, cfg.cputune.shares)
|
||||
self.assertEqual(20000, cfg.cputune.period)
|
||||
|
||||
def _test_get_guest_config_disk_cachemodes(self, images_type):
|
||||
# Verify that the configured cachemodes are propagated to the device
|
||||
# configurations.
|
||||
if images_type == 'flat':
|
||||
cachemode = 'file=directsync'
|
||||
elif images_type == 'lvm':
|
||||
cachemode = 'block=writethrough'
|
||||
elif images_type == 'rbd':
|
||||
cachemode = 'network=writeback'
|
||||
self.flags(disk_cachemodes=[cachemode], group='libvirt')
|
||||
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
||||
instance_ref = objects.Instance(**self.test_instance)
|
||||
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
|
||||
disk_info = blockinfo.get_disk_info(CONF.libvirt.virt_type,
|
||||
instance_ref,
|
||||
image_meta)
|
||||
cfg = drvr._get_guest_config(instance_ref, [],
|
||||
image_meta, disk_info)
|
||||
for d in cfg.devices:
|
||||
if isinstance(d, vconfig.LibvirtConfigGuestDisk):
|
||||
expected = cachemode.split('=')
|
||||
self.assertEqual(expected[0], d.source_type)
|
||||
self.assertEqual(expected[1], d.driver_cache)
|
||||
|
||||
def test_get_guest_config_disk_cachemodes_file(self):
|
||||
self.flags(images_type='flat', group='libvirt')
|
||||
self._test_get_guest_config_disk_cachemodes('flat')
|
||||
|
||||
def test_get_guest_config_disk_cachemodes_block(self):
|
||||
self.flags(images_type='lvm', group='libvirt')
|
||||
self.flags(images_volume_group='vols', group='libvirt')
|
||||
self._test_get_guest_config_disk_cachemodes('lvm')
|
||||
|
||||
@mock.patch.object(rbd_utils, 'rbd')
|
||||
@mock.patch.object(rbd_utils, 'rados')
|
||||
@mock.patch.object(rbd_utils.RBDDriver, 'get_mon_addrs',
|
||||
return_value=(mock.Mock(), mock.Mock()))
|
||||
def test_get_guest_config_disk_cachemodes_network(
|
||||
self, mock_get_mon_addrs, mock_rados, mock_rbd):
|
||||
self.flags(images_type='rbd', group='libvirt')
|
||||
self._test_get_guest_config_disk_cachemodes('rbd')
|
||||
|
||||
@mock.patch.object(
|
||||
host.Host, "is_cpu_control_policy_capable", return_value=True)
|
||||
def test_get_guest_config_with_bogus_cpu_quota(self, is_able):
|
||||
|
|
|
@ -3725,6 +3725,9 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
vol['connection_info'] = connection_info
|
||||
vol.save()
|
||||
|
||||
for d in devices:
|
||||
self._set_cache_mode(d)
|
||||
|
||||
if scsi_controller:
|
||||
devices.append(scsi_controller)
|
||||
|
||||
|
|
Loading…
Reference in New Issue