Fix root_device_name for Xen
When running the Tempest scenario test_volume_boot_pattern.\ TestVolumeBootPattern.test_volume_boot_pattern with a libvirt+Xen environment, the tests fails because the root_device_name is set to 'vda' which is invalid for Xen. When getting the BDM for the root block device, check that the root_device_name is compatible with the used disk bus and if it is not, adjust the root_device_name. Change-Id: I4c231b5ef646a067be1566653b6ee89ccbee60f3 Closes-Bug: #1443898
This commit is contained in:
parent
d49f901b43
commit
12485c74fa
|
@ -990,6 +990,16 @@ class LibvirtBlockInfoTest(test.NoDBTestCase):
|
|||
'disk_bus': 'scsi',
|
||||
'device_type': 'disk'},
|
||||
{}, 'virtio')
|
||||
mock_get_info.reset_mock()
|
||||
# xen with incompatible root_device_name/disk_bus combination
|
||||
root_bdm['disk_bus'] = 'xen'
|
||||
blockinfo.get_root_info(instance, 'xen', image_meta, root_bdm,
|
||||
'xen', 'ide', root_device_name='sda')
|
||||
mock_get_info.assert_called_once_with(instance, 'xen', image_meta,
|
||||
{'device_name': 'xvda',
|
||||
'disk_bus': 'xen',
|
||||
'device_type': 'disk'},
|
||||
{}, 'xen')
|
||||
|
||||
def test_get_boot_order_simple(self):
|
||||
disk_info = {
|
||||
|
|
|
@ -457,6 +457,13 @@ def get_root_info(instance, virt_type, image_meta, root_bdm,
|
|||
|
||||
if not get_device_name(root_bdm) and root_device_name:
|
||||
root_bdm = root_bdm.copy()
|
||||
# it can happen, eg for libvirt+Xen, that the root_device_name is
|
||||
# incompatible with the disk bus. In that case fix the root_device_name
|
||||
if virt_type == 'xen':
|
||||
dev_prefix = get_dev_prefix_for_disk_bus(disk_bus)
|
||||
if not root_device_name.startswith(dev_prefix):
|
||||
letter = block_device.get_device_letter(root_device_name)
|
||||
root_device_name = '%s%s' % (dev_prefix, letter)
|
||||
root_bdm['device_name'] = root_device_name
|
||||
return get_info_from_bdm(instance, virt_type, image_meta,
|
||||
root_bdm, {}, disk_bus)
|
||||
|
|
Loading…
Reference in New Issue