summaryrefslogtreecommitdiff
path: root/nova/pci
diff options
context:
space:
mode:
authorMoshe Levi <moshele@mellanox.com>2016-04-18 14:33:59 +0300
committerMoshe Levi <moshele@mellanox.com>2016-06-03 02:09:33 +0300
commitc2c3b97259258eec3c98feabde3b411b519eae6e (patch)
tree31ab18808566e0a9af8c13793a8794f6e1361572 /nova/pci
parentc9a3d86803535c43b44c498e81560f06dede9c2a (diff)
downloadnova-c2c3b97259258eec3c98feabde3b411b519eae6e.tar.gz
pci: Move PCI devices and PCI requests into migration context
When resizing guest to flavor with pci passthrogth, we need to drop the old pci devices and allocate new ones. To be able to do that we are leveraging the migration context (that used only for NUMA). Adds old and new PCI devices/ PCI requests into the MigrationContext object and uses the nova.pci.request.get_pci_requests_from_flavor() function to grab the set of requested PCI devices during a migration. Then, in the resource tracker's _update_usage_from_migration() call, we use the old and new PCI devices and PCI requests stored in the MigrationContext to properly account for changes. Closes-Bug: #1368201 Co-Authored-by: Jay Pipes <jaypipes@gmail.com> Change-Id: Ie8690f2b7235d677ebe15fabaae81b0a6bda29de
Diffstat (limited to 'nova/pci')
-rw-r--r--nova/pci/manager.py51
1 files changed, 20 insertions, 31 deletions
diff --git a/nova/pci/manager.py b/nova/pci/manager.py
index 3decb431bc..65cfc45b83 100644
--- a/nova/pci/manager.py
+++ b/nova/pci/manager.py
@@ -26,7 +26,6 @@ from nova import objects
from nova.objects import fields
from nova.pci import stats
from nova.pci import whitelist
-from nova.virt import hardware
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
@@ -200,16 +199,27 @@ class PciDevTracker(object):
self.allocations[instance['uuid']] += devs
def claim_instance(self, context, pci_requests, instance_numa_topology):
- if not self.pci_devs or not pci_requests.requests:
- return
+ devs = []
+ if self.pci_devs and pci_requests.requests:
+ instance_uuid = pci_requests.instance_uuid
+ devs = self._claim_instance(context, pci_requests,
+ instance_numa_topology)
+ if devs:
+ self.claims[instance_uuid] = devs
+ return devs
- instance_uuid = pci_requests.instance_uuid
- devs = self._claim_instance(context, pci_requests,
- instance_numa_topology)
- if devs:
- self.claims[instance_uuid] = devs
- return devs
- return None
+ def free_device(self, dev, instance):
+ """Free device from pci resource tracker
+
+ :param dev: cloned pci device object that needs to be free
+ :param instance: the instance that this pci device
+ is allocated to
+ """
+ for pci_dev in self.pci_devs:
+ # find the matching pci device in the pci resource tracker
+ # pci device. Once found one free it.
+ if dev == pci_dev and dev.instance_uuid == instance['uuid']:
+ self._free_device(pci_dev)
def _free_device(self, dev, instance=None):
freed_devs = dev.free(instance)
@@ -248,27 +258,6 @@ class PciDevTracker(object):
if sign == 1:
self.allocate_instance(instance)
- def update_pci_for_migration(self, context, instance, sign=1):
- """Update instance's pci usage information when it is migrated.
-
- The caller should hold the COMPUTE_RESOURCE_SEMAPHORE lock.
-
- :param sign: claim devices for instance when sign is 1, remove
- the claims when sign is -1
- """
- uuid = instance['uuid']
- pci_requests = objects.InstancePCIRequests.get_by_instance(
- context, instance)
- instance_numa_topology = hardware.instance_topology_from_instance(
- instance)
- if sign == 1 and uuid not in self.claims:
- devs = self._claim_instance(context, pci_requests,
- instance_numa_topology)
- if devs:
- self.claims[uuid] = devs
- if sign == -1 and uuid in self.claims:
- self._free_instance(instance)
-
def clean_usage(self, instances, migrations, orphans):
"""Remove all usages for instances not passed in the parameter.