Skip to content

Commit 950e044

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Ignore hw_vif_type for direct, direct-physical vNIC types" into stable/stein
2 parents 7068d9b + d78310e commit 950e044

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
@@ -866,8 +866,10 @@ def test_model_with_osinfo(self, mock_set):
866866
mock_set.assert_called_once_with(mock.ANY, 'ca:fe:de:ad:be:ef',
867867
'virtio', None, None, None)
868868

869-
@mock.patch.object(vif.designer, 'set_vif_guest_frontend_config')
870-
def test_model_sriov_direct_multi_queue_not_set(self, mock_set):
869+
@mock.patch.object(vif.designer, 'set_vif_guest_frontend_config',
870+
wraps=vif.designer.set_vif_guest_frontend_config)
871+
def test_model_sriov_direct(self, mock_set):
872+
"""Direct attach vNICs shouldn't retrieve info from image_meta."""
871873
self.flags(use_virtio_for_bridges=True,
872874
virt_type='kvm',
873875
group='libvirt')
@@ -876,15 +878,16 @@ def test_model_sriov_direct_multi_queue_not_set(self, mock_set):
876878
fakelibosinfo))
877879
d = vif.LibvirtGenericVIFDriver()
878880
hostimpl = host.Host("qemu:///system")
879-
image_meta = {'properties': {'os_name': 'fedora22'}}
880-
image_meta = objects.ImageMeta.from_dict(image_meta)
881+
image_meta = objects.ImageMeta.from_dict(
882+
{'properties': {'hw_vif_model': 'virtio'}})
881883
conf = d.get_base_config(None, 'ca:fe:de:ad:be:ef', image_meta,
882884
None, 'kvm', network_model.VNIC_TYPE_DIRECT,
883885
hostimpl)
884886
mock_set.assert_called_once_with(mock.ANY, 'ca:fe:de:ad:be:ef',
885887
None, None, None, None)
886888
self.assertIsNone(conf.vhost_queues)
887889
self.assertIsNone(conf.driver_name)
890+
self.assertIsNone(conf.model)
888891

889892
def _test_model_qemu(self, *vif_objs, **kw):
890893
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
@@ -145,21 +145,25 @@ def get_base_config(self, instance, mac, image_meta,
145145
model = None
146146
driver = None
147147
vhost_queues = None
148+
rx_queue_size = None
149+
150+
# NOTE(stephenfin): Skip most things here as only apply to virtio
151+
# devices
152+
if vnic_type in network_model.VNIC_TYPES_DIRECT_PASSTHROUGH:
153+
designer.set_vif_guest_frontend_config(
154+
conf, mac, model, driver, vhost_queues, rx_queue_size)
155+
return conf
148156

149157
# If the user has specified a 'vif_model' against the
150158
# image then honour that model
151159
if image_meta:
152160
model = osinfo.HardwareProperties(image_meta).network_model
153161

154-
# Note(moshele): Skip passthough vnic_types as they don't support
155-
# virtio model.
156-
if vnic_type not in network_model.VNIC_TYPES_DIRECT_PASSTHROUGH:
157-
# Else if the virt type is KVM/QEMU/VZ(Parallels), then use virtio
158-
# according to the global config parameter
159-
if (model is None and
160-
virt_type in ('kvm', 'qemu', 'parallels') and
161-
CONF.libvirt.use_virtio_for_bridges):
162-
model = network_model.VIF_MODEL_VIRTIO
162+
# If the virt type is KVM/QEMU/VZ(Parallels), then use virtio according
163+
# to the global config parameter
164+
if (model is None and virt_type in ('kvm', 'qemu', 'parallels') and
165+
CONF.libvirt.use_virtio_for_bridges):
166+
model = network_model.VIF_MODEL_VIRTIO
163167

164168
# Workaround libvirt bug, where it mistakenly
165169
# enables vhost mode, even for non-KVM guests
@@ -184,7 +188,6 @@ def get_base_config(self, instance, mac, image_meta,
184188
# use vhost and not None.
185189
driver = vhost_drv or driver
186190

187-
rx_queue_size = None
188191
# Note(moshele): rx_queue_size is support only for virtio model
189192
if model == network_model.VIF_MODEL_VIRTIO:
190193
if driver == 'vhost' or driver is None:

0 commit comments

Comments
 (0)