|
22 | 22 | import nova
|
23 | 23 | from nova.compute import vm_states
|
24 | 24 | from nova import context
|
| 25 | +from nova import exception |
25 | 26 | from nova import objects
|
26 | 27 | from nova.objects import fields
|
27 | 28 | from nova.pci import manager
|
@@ -236,6 +237,42 @@ def test_update_devices_from_hypervisor_resources(self, _mock_dev_assign):
|
236 | 237 | tracker.update_devices_from_hypervisor_resources(fake_pci_devs_json)
|
237 | 238 | self.assertEqual(2, len(tracker.pci_devs))
|
238 | 239 |
|
| 240 | + def test_update_devices_from_hypervisor_resources_32bit_domain(self): |
| 241 | + self.flags( |
| 242 | + group='pci', |
| 243 | + passthrough_whitelist=[ |
| 244 | + '{"product_id":"2032", "vendor_id":"8086"}']) |
| 245 | + # There are systems where 32 bit PCI domain is used. See bug 1897528 |
| 246 | + # for example. While nova (and qemu) does not support assigning such |
| 247 | + # devices but the existence of such device in the system should not |
| 248 | + # lead to an error. |
| 249 | + fake_pci = { |
| 250 | + 'compute_node_id': 1, |
| 251 | + 'address': '10000:00:02.0', |
| 252 | + 'product_id': '2032', |
| 253 | + 'vendor_id': '8086', |
| 254 | + 'request_id': None, |
| 255 | + 'status': fields.PciDeviceStatus.AVAILABLE, |
| 256 | + 'dev_type': fields.PciDeviceType.STANDARD, |
| 257 | + 'parent_addr': None, |
| 258 | + 'numa_node': 0} |
| 259 | + |
| 260 | + fake_pci_devs = [fake_pci] |
| 261 | + fake_pci_devs_json = jsonutils.dumps(fake_pci_devs) |
| 262 | + tracker = manager.PciDevTracker(self.fake_context) |
| 263 | + # We expect that the device with 32bit PCI domain is ignored |
| 264 | + # tracker.update_devices_from_hypervisor_resources(fake_pci_devs_json) |
| 265 | + # self.assertEqual(0, len(tracker.pci_devs)) |
| 266 | + # |
| 267 | + # This is the bug 1897528 |
| 268 | + ex = self.assertRaises( |
| 269 | + exception.PciConfigInvalidWhitelist, |
| 270 | + tracker.update_devices_from_hypervisor_resources, |
| 271 | + fake_pci_devs_json) |
| 272 | + self.assertEqual( |
| 273 | + 'Invalid PCI devices Whitelist config: property domain (10000) is ' |
| 274 | + 'greater than the maximum allowable value (FFFF).', str(ex)) |
| 275 | + |
239 | 276 | def test_set_hvdev_new_dev(self):
|
240 | 277 | fake_pci_3 = dict(fake_pci, address='0000:00:00.4', vendor_id='v2')
|
241 | 278 | fake_pci_devs = [copy.deepcopy(fake_pci), copy.deepcopy(fake_pci_1),
|
|
0 commit comments