Skip to content

Commit b8a2323

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Ignore hw_vif_type for direct, direct-physical vNIC types" into stable/rocky
2 parents 7404689 + 0142cc8 commit b8a2323

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

nova/tests/unit/virt/libvirt/test_vif.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -847,8 +847,10 @@ def test_model_with_osinfo(self, mock_set):
847847
mock_set.assert_called_once_with(mock.ANY, 'ca:fe:de:ad:be:ef',
848848
'virtio', None, None, None)
849849

850-
@mock.patch.object(vif.designer, 'set_vif_guest_frontend_config')
851-
def test_model_sriov_direct_multi_queue_not_set(self, mock_set):
850+
@mock.patch.object(vif.designer, 'set_vif_guest_frontend_config',
851+
wraps=vif.designer.set_vif_guest_frontend_config)
852+
def test_model_sriov_direct(self, mock_set):
853+
"""Direct attach vNICs shouldn't retrieve info from image_meta."""
852854
self.flags(use_virtio_for_bridges=True,
853855
virt_type='kvm',
854856
group='libvirt')
@@ -857,15 +859,16 @@ def test_model_sriov_direct_multi_queue_not_set(self, mock_set):
857859
fakelibosinfo))
858860
d = vif.LibvirtGenericVIFDriver()
859861
hostimpl = host.Host("qemu:///system")
860-
image_meta = {'properties': {'os_name': 'fedora22'}}
861-
image_meta = objects.ImageMeta.from_dict(image_meta)
862+
image_meta = objects.ImageMeta.from_dict(
863+
{'properties': {'hw_vif_model': 'virtio'}})
862864
conf = d.get_base_config(None, 'ca:fe:de:ad:be:ef', image_meta,
863865
None, 'kvm', network_model.VNIC_TYPE_DIRECT,
864866
hostimpl)
865867
mock_set.assert_called_once_with(mock.ANY, 'ca:fe:de:ad:be:ef',
866868
None, None, None, None)
867869
self.assertIsNone(conf.vhost_queues)
868870
self.assertIsNone(conf.driver_name)
871+
self.assertIsNone(conf.model)
869872

870873
def _test_model_qemu(self, *vif_objs, **kw):
871874
libvirt_version = kw.get('libvirt_version')

nova/virt/libvirt/vif.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,21 +128,25 @@ def get_base_config(self, instance, mac, image_meta,
128128
model = None
129129
driver = None
130130
vhost_queues = None
131+
rx_queue_size = None
132+
133+
# NOTE(stephenfin): Skip most things here as only apply to virtio
134+
# devices
135+
if vnic_type in network_model.VNIC_TYPES_DIRECT_PASSTHROUGH:
136+
designer.set_vif_guest_frontend_config(
137+
conf, mac, model, driver, vhost_queues, rx_queue_size)
138+
return conf
131139

132140
# If the user has specified a 'vif_model' against the
133141
# image then honour that model
134142
if image_meta:
135143
model = osinfo.HardwareProperties(image_meta).network_model
136144

137-
# Note(moshele): Skip passthough vnic_types as they don't support
138-
# virtio model.
139-
if vnic_type not in network_model.VNIC_TYPES_DIRECT_PASSTHROUGH:
140-
# Else if the virt type is KVM/QEMU/VZ(Parallels), then use virtio
141-
# according to the global config parameter
142-
if (model is None and
143-
virt_type in ('kvm', 'qemu', 'parallels') and
144-
CONF.libvirt.use_virtio_for_bridges):
145-
model = network_model.VIF_MODEL_VIRTIO
145+
# If the virt type is KVM/QEMU/VZ(Parallels), then use virtio according
146+
# to the global config parameter
147+
if (model is None and virt_type in ('kvm', 'qemu', 'parallels') and
148+
CONF.libvirt.use_virtio_for_bridges):
149+
model = network_model.VIF_MODEL_VIRTIO
146150

147151
# Workaround libvirt bug, where it mistakenly
148152
# enables vhost mode, even for non-KVM guests
@@ -167,7 +171,6 @@ def get_base_config(self, instance, mac, image_meta,
167171
# use vhost and not None.
168172
driver = vhost_drv or driver
169173

170-
rx_queue_size = None
171174
# Note(moshele): rx_queue_size is support only for virtio model
172175
if model == network_model.VIF_MODEL_VIRTIO:
173176
if driver == 'vhost' or driver is None:

0 commit comments

Comments
 (0)