Use disk_bus when guessing the device name for vol

Even though the disk bus could be set through hw_disk_bus property,
the libvirt driver didn't guess the proper bus and device name for the
root volume and expected it to be defined in the BDM.

With this patch, we consider the predefined disk_bus when going to guess
the volume device name and bus instead of just relying on the one
defined in the BDM.

Change-Id: Ic6434ee2b29dc20126ec3b470d7340a0f8bf62e9
Closes-Bug: 1281989
This commit is contained in:
Xavier Queralt
2014-02-19 10:08:49 +01:00
parent 7093b847f6
commit 060c0e1208
2 changed files with 5 additions and 4 deletions

View File

@@ -704,12 +704,12 @@ class LibvirtBlockInfoTest(test.TestCase):
'device_type': 'disk'}
# No root_device_name
blockinfo.get_root_info('kvm', None, root_bdm, 'virtio', 'ide')
mock_get_info.assert_called_once_with('kvm', root_bdm, {})
mock_get_info.assert_called_once_with('kvm', root_bdm, {}, 'virtio')
mock_get_info.reset_mock()
# Both device names
blockinfo.get_root_info('kvm', None, root_bdm, 'virtio', 'ide',
root_device_name='sda')
mock_get_info.assert_called_once_with('kvm', root_bdm, {})
mock_get_info.assert_called_once_with('kvm', root_bdm, {}, 'virtio')
mock_get_info.reset_mock()
# Missing device names
del root_bdm['mount_device']
@@ -718,7 +718,8 @@ class LibvirtBlockInfoTest(test.TestCase):
mock_get_info.assert_called_once_with('kvm',
{'device_name': 'sda',
'disk_bus': 'scsi',
'device_type': 'disk'}, {})
'device_type': 'disk'},
{}, 'virtio')
def test_get_boot_order_simple(self):
disk_info = {

View File

@@ -422,7 +422,7 @@ def get_root_info(virt_type, image_meta, root_bdm, disk_bus, cdrom_bus,
if not get_device_name(root_bdm) and root_device_name:
root_bdm = root_bdm.copy()
root_bdm['device_name'] = root_device_name
return get_info_from_bdm(virt_type, root_bdm, {})
return get_info_from_bdm(virt_type, root_bdm, {}, disk_bus)
def default_device_names(virt_type, context, instance, root_device_name,