Merge "Fix race with DPDK and vhostuserclient mode"
This commit is contained in:
commit
987c76d7c8
|
@ -196,12 +196,11 @@ class OvsPlugin(plugin.PluginBase):
|
||||||
return profile.datapath_type
|
return profile.datapath_type
|
||||||
|
|
||||||
def _plug_vhostuser(self, vif, instance_info):
|
def _plug_vhostuser(self, vif, instance_info):
|
||||||
self.ovsdb.ensure_ovs_bridge(
|
|
||||||
vif.network.bridge, self._get_vif_datapath_type(
|
|
||||||
vif, datapath=constants.OVS_DATAPATH_NETDEV))
|
|
||||||
vif_name = OvsPlugin.gen_port_name(
|
vif_name = OvsPlugin.gen_port_name(
|
||||||
constants.OVS_VHOSTUSER_PREFIX, vif.id)
|
constants.OVS_VHOSTUSER_PREFIX, vif.id)
|
||||||
args = {}
|
args = {}
|
||||||
|
args['datapath_type'] = self._get_vif_datapath_type(vif,
|
||||||
|
datapath=constants.OVS_DATAPATH_NETDEV)
|
||||||
if vif.mode == "client":
|
if vif.mode == "client":
|
||||||
args['interface_type'] = \
|
args['interface_type'] = \
|
||||||
constants.OVS_VHOSTUSER_INTERFACE_TYPE
|
constants.OVS_VHOSTUSER_INTERFACE_TYPE
|
||||||
|
|
|
@ -138,7 +138,7 @@ class BaseOVS(object):
|
||||||
def create_ovs_vif_port(
|
def create_ovs_vif_port(
|
||||||
self, bridge, dev, iface_id, mac, instance_id,
|
self, bridge, dev, iface_id, mac, instance_id,
|
||||||
mtu=None, interface_type=None, vhost_server_path=None,
|
mtu=None, interface_type=None, vhost_server_path=None,
|
||||||
tag=None, pf_pci=None, vf_num=None, set_ids=True
|
tag=None, pf_pci=None, vf_num=None, set_ids=True, datapath_type=None
|
||||||
):
|
):
|
||||||
"""Create OVS port
|
"""Create OVS port
|
||||||
|
|
||||||
|
@ -154,6 +154,7 @@ class BaseOVS(object):
|
||||||
:param pf_pci: PCI address of PF for dpdk representor port.
|
:param pf_pci: PCI address of PF for dpdk representor port.
|
||||||
:param vf_num: VF number of PF for dpdk representor port.
|
:param vf_num: VF number of PF for dpdk representor port.
|
||||||
:param set_ids: set external ids on port (bool).
|
:param set_ids: set external ids on port (bool).
|
||||||
|
:param datapath_type: datapath type for port's bridge
|
||||||
|
|
||||||
.. note:: create DPDK representor port by setting all three values:
|
.. note:: create DPDK representor port by setting all three values:
|
||||||
`interface_type`, `pf_pci` and `vf_num`. if interface type is
|
`interface_type`, `pf_pci` and `vf_num`. if interface type is
|
||||||
|
@ -177,6 +178,9 @@ class BaseOVS(object):
|
||||||
col_values.append(('options',
|
col_values.append(('options',
|
||||||
{'dpdk-devargs': devargs_string}))
|
{'dpdk-devargs': devargs_string}))
|
||||||
with self.ovsdb.transaction() as txn:
|
with self.ovsdb.transaction() as txn:
|
||||||
|
if datapath_type:
|
||||||
|
txn.add(self.ovsdb.add_br(bridge, may_exist=True,
|
||||||
|
datapath_type=datapath_type))
|
||||||
txn.add(self.ovsdb.add_port(bridge, dev))
|
txn.add(self.ovsdb.add_port(bridge, dev))
|
||||||
if tag:
|
if tag:
|
||||||
txn.add(self.ovsdb.db_set('Port', dev, ('tag', tag)))
|
txn.add(self.ovsdb.db_set('Port', dev, ('tag', tag)))
|
||||||
|
|
|
@ -362,47 +362,37 @@ class PluginTest(testtools.TestCase):
|
||||||
def test_unplug_ovs_bridge_windows(self):
|
def test_unplug_ovs_bridge_windows(self):
|
||||||
self._check_unplug_ovs_windows(self.vif_ovs_hybrid)
|
self._check_unplug_ovs_windows(self.vif_ovs_hybrid)
|
||||||
|
|
||||||
@mock.patch.object(ovsdb_lib.BaseOVS, 'ensure_ovs_bridge')
|
|
||||||
@mock.patch.object(ovs.OvsPlugin, '_create_vif_port')
|
@mock.patch.object(ovs.OvsPlugin, '_create_vif_port')
|
||||||
def test_plug_ovs_vhostuser(self, _create_vif_port, ensure_ovs_bridge):
|
def test_plug_ovs_vhostuser(self, _create_vif_port):
|
||||||
dp_type = ovs.OvsPlugin._get_vif_datapath_type(self.vif_vhostuser)
|
dp_type = ovs.OvsPlugin._get_vif_datapath_type(self.vif_vhostuser)
|
||||||
calls = {
|
calls = [mock.call(
|
||||||
|
self.vif_vhostuser, 'vhub679325f-ca',
|
||||||
'_create_vif_port': [mock.call(
|
self.instance,
|
||||||
self.vif_vhostuser, 'vhub679325f-ca',
|
interface_type='dpdkvhostuser',
|
||||||
self.instance,
|
datapath_type=dp_type)]
|
||||||
interface_type='dpdkvhostuser')],
|
|
||||||
'ensure_ovs_bridge': [mock.call('br0', dp_type)]
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin = ovs.OvsPlugin.load(constants.PLUGIN_NAME)
|
plugin = ovs.OvsPlugin.load(constants.PLUGIN_NAME)
|
||||||
plugin.plug(self.vif_vhostuser, self.instance)
|
plugin.plug(self.vif_vhostuser, self.instance)
|
||||||
_create_vif_port.assert_has_calls(calls['_create_vif_port'])
|
_create_vif_port.assert_has_calls(calls)
|
||||||
ensure_ovs_bridge.assert_has_calls(calls['ensure_ovs_bridge'])
|
|
||||||
|
|
||||||
@mock.patch.object(ovsdb_lib.BaseOVS, 'ensure_ovs_bridge')
|
|
||||||
@mock.patch.object(ovsdb_lib.BaseOVS, 'create_ovs_vif_port')
|
@mock.patch.object(ovsdb_lib.BaseOVS, 'create_ovs_vif_port')
|
||||||
def test_plug_ovs_vhostuser_client(self, create_ovs_vif_port,
|
def test_plug_ovs_vhostuser_client(self, create_ovs_vif_port):
|
||||||
ensure_ovs_bridge):
|
|
||||||
dp_type = ovs.OvsPlugin._get_vif_datapath_type(
|
dp_type = ovs.OvsPlugin._get_vif_datapath_type(
|
||||||
self.vif_vhostuser_client)
|
self.vif_vhostuser_client)
|
||||||
calls = {
|
calls = [
|
||||||
'create_ovs_vif_port': [
|
|
||||||
mock.call(
|
mock.call(
|
||||||
'br0', 'vhub679325f-ca',
|
'br0', 'vhub679325f-ca',
|
||||||
'e65867e0-9340-4a7f-a256-09af6eb7a3aa',
|
'e65867e0-9340-4a7f-a256-09af6eb7a3aa',
|
||||||
'ca:fe:de:ad:be:ef',
|
'ca:fe:de:ad:be:ef',
|
||||||
'f0000000-0000-0000-0000-000000000001',
|
'f0000000-0000-0000-0000-000000000001',
|
||||||
mtu=1500, interface_type='dpdkvhostuserclient',
|
mtu=1500, interface_type='dpdkvhostuserclient',
|
||||||
vhost_server_path='/var/run/openvswitch/vhub679325f-ca'
|
vhost_server_path='/var/run/openvswitch/vhub679325f-ca',
|
||||||
)],
|
datapath_type=dp_type
|
||||||
'ensure_ovs_bridge': [mock.call('br0', dp_type)]
|
)]
|
||||||
}
|
|
||||||
|
|
||||||
plugin = ovs.OvsPlugin.load(constants.PLUGIN_NAME)
|
plugin = ovs.OvsPlugin.load(constants.PLUGIN_NAME)
|
||||||
plugin.plug(self.vif_vhostuser_client, self.instance)
|
plugin.plug(self.vif_vhostuser_client, self.instance)
|
||||||
create_ovs_vif_port.assert_has_calls(calls['create_ovs_vif_port'])
|
create_ovs_vif_port.assert_has_calls(calls)
|
||||||
ensure_ovs_bridge.assert_has_calls(calls['ensure_ovs_bridge'])
|
|
||||||
|
|
||||||
@mock.patch.object(ovsdb_lib.BaseOVS, 'delete_ovs_vif_port')
|
@mock.patch.object(ovsdb_lib.BaseOVS, 'delete_ovs_vif_port')
|
||||||
def test_unplug_ovs_vhostuser(self, delete_ovs_vif_port):
|
def test_unplug_ovs_vhostuser(self, delete_ovs_vif_port):
|
||||||
|
|
Loading…
Reference in New Issue