From 1273c5ee0b18974d9837e9221fc9270429d428bf Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Thu, 27 Aug 2020 15:12:50 +0200 Subject: [PATCH] Make PCI claim NUMA aware during live migration NUMA aware live migration and SRIOV live migration was implemented as two separate feature. As a consequence the case when both SRIOV and NUMA is present in the instance was missed. When the PCI device is claimed on the destination host the NUMA topology of the instance needs to be passed to the claim call. Change-Id: If469762b22d687151198468f0291821cebdf26b2 Closes-Bug: #1893221 --- nova/compute/manager.py | 10 ++++++++-- nova/compute/resource_tracker.py | 4 +--- nova/tests/unit/compute/test_compute_mgr.py | 7 ++++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index ee0429899d4e..fd191b5eae4a 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -10597,9 +10597,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 a0b2f6dd05f3..0f7eff989681 100644 --- a/nova/tests/unit/compute/test_compute_mgr.py +++ b/nova/tests/unit/compute/test_compute_mgr.py @@ -10752,6 +10752,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, @@ -10766,7 +10768,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()