diff options
author | Balazs Gibizer <balazs.gibizer@est.tech> | 2022-02-15 14:38:41 +0100 |
---|---|---|
committer | Balazs Gibizer <gibi@redhat.com> | 2022-05-03 18:08:50 +0200 |
commit | cd03bbc1c33e33872594cf002f0e7011ab8ea047 (patch) | |
tree | 090f794905e4fed6d7bb9b47c4b8ff7c82741a2a /nova/objects | |
parent | b8cc5704558d3c08fda9db2f1bb7fecb2bcd985d (diff) | |
download | nova-cd03bbc1c33e33872594cf002f0e7011ab8ea047.tar.gz |
Record SRIOV PF MAC in the binding profile
Today Nova updates the mac_address of a direct-physical port to reflect
the MAC address of the physical device the port is bound to. But this
can only be done before the port is bound. However during migration Nova
does not update the MAC when the port is bound to a different physical
device on the destination host.
This patch extends the libvirt virt driver to provide the MAC address of
the PF in the pci_info returned to the resource tracker. This
information will be then persisted in the extra_info field of the
PciDevice object.
Then the port update logic during migration, resize, live
migration, evacuation and unshelve is also extended to record the MAC of
physical device in the port binding profile according to the device on
the destination host.
The related neutron change Ib0638f5db69cb92daf6932890cb89e83cf84f295
uses this info from the binding profile to update the mac_address field
of the port when the binding is activated.
Closes-Bug: #1942329
Change-Id: Iad5e70b43a65c076134e1874cb8e75d1ba214fde
Diffstat (limited to 'nova/objects')
-rw-r--r-- | nova/objects/pci_device.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/nova/objects/pci_device.py b/nova/objects/pci_device.py index a1e5d9a15a..a672b0756b 100644 --- a/nova/objects/pci_device.py +++ b/nova/objects/pci_device.py @@ -148,6 +148,12 @@ class PciDevice(base.NovaPersistentObject, base.NovaObject): reason='dev_type=%s not supported in version %s' % ( dev_type, target_version)) + def __repr__(self): + return ( + f'PciDevice(address={self.address}, ' + f'compute_node_id={self.compute_node_id})' + ) + def update_device(self, dev_dict): """Sync the content from device dictionary to device object. @@ -175,6 +181,9 @@ class PciDevice(base.NovaPersistentObject, base.NovaObject): # NOTE(ralonsoh): list of parameters currently added to # "extra_info" dict: # - "capabilities": dict of (strings/list of strings) + # - "parent_ifname": the netdev name of the parent (PF) + # device of a VF + # - "mac_address": the MAC address of the PF extra_info = self.extra_info data = v if isinstance(v, str) else jsonutils.dumps(v) extra_info.update({k: data}) @@ -542,6 +551,13 @@ class PciDevice(base.NovaPersistentObject, base.NovaObject): caps = jsonutils.loads(caps_json) return caps.get('sriov', {}) + @property + def mac_address(self): + """The MAC address of the PF physical device or None if the device is + not a PF or if the MAC is not available. + """ + return self.extra_info.get('mac_address') + @base.NovaObjectRegistry.register class PciDeviceList(base.ObjectListBase, base.NovaObject): @@ -581,3 +597,6 @@ class PciDeviceList(base.ObjectListBase, base.NovaObject): parent_addr) return base.obj_make_list(context, cls(context), objects.PciDevice, db_dev_list) + + def __repr__(self): + return f"PciDeviceList(objects={[repr(obj) for obj in self.objects]})" |