Add a vnic type for PF passthrough and a new libvirt vif driver
The new vnic type is defined by Neutron in the following change: If1ab969c2002c649a3d51635ca2765c262e2d37f We define it for Nova with this patch, and add a vif driver for plugging PFs - it's really just a simple hostdev passthrough, which is already used so we just abstract the code a bit. The patch that same vif type to Neutron (it got overlooked by the original work) is here: https://review.openstack.org/262604 Change-Id: I1dc5601027ac97158d409d799b314a0c49968ce5 Related-blueprint: sriov-pf-passthrough-neutron-port
This commit is contained in:
parent
bc561be8bc
commit
32069c8f39
|
@ -37,6 +37,7 @@ VIF_TYPE_BRIDGE = 'bridge'
|
|||
VIF_TYPE_802_QBG = '802.1qbg'
|
||||
VIF_TYPE_802_QBH = '802.1qbh'
|
||||
VIF_TYPE_HW_VEB = 'hw_veb'
|
||||
VIF_TYPE_HOSTDEV = 'hostdev_physical'
|
||||
VIF_TYPE_IB_HOSTDEV = 'ib_hostdev'
|
||||
VIF_TYPE_MIDONET = 'midonet'
|
||||
VIF_TYPE_VHOSTUSER = 'vhostuser'
|
||||
|
@ -92,6 +93,7 @@ VIF_DETAILS_TAP_MAC_ADDRESS = 'mac_address'
|
|||
VNIC_TYPE_NORMAL = 'normal'
|
||||
VNIC_TYPE_DIRECT = 'direct'
|
||||
VNIC_TYPE_MACVTAP = 'macvtap'
|
||||
VNIC_TYPE_DIRECT_PHYSICAL = 'direct-physical'
|
||||
VNIC_TYPE_BAREMETAL = 'baremetal'
|
||||
|
||||
VNIC_TYPES_SRIOV = (VNIC_TYPE_DIRECT, VNIC_TYPE_MACVTAP)
|
||||
|
|
|
@ -148,10 +148,9 @@ class DesignerTestCase(test.NoDBTestCase):
|
|||
@mock.patch.object(pci_utils, 'get_pci_address_fields',
|
||||
return_value=('fake-domain', 'fake-bus',
|
||||
'fake-slot', 'fake-function'))
|
||||
def test_set_vif_host_backend_ib_hostdev_config(self,
|
||||
mock_pci_fields):
|
||||
def test_set_vif_host_backend_hostdev_pci_config(self, mock_pci_fields):
|
||||
conf = config.LibvirtConfigGuestInterface()
|
||||
designer.set_vif_host_backend_ib_hostdev_config(conf,
|
||||
designer.set_vif_host_backend_hostdev_pci_config(conf,
|
||||
'fake-pci-slot')
|
||||
self.assertEqual('fake-domain', conf.domain)
|
||||
self.assertEqual('fake-bus', conf.bus)
|
||||
|
|
|
@ -203,6 +203,17 @@ class LibvirtVifTestCase(test.NoDBTestCase):
|
|||
'pci_slot': '0000:0a:00.1',
|
||||
'physical_network': 'phynet1'})
|
||||
|
||||
vif_hostdev_physical = network_model.VIF(id='vif-xxx-yyy-zzz',
|
||||
address='ca:fe:de:ad:be:ef',
|
||||
network=network_8021,
|
||||
type=network_model.VIF_TYPE_HOSTDEV,
|
||||
vnic_type=
|
||||
network_model.VNIC_TYPE_DIRECT_PHYSICAL,
|
||||
ovs_interfaceid=None,
|
||||
profile={'pci_vendor_info': '1137:0043',
|
||||
'pci_slot': '0000:0a:00.1',
|
||||
'physical_network': 'phynet1'})
|
||||
|
||||
vif_hw_veb_macvtap = network_model.VIF(id='vif-xxx-yyy-zzz',
|
||||
address='ca:fe:de:ad:be:ef',
|
||||
network=network_8021,
|
||||
|
@ -1127,6 +1138,14 @@ class LibvirtVifTestCase(test.NoDBTestCase):
|
|||
vlan_want = self.vif_hw_veb["details"]["vlan"]
|
||||
self.assertEqual(vlan, vlan_want)
|
||||
|
||||
def test_hostdev_physical_driver(self):
|
||||
d = vif.LibvirtGenericVIFDriver()
|
||||
xml = self._get_instance_xml(d, self.vif_hostdev_physical)
|
||||
doc = etree.fromstring(xml)
|
||||
node = doc.findall('./devices/hostdev')[0]
|
||||
self.assertEqual(1, len(node))
|
||||
self._assertPciEqual(node, self.vif_hostdev_physical)
|
||||
|
||||
@mock.patch.object(pci_utils, 'get_ifname_by_pci_address',
|
||||
return_value='eth1')
|
||||
def test_hw_veb_driver_macvtap(self, mock_get_ifname):
|
||||
|
|
|
@ -133,10 +133,9 @@ def set_vif_host_backend_hw_veb(conf, net_type, devname, vlan,
|
|||
conf.target_dev = tapname
|
||||
|
||||
|
||||
def set_vif_host_backend_ib_hostdev_config(conf, pci_slot):
|
||||
"""Populate a LibvirtConfigGuestInterface instance
|
||||
with hostdev Interface.
|
||||
"""
|
||||
def set_vif_host_backend_hostdev_pci_config(conf, pci_slot):
|
||||
"""Populate a LibvirtConfigGuestHostdev instance with pci address data."""
|
||||
|
||||
conf.domain, conf.bus, conf.slot, conf.function = (
|
||||
pci_utils.get_pci_address_fields(pci_slot))
|
||||
|
||||
|
|
|
@ -139,6 +139,12 @@ class LibvirtGenericVIFDriver(object):
|
|||
|
||||
return conf
|
||||
|
||||
def get_base_hostdev_pci_config(self, vif):
|
||||
conf = vconfig.LibvirtConfigGuestHostdevPCI()
|
||||
pci_slot = vif['profile']['pci_slot']
|
||||
designer.set_vif_host_backend_hostdev_pci_config(conf, pci_slot)
|
||||
return conf
|
||||
|
||||
def _get_virtio_mq_settings(self, image_meta, flavor):
|
||||
"""A methods to set the number of virtio queues,
|
||||
if it has been requested in extra specs.
|
||||
|
@ -322,6 +328,10 @@ class LibvirtGenericVIFDriver(object):
|
|||
|
||||
return conf
|
||||
|
||||
def get_config_hostdev_physical(self, instance, vif, image_meta,
|
||||
inst_type, virt_type, host):
|
||||
return self.get_base_hostdev_pci_config(vif)
|
||||
|
||||
def get_config_macvtap(self, instance, vif, image_meta,
|
||||
inst_type, virt_type, host):
|
||||
conf = self.get_base_config(instance, vif, image_meta,
|
||||
|
@ -412,10 +422,7 @@ class LibvirtGenericVIFDriver(object):
|
|||
|
||||
def get_config_ib_hostdev(self, instance, vif, image_meta,
|
||||
inst_type, virt_type, host):
|
||||
conf = vconfig.LibvirtConfigGuestHostdevPCI()
|
||||
pci_slot = vif['profile']['pci_slot']
|
||||
designer.set_vif_host_backend_ib_hostdev_config(conf, pci_slot)
|
||||
return conf
|
||||
return self.get_base_hostdev_pci_config(vif)
|
||||
|
||||
def get_config_vrouter(self, instance, vif, image_meta,
|
||||
inst_type, virt_type, host):
|
||||
|
@ -585,6 +592,9 @@ class LibvirtGenericVIFDriver(object):
|
|||
mac_addr=vif['address'],
|
||||
vlan=vif['details'][network_model.VIF_DETAILS_VLAN])
|
||||
|
||||
def plug_hostdev_physical(self, instance, vif):
|
||||
pass
|
||||
|
||||
def plug_macvtap(self, instance, vif):
|
||||
vif_details = vif['details']
|
||||
vlan = vif_details.get(network_model.VIF_DETAILS_VLAN)
|
||||
|
@ -853,6 +863,9 @@ class LibvirtGenericVIFDriver(object):
|
|||
linux_net.set_vf_interface_vlan(vif['profile']['pci_slot'],
|
||||
mac_addr=vif['address'])
|
||||
|
||||
def unplug_hostdev_physical(self, instance, vif):
|
||||
pass
|
||||
|
||||
def unplug_macvtap(self, instance, vif):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Reference in New Issue