diff --git a/nova/compute/manager.py b/nova/compute/manager.py index c68fa5c417bd..6ed32e4e5955 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -10541,9 +10541,15 @@ class ComputeManager(manager.Manager): requests=pci_reqs, instance_uuid=instance.uuid) + # if we are called during the live migration with NUMA topology + # support the PCI claim needs to consider the destination NUMA + # topology that is then stored in the migration_context + dest_topo = None + if instance.migration_context: + dest_topo = instance.migration_context.new_numa_topology + claimed_pci_devices_objs = self.rt.claim_pci_devices( - ctxt, - vif_pci_requests) + ctxt, vif_pci_requests, dest_topo) # Update VIFMigrateData profile with the newly claimed PCI # device diff --git a/nova/compute/resource_tracker.py b/nova/compute/resource_tracker.py index 359fab2a48d9..f64f8c948082 100644 --- a/nova/compute/resource_tracker.py +++ b/nova/compute/resource_tracker.py @@ -1873,9 +1873,7 @@ class ResourceTracker(object): self.stats[nodename].build_succeeded() @utils.synchronized(COMPUTE_RESOURCE_SEMAPHORE, fair=True) - def claim_pci_devices( - self, context, pci_requests, instance_numa_topology=None - ): + def claim_pci_devices(self, context, pci_requests, instance_numa_topology): """Claim instance PCI resources :param context: security context diff --git a/nova/tests/unit/compute/test_compute_mgr.py b/nova/tests/unit/compute/test_compute_mgr.py index 3651489ae669..3adb590375cd 100644 --- a/nova/tests/unit/compute/test_compute_mgr.py +++ b/nova/tests/unit/compute/test_compute_mgr.py @@ -10711,6 +10711,8 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase, get_pci_req_side_effect self.instance.pci_devices = instance_pci_devs self.instance.pci_requests = instance_pci_reqs + self.instance.migration_context = objects.MigrationContext( + new_numa_topology=objects.InstanceNUMATopology()) rt_mock.reset() claimed_pci_dev = objects.PciDevice(request_id=uuids.pci_req, @@ -10725,7 +10727,10 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase, self.instance) self.assertEqual(len(nw_vifs), mock_get_instance_pci_request_from_vif.call_count) - self.assertTrue(rt_mock.claim_pci_devices.called) + + rt_mock.claim_pci_devices.assert_called_once_with( + self.context, test.MatchType(objects.InstancePCIRequests), + self.instance.migration_context.new_numa_topology) self.assertEqual(len(port_id_to_pci), 1) _test()