The nova.pci.manager Module

class PciDevTracker(context, node_id=None)

Bases: object

Manage pci devices in a compute node.

This class fetches pci passthrough information from hypervisor and tracks the usage of these devices.

It’s called by compute node resource tracker to allocate and free devices to/from instances, and to update the available pci passthrough devices information from hypervisor periodically. The devices information is updated to DB when devices information is changed.

all_devs
allocate_instance(instance)
claim_instance(context, pci_requests, instance_numa_topology)
clean_usage(instances, migrations, orphans)

Remove all usages for instances not passed in the parameter.

The caller should hold the COMPUTE_RESOURCE_SEMAPHORE lock

free_instance(context, instance)
pci_stats
save(context)
update_devices_from_hypervisor_resources(devices_json)

Sync the pci device tracker with hypervisor information.

To support pci device hot plug, we sync with the hypervisor periodically, fetching all devices information from hypervisor, update the tracker and sync the DB information.

Devices should not be hot-plugged when assigned to a guest, but possibly the hypervisor has no such guarantee. The best we can do is to give a warning if a device is changed or removed while assigned.

Parameters:devices_json – The JSON-ified string of device information that is returned from the virt driver’s get_available_resource() call in the pci_passthrough_devices key.
update_pci_for_instance(context, instance, sign)

Update PCI usage information if devices are de/allocated.

update_pci_for_migration(context, instance, sign=1)

Update instance’s pci usage information when it is migrated.

The caller should hold the COMPUTE_RESOURCE_SEMAPHORE lock.

Parameters:sign – claim devices for instance when sign is 1, remove the claims when sign is -1
get_instance_pci_devs(inst, request_id=None)

Get the devices allocated to one or all requests for an instance.

  • For generic PCI request, the request id is None.
  • For sr-iov networking, the request id is a valid uuid
  • There are a couple of cases where all the PCI devices allocated to an instance need to be returned. Refer to libvirt driver that handles soft_reboot and hard_boot of ‘xen’ instances.

Previous topic

The nova.pci.devspec Module

Next topic

The nova.pci.request Module

Project Source

This Page