libvirt: Fix unit test error block info on non x86 architecture

The Q35 machine type does not provide an IDE bus. As a result, when
trying to provide a default bus for 'cdrom' type devices, we check the
machine type and select either 'ide' or 'sata' depending on whether
we're using the Q35 machine type. However, this only applies for x86 as
other architectures use different machine types.

The 'test_get_disk_bus_for_device_type_cdrom_with_q35_image_meta' test
is intended to ensure that the retrieved bus type for a 'cdrom' type
device is actually 'sata' when the machine type is 'q35'. However,
this test can still fail on non-x86 platforms. Correct this by using
the 'hw_architecture' image metadata property to ensure consistent
behavior on all platforms.

Change-Id: If9e173c8df2a7ab47dc5fca90e1d333c0f34197b
Signed-off-by: Kevin Zhao <kevin.zhao@linaro.org>
Closes-Bug: #1868121
This commit is contained in:
Kevin Zhao 2020-03-19 23:30:41 +08:00 committed by Stephen Finucane
parent 6b38a47425
commit d10ed8e75b
1 changed files with 3 additions and 1 deletions

View File

@ -831,7 +831,9 @@ class LibvirtBlockInfoTest(test.NoDBTestCase):
def test_get_disk_bus_for_device_type_cdrom_with_q35_image_meta(self):
instance = objects.Instance(**self.test_instance)
image_meta = {'properties': {'hw_machine_type': 'pc-q35-rhel8.0.0'}}
image_meta = {'properties': {
'hw_machine_type': 'pc-q35-rhel8.0.0',
'hw_architecture': obj_fields.Architecture.X86_64}}
image_meta = objects.ImageMeta.from_dict(image_meta)
bus = blockinfo.get_disk_bus_for_device_type(instance, 'kvm',
image_meta,