From fb1ef0d7e808c537ea5af3aea94615f1f34a7b1d Mon Sep 17 00:00:00 2001 From: liangjiechao Date: Wed, 8 Mar 2023 17:07:49 +0800 Subject: [PATCH] Add patch of offload --- ...rtNIC.patch => nova-offload-20230228.patch | 125 +++++++++++++----- openstack-nova.spec | 11 +- 2 files changed, 97 insertions(+), 39 deletions(-) rename nova_smartNIC.patch => nova-offload-20230228.patch (86%) diff --git a/nova_smartNIC.patch b/nova-offload-20230228.patch similarity index 86% rename from nova_smartNIC.patch rename to nova-offload-20230228.patch index 6131e29..b9c78b7 100644 --- a/nova_smartNIC.patch +++ b/nova-offload-20230228.patch @@ -1,8 +1,50 @@ diff --git a/tools/nova/nova-20.6.1/nova/compute/manager.py b/tools/nova/nova-20.6.1/nova/compute/manager.py -index 6e5d72f..f2afe21 100644 +index 6e5d72f..f6083c2 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py -@@ -6611,6 +6611,11 @@ class ComputeManager(manager.Manager): +@@ -5612,6 +5612,18 @@ class ComputeManager(manager.Manager): + block_device_info = self._get_instance_block_device_info(context, + instance, + bdms=bdms) ++ for vif in network_info: ++ if vif['vnic_type'] != 'direct': ++ continue ++ found_dev = None ++ for pci_dev in instance.pci_devices: ++ if pci_dev.address == vif['profile']['pci_slot']: ++ found_dev = pci_dev ++ if not found_dev: ++ continue ++ for pci_req in instance.pci_requests.requests: ++ if pci_req.request_id == found_dev.request_id and not pci_req.requester_id: ++ pci_req.requester_id = vif['id'] + self.driver.destroy(context, instance, network_info, + block_device_info) + +@@ -5732,8 +5744,22 @@ class ComputeManager(manager.Manager): + self.host) + network_info = self.network_api.get_instance_nw_info( + context, instance) ++ vif_to_req = {} ++ for vif in network_info: ++ if vif['vnic_type'] != 'direct': ++ continue ++ for pci_req in instance.pci_requests.requests: ++ if pci_req.requester_id == vif['id']: ++ vif_to_req[vif['id']] = pci_req.request_id + with self.rt.instance_claim(context, instance, node, allocations, + limits): ++ for vif in network_info: ++ if vif['id'] not in vif_to_req: ++ continue ++ LOG.info(vif['id']) ++ for pci_dev in instance.pci_devices: ++ if pci_dev.request_id == vif_to_req[vif['id']]: ++ vif['profile']['pci_slot'] = pci_dev.address + self.driver.spawn(context, instance, image_meta, + injected_files=[], + admin_password=None, +@@ -6611,6 +6637,11 @@ class ComputeManager(manager.Manager): # cinder v3 api flow self.volume_api.attachment_delete(context, bdm.attachment_id) @@ -14,7 +56,7 @@ index 6e5d72f..f2afe21 100644 def _deallocate_port_for_instance(self, context, instance, port_id, raise_on_failure=False): try: -@@ -6645,6 +6650,42 @@ class ComputeManager(manager.Manager): +@@ -6645,6 +6676,42 @@ class ComputeManager(manager.Manager): {'port_id': port_id, 'error': ex}, instance=instance) @@ -57,7 +99,7 @@ index 6e5d72f..f2afe21 100644 # TODO(mriedem): There are likely race failures which can result in # NotFound and QuotaError exceptions getting traced as well. @messaging.expected_exceptions( -@@ -6680,9 +6721,50 @@ class ComputeManager(manager.Manager): +@@ -6680,9 +6747,50 @@ class ComputeManager(manager.Manager): phase=fields.NotificationPhase.START) bind_host_id = self.driver.network_binding_host_id(context, instance) @@ -93,9 +135,9 @@ index 6e5d72f..f2afe21 100644 + try: + pci_device = self._claim_pci_device_for_interface_attach( + context, instance, pci_reqs) -+ except exception.InterfaceAttachPciClaimFailed: ++ except exception.InterfaceAttachPciClaimFailed as e: + raise exception.InterfaceAttachFailed( -+ instance_uuid=instance.uuid) ++ instance_uuid=instance.uuid) from e + + instance.pci_requests.requests.extend(pci_reqs.requests) + @@ -111,7 +153,7 @@ index 6e5d72f..f2afe21 100644 if len(network_info) != 1: LOG.error('allocate_port_for_instance returned %(ports)s ' 'ports', {'ports': len(network_info)}) -@@ -6702,6 +6784,7 @@ class ComputeManager(manager.Manager): +@@ -6702,6 +6810,7 @@ class ComputeManager(manager.Manager): {'port_id': port_id, 'msg': ex}, instance=instance) self._deallocate_port_for_instance(context, instance, port_id) @@ -119,7 +161,7 @@ index 6e5d72f..f2afe21 100644 tb = traceback.format_exc() compute_utils.notify_about_instance_action( -@@ -6713,6 +6796,11 @@ class ComputeManager(manager.Manager): +@@ -6713,6 +6822,11 @@ class ComputeManager(manager.Manager): raise exception.InterfaceAttachFailed( instance_uuid=instance.uuid) @@ -131,7 +173,7 @@ index 6e5d72f..f2afe21 100644 compute_utils.notify_about_instance_action( context, instance, self.host, action=fields.NotificationAction.INTERFACE_ATTACH, -@@ -6735,6 +6823,25 @@ class ComputeManager(manager.Manager): +@@ -6735,6 +6849,25 @@ class ComputeManager(manager.Manager): raise exception.PortNotFound(_("Port %s is not " "attached") % port_id) @@ -157,7 +199,7 @@ index 6e5d72f..f2afe21 100644 compute_utils.notify_about_instance_action( context, instance, self.host, action=fields.NotificationAction.INTERFACE_DETACH, -@@ -6756,6 +6863,9 @@ class ComputeManager(manager.Manager): +@@ -6756,6 +6889,9 @@ class ComputeManager(manager.Manager): else: self._deallocate_port_for_instance( context, instance, port_id, raise_on_failure=True) @@ -170,7 +212,7 @@ index 6e5d72f..f2afe21 100644 diff --git a/tools/nova/nova-20.6.1/nova/compute/resource_tracker.py b/tools/nova/nova-20.6.1/nova/compute/resource_tracker.py index b2ba014..4106ed7 100644 --- a/nova/compute/resource_tracker.py -+++ b/nova/compute/resource_tracker.py +--- b/nova/compute/resource_tracker.py @@ -1772,6 +1772,18 @@ class ResourceTracker(object): self.pci_tracker.save(context) return result @@ -193,7 +235,7 @@ index b2ba014..4106ed7 100644 diff --git a/tools/nova/nova-20.6.1/nova/exception.py b/tools/nova/nova-20.6.1/nova/exception.py index d178034..2fd4932 100644 --- a/nova/exception.py -+++ b/nova/exception.py +--- b/nova/exception.py @@ -690,6 +690,11 @@ class VolumeBDMPathNotFound(VolumeBDMNotFound): msg_fmt = _("No volume Block Device Mapping at path: %(path)s") @@ -209,7 +251,7 @@ index d178034..2fd4932 100644 diff --git a/tools/nova/nova-20.6.1/nova/network/neutronv2/api.py b/tools/nova/nova-20.6.1/nova/network/neutronv2/api.py index 8f85a74..c8f505d 100644 --- a/nova/network/neutronv2/api.py -+++ b/nova/network/neutronv2/api.py +--- b/nova/network/neutronv2/api.py @@ -693,10 +693,15 @@ class API(base_api.NetworkAPI): # SR-IOV port attach is not supported. vnic_type = port.get('binding:vnic_type', @@ -232,7 +274,7 @@ index 8f85a74..c8f505d 100644 diff --git a/tools/nova/nova-20.6.1/nova/network/os_vif_util.py b/tools/nova/nova-20.6.1/nova/network/os_vif_util.py index 9b76ef3..cc5e03a 100644 --- a/nova/network/os_vif_util.py -+++ b/nova/network/os_vif_util.py +--- b/nova/network/os_vif_util.py @@ -285,6 +285,27 @@ def _set_representor_datapath_offload_settings(vif, obj): obj.port_profile.datapath_offload = datapath_offload @@ -277,7 +319,7 @@ index 9b76ef3..cc5e03a 100644 diff --git a/tools/nova/nova-20.6.1/nova/objects/instance.py b/tools/nova/nova-20.6.1/nova/objects/instance.py index ba0ea15..7dbce27 100644 --- a/nova/objects/instance.py -+++ b/nova/objects/instance.py +--- b/nova/objects/instance.py @@ -1207,6 +1207,14 @@ class Instance(base.NovaPersistentObject, base.NovaObject, return objects.BlockDeviceMappingList.get_by_instance_uuid( self._context, self.uuid) @@ -294,22 +336,33 @@ index ba0ea15..7dbce27 100644 def _make_instance_list(context, inst_list, db_inst_list, expected_attrs): get_fault = expected_attrs and 'fault' in expected_attrs diff --git a/tools/nova/nova-20.6.1/nova/pci/utils.py b/tools/nova/nova-20.6.1/nova/pci/utils.py -index 5b0a082..5acdc21 100644 +index 5b0a082..82ed817 100644 --- a/nova/pci/utils.py -+++ b/nova/pci/utils.py -@@ -221,6 +221,6 @@ def get_net_name_by_vf_pci_address(vfaddress): - return ("net_%(ifname)s_%(mac)s" % - {'ifname': ifname, 'mac': '_'.join(mac)}) - except Exception: -- LOG.warning("No net device was found for VF %(vfaddress)s", -- {'vfaddress': vfaddress}) -+ #LOG.warning("No net device was found for VF %(vfaddress)s", -+ # {'vfaddress': vfaddress}) - return +--- b/nova/pci/utils.py +@@ -215,12 +215,15 @@ def get_net_name_by_vf_pci_address(vfaddress): + In the libvirt parser information tree, the network device stores the + network capabilities associated to this device. + """ ++ direct_flag = False + try: + mac = get_mac_by_pci_address(vfaddress).split(':') + ifname = get_ifname_by_pci_address(vfaddress) +- return ("net_%(ifname)s_%(mac)s" % +- {'ifname': ifname, 'mac': '_'.join(mac)}) +- except Exception: ++ except Exception as e: + LOG.warning("No net device was found for VF %(vfaddress)s", + {'vfaddress': vfaddress}) +- return ++ direct_flag = True ++ if direct_flag: ++ return None ++ return ("net_%(ifname)s_%(mac)s" % ++ {'ifname': ifname, 'mac': '_'.join(mac)}) diff --git a/tools/nova/nova-20.6.1/nova/virt/libvirt/config.py b/tools/nova/nova-20.6.1/nova/virt/libvirt/config.py index 39c4da8..f2c1a1a 100644 --- a/nova/virt/libvirt/config.py -+++ b/nova/virt/libvirt/config.py +--- b/nova/virt/libvirt/config.py @@ -2020,6 +2020,9 @@ class LibvirtConfigGuestHostdevPCI(LibvirtConfigGuestHostdev): def format_dom(self): dev = super(LibvirtConfigGuestHostdevPCI, self).format_dom() @@ -323,7 +376,7 @@ index 39c4da8..f2c1a1a 100644 diff --git a/tools/nova/nova-20.6.1/nova/virt/libvirt/driver.py b/tools/nova/nova-20.6.1/nova/virt/libvirt/driver.py index f51463f..1e0f566 100644 --- a/nova/virt/libvirt/driver.py -+++ b/nova/virt/libvirt/driver.py +--- b/nova/virt/libvirt/driver.py @@ -4145,20 +4145,31 @@ class LibvirtDriver(driver.ComputeDriver): guest.detach_device(self._get_guest_pci_device(dev), live=True) # after detachDeviceFlags returned, we should check the dom to @@ -435,7 +488,7 @@ index f51463f..1e0f566 100644 diff --git a/tools/nova/nova-20.6.1/nova/virt/libvirt/guest.py b/tools/nova/nova-20.6.1/nova/virt/libvirt/guest.py index a7fbc50..d3687ae 100644 --- a/nova/virt/libvirt/guest.py -+++ b/nova/virt/libvirt/guest.py +--- b/nova/virt/libvirt/guest.py @@ -234,21 +234,30 @@ class Guest(object): """ @@ -483,9 +536,9 @@ index a7fbc50..d3687ae 100644 def get_vcpus_info(self): """Returns virtual cpus information of guest. diff --git a/tools/nova/nova-20.6.1/nova/virt/libvirt/migration.py b/tools/nova/nova-20.6.1/nova/virt/libvirt/migration.py -index 7b72147..a03765a 100644 +index 7b72147..3258c93 100644 --- a/nova/virt/libvirt/migration.py -+++ b/nova/virt/libvirt/migration.py +--- b/nova/virt/libvirt/migration.py @@ -89,6 +89,7 @@ def get_updated_guest_xml(guest, migrate_data, get_volume_config, xml_doc = _update_memory_backing_xml(xml_doc, migrate_data) if get_vif_config is not None: @@ -494,10 +547,10 @@ index 7b72147..a03765a 100644 if 'dst_numa_info' in migrate_data: xml_doc = _update_numa_xml(xml_doc, migrate_data) return etree.tostring(xml_doc, encoding='unicode') -@@ -397,6 +398,55 @@ def _update_vif_xml(xml_doc, migrate_data, get_vif_config): - +@@ -398,6 +399,57 @@ def _update_vif_xml(xml_doc, migrate_data, get_vif_config): return xml_doc + +def _update_direct_passthrough_vif_xml(xml_doc, migrate_data, get_vif_config): + instance_uuid = xml_doc.findtext('uuid') + parser = etree.XMLParser(remove_blank_text=True) @@ -547,13 +600,15 @@ index 7b72147..a03765a 100644 + for index, dest_interface_subelem in enumerate(dest_hostdev_elem): + host_dev.insert(index, dest_interface_subelem) + return xml_doc - ++ ++ def find_job_type(guest, instance, logging_ok=True): """Determine the (likely) current migration job type + diff --git a/tools/nova/nova-20.6.1/nova/virt/libvirt/vif.py b/tools/nova/nova-20.6.1/nova/virt/libvirt/vif.py index c03548d..60cac1c 100644 --- a/nova/virt/libvirt/vif.py -+++ b/nova/virt/libvirt/vif.py +--- b/nova/virt/libvirt/vif.py @@ -512,6 +512,16 @@ class LibvirtGenericVIFDriver(object): designer.set_vif_host_backend_vhostuser_config( conf, vif.mode, vif.path, rx_queue_size, tx_queue_size) diff --git a/openstack-nova.spec b/openstack-nova.spec index 78b29da..b3e78e0 100644 --- a/openstack-nova.spec +++ b/openstack-nova.spec @@ -15,7 +15,7 @@ Name: openstack-nova # Liberty semver reset # https://review.openstack.org/#/q/I6a35fa0dda798fad93b804d00a46af80f08d475c,n,z Version: 20.6.1 -Release: 7 +Release: 8 Summary: OpenStack Compute (nova) License: ASL 2.0 @@ -50,7 +50,7 @@ Source41: nova_migration-rootwrap_cold_migration Patch1: Fixes-aarch64-incorrect-cpu-model.patch Patch2: Fixes-ignore-device-already-in-the-process-of-unplug-errors.patch -Patch3: nova_smartNIC.patch +Patch3: nova-offload-20230228.patch BuildArch: noarch BuildRequires: openstack-macros @@ -733,10 +733,13 @@ exit 0 %endif %changelog -* Tue Jun 22 2022 yangjunjie - 23.0.1-7 +* Wed Mar 08 2023 liangjiechao - 20.0.1-8 +- Add offload support + +* Tue Jun 22 2022 yangjunjie - 20.0.1-7 - Add smartNIC support. -* Fri Apr 22 2022 yangjunjie - 23.0.1-6 +* Fri Apr 22 2022 yangjunjie - 20.0.1-6 - Ignore device already in the process of unplug errors. * Tue Jan 25 2022 wangxiyuan - 20.6.1-5 -- Gitee