From f6799825f8fa7e398da47c3e703c7aa7143ded3b Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 24 Nov 2022 18:09:34 +0100 Subject: [PATCH] F #6025: Simplify DPDK Management * BRIDGE_TYPE can be updated after creating a network to set openvswitch_dpdk. This way DPDK and none DPDK datapath bridges can coexist. * When bridge_type is openvswtich_dpdk datapath_type=netdev is automatically added to the bridge. No need to change other configuration files. * Better port detection for dpdk switches --- src/vnm/VirtualNetwork.cc | 12 +++++++++++- src/vnm_mad/remotes/OpenNebulaNetwork.conf | 2 -- src/vnm_mad/remotes/lib/nic.rb | 18 ++++++++++++------ src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb | 5 +++++ 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/vnm/VirtualNetwork.cc b/src/vnm/VirtualNetwork.cc index a2a5cc9b8f..fe94a707ff 100644 --- a/src/vnm/VirtualNetwork.cc +++ b/src/vnm/VirtualNetwork.cc @@ -377,7 +377,7 @@ error_common: int VirtualNetwork::post_update_template(string& error) { - string new_bridge; + string new_bridge, new_br_type; string sg_str; /* ---------------------------------------------------------------------- */ @@ -386,6 +386,7 @@ int VirtualNetwork::post_update_template(string& error) /* - PHYDEV */ /* - VLAN_ID */ /* - BRIDGE */ + /* - BRIDGE_TYPE */ /* - SECURITY_GROUPS */ /* ---------------------------------------------------------------------- */ erase_template_attribute("VN_MAD", vn_mad); @@ -429,6 +430,15 @@ int VirtualNetwork::post_update_template(string& error) add_template_attribute("BRIDGE", bridge); + erase_template_attribute("BRIDGE_TYPE", new_br_type); + + if (str_to_bridge_type(new_br_type) != UNDEFINED) + { + bridge_type = new_br_type; + } + + add_template_attribute("BRIDGE_TYPE", bridge_type); + security_groups.clear(); obj_template->get("SECURITY_GROUPS", sg_str); diff --git a/src/vnm_mad/remotes/OpenNebulaNetwork.conf b/src/vnm_mad/remotes/OpenNebulaNetwork.conf index 9cdcf0b697..385f5b7666 100644 --- a/src/vnm_mad/remotes/OpenNebulaNetwork.conf +++ b/src/vnm_mad/remotes/OpenNebulaNetwork.conf @@ -104,8 +104,6 @@ # # :ovs_bridge_conf: # :stp_enable: true -# :datapath_type: netdev - # These options will be added to the ip link add command. For example: # diff --git a/src/vnm_mad/remotes/lib/nic.rb b/src/vnm_mad/remotes/lib/nic.rb index 5849cd1b8c..977b616764 100644 --- a/src/vnm_mad/remotes/lib/nic.rb +++ b/src/vnm_mad/remotes/lib/nic.rb @@ -79,16 +79,22 @@ module VNMMAD # devices/interface[@type='bridge']/mac[@address='']/../target" def get_tap(vm) dumpxml = vm.vm_info[:dumpxml] + bxpath = "devices/interface[@type='bridge' or @type='vhostuser']/" \ + "mac[@address='#{self[:mac]}']/../" - if dumpxml - dumpxml_root = REXML::Document.new(dumpxml).root + return self unless dumpxml - xpath = "devices/interface[@type='bridge' or @type='vhostuser']/" \ - "mac[@address='#{self[:mac]}']/../target" + dumpxml_root = REXML::Document.new(dumpxml).root - tap = dumpxml_root.elements[xpath] + tap = dumpxml_root.elements["#{bxpath}target"] - self[:tap] = tap.attributes['dev'] if tap + self[:tap] = tap.attributes['dev'] if tap + + # DPDK interfaces (post phase) only have source not target + if !self[:tap] || self[:tap].empty? + source = dumpxml_root.elements["#{bxpath}source"] + + self[:tap] = File.basename(source.attributes['path']) if source end self diff --git a/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb b/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb index b7628b6160..13171af502 100644 --- a/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb +++ b/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb @@ -538,6 +538,11 @@ class OpenvSwitchVLAN < VNMMAD::VNMDriver def create_bridge return if @bridges.keys.include? @nic[:bridge] + if @nic[:bridge_type] == 'openvswitch_dpdk' + @nic[:ovs_bridge_conf] = {} unless @nic[:ovs_bridge_conf] + @nic[:ovs_bridge_conf]['datapath_type'] = 'netdev' + end + OpenNebula.exec_and_log("#{command(:ovs_vsctl)} --may-exist add-br #{@nic[:bridge]}") set_bridge_options