Merge "Ignore hw_vif_type for direct, direct-physical vNIC types" into stable/rocky

This commit is contained in:
Zuul 2019-07-08 17:35:57 +00:00 committed by Gerrit Code Review
commit b8a2323c64
2 changed files with 20 additions and 14 deletions

View File

@ -847,8 +847,10 @@ class LibvirtVifTestCase(test.NoDBTestCase):
mock_set.assert_called_once_with(mock.ANY, 'ca:fe:de:ad:be:ef',
'virtio', None, None, None)
@mock.patch.object(vif.designer, 'set_vif_guest_frontend_config')
def test_model_sriov_direct_multi_queue_not_set(self, mock_set):
@mock.patch.object(vif.designer, 'set_vif_guest_frontend_config',
wraps=vif.designer.set_vif_guest_frontend_config)
def test_model_sriov_direct(self, mock_set):
"""Direct attach vNICs shouldn't retrieve info from image_meta."""
self.flags(use_virtio_for_bridges=True,
virt_type='kvm',
group='libvirt')
@ -857,8 +859,8 @@ class LibvirtVifTestCase(test.NoDBTestCase):
fakelibosinfo))
d = vif.LibvirtGenericVIFDriver()
hostimpl = host.Host("qemu:///system")
image_meta = {'properties': {'os_name': 'fedora22'}}
image_meta = objects.ImageMeta.from_dict(image_meta)
image_meta = objects.ImageMeta.from_dict(
{'properties': {'hw_vif_model': 'virtio'}})
conf = d.get_base_config(None, 'ca:fe:de:ad:be:ef', image_meta,
None, 'kvm', network_model.VNIC_TYPE_DIRECT,
hostimpl)
@ -866,6 +868,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
None, None, None, None)
self.assertIsNone(conf.vhost_queues)
self.assertIsNone(conf.driver_name)
self.assertIsNone(conf.model)
def _test_model_qemu(self, *vif_objs, **kw):
libvirt_version = kw.get('libvirt_version')

View File

@ -128,21 +128,25 @@ class LibvirtGenericVIFDriver(object):
model = None
driver = None
vhost_queues = None
rx_queue_size = None
# NOTE(stephenfin): Skip most things here as only apply to virtio
# devices
if vnic_type in network_model.VNIC_TYPES_DIRECT_PASSTHROUGH:
designer.set_vif_guest_frontend_config(
conf, mac, model, driver, vhost_queues, rx_queue_size)
return conf
# If the user has specified a 'vif_model' against the
# image then honour that model
if image_meta:
model = osinfo.HardwareProperties(image_meta).network_model
# Note(moshele): Skip passthough vnic_types as they don't support
# virtio model.
if vnic_type not in network_model.VNIC_TYPES_DIRECT_PASSTHROUGH:
# Else if the virt type is KVM/QEMU/VZ(Parallels), then use virtio
# according to the global config parameter
if (model is None and
virt_type in ('kvm', 'qemu', 'parallels') and
CONF.libvirt.use_virtio_for_bridges):
model = network_model.VIF_MODEL_VIRTIO
# If the virt type is KVM/QEMU/VZ(Parallels), then use virtio according
# to the global config parameter
if (model is None and virt_type in ('kvm', 'qemu', 'parallels') and
CONF.libvirt.use_virtio_for_bridges):
model = network_model.VIF_MODEL_VIRTIO
# Workaround libvirt bug, where it mistakenly
# enables vhost mode, even for non-KVM guests
@ -167,7 +171,6 @@ class LibvirtGenericVIFDriver(object):
# use vhost and not None.
driver = vhost_drv or driver
rx_queue_size = None
# Note(moshele): rx_queue_size is support only for virtio model
if model == network_model.VIF_MODEL_VIRTIO:
if driver == 'vhost' or driver is None: