Skip to content

Commit aaa5624

Browse files
Fix 1vcpu error with multiqueue and vif_type=tap
Fix for bug #1893263 introduced a regression where 1 vcpu instances would fail to build when paired with multiqueue-enabled images, in the scenario vif_type=tap. Solution is to not pass multiqueue parameter when instances.get_flavor().vcpus = 1. Closes-bug: #1939604 Change-Id: Iaccf2eeeb6e8bb80c658f51ce9ab4e8eb4093a55 (cherry picked from commit 7fc6fe6) (cherry picked from commit aa5b8d1)
1 parent 4ce01d6 commit aaa5624

File tree

3 files changed

+43
-13
lines changed

3 files changed

+43
-13
lines changed

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

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,10 @@ class LibvirtVifTestCase(test.NoDBTestCase):
379379
uuid='f0000000-0000-0000-0000-000000000001',
380380
project_id=723)
381381

382+
flavor_1vcpu = objects.Flavor(vcpus=1, memory=512, root_gb=1)
383+
384+
flavor_2vcpu = objects.Flavor(vcpus=2, memory=512, root_gb=1)
385+
382386
bandwidth = {
383387
'quota:vif_inbound_peak': '200',
384388
'quota:vif_outbound_peak': '20',
@@ -1063,30 +1067,50 @@ def test_tap_ethernet_vif_driver(self):
10631067
@mock.patch('nova.privsep.linux_net.device_exists', return_value=True)
10641068
@mock.patch('nova.privsep.linux_net.set_device_mtu')
10651069
@mock.patch('nova.privsep.linux_net.create_tap_dev')
1066-
def test_plug_tap_kvm_virtio(self, mock_create_tap_dev, mock_set_mtu,
1067-
mock_device_exists):
1070+
def test_plug_tap_kvm_virtio(
1071+
self, mock_create_tap_dev, mock_set_mtu, mock_device_exists):
10681072

10691073
d1 = vif.LibvirtGenericVIFDriver()
10701074
ins = objects.Instance(
10711075
id=1, uuid='f0000000-0000-0000-0000-000000000001',
1076+
flavor=self.flavor_2vcpu,
10721077
project_id=723, system_metadata={}
10731078
)
10741079
d1.plug(ins, self.vif_tap)
1075-
mock_create_tap_dev.assert_called_once_with('tap-xxx-yyy-zzz', None,
1076-
multiqueue=False)
1080+
mock_create_tap_dev.assert_called_once_with(
1081+
'tap-xxx-yyy-zzz', None, multiqueue=False)
10771082

10781083
mock_create_tap_dev.reset_mock()
10791084

10801085
d2 = vif.LibvirtGenericVIFDriver()
10811086
mq_ins = objects.Instance(
10821087
id=1, uuid='f0000000-0000-0000-0000-000000000001',
1088+
flavor=self.flavor_2vcpu,
10831089
project_id=723, system_metadata={
10841090
'image_hw_vif_multiqueue_enabled': 'True'
10851091
}
10861092
)
10871093
d2.plug(mq_ins, self.vif_tap)
1088-
mock_create_tap_dev.assert_called_once_with('tap-xxx-yyy-zzz', None,
1089-
multiqueue=True)
1094+
mock_create_tap_dev.assert_called_once_with(
1095+
'tap-xxx-yyy-zzz', None, multiqueue=True)
1096+
1097+
@mock.patch('nova.privsep.linux_net.device_exists', return_value=True)
1098+
@mock.patch('nova.privsep.linux_net.set_device_mtu')
1099+
@mock.patch('nova.privsep.linux_net.create_tap_dev')
1100+
def test_plug_tap_mq_ignored_1vcpu(
1101+
self, mock_create_tap_dev, mock_set_mtu, mock_device_exists):
1102+
1103+
d1 = vif.LibvirtGenericVIFDriver()
1104+
mq_ins = objects.Instance(
1105+
id=1, uuid='f0000000-0000-0000-0000-000000000001',
1106+
image_ref=uuids.image_ref, flavor=self.flavor_1vcpu,
1107+
project_id=723, system_metadata={
1108+
'image_hw_vif_multiqueue_enabled': 'True',
1109+
}
1110+
)
1111+
d1.plug(mq_ins, self.vif_tap)
1112+
mock_create_tap_dev.assert_called_once_with(
1113+
'tap-xxx-yyy-zzz', None, multiqueue=False)
10901114

10911115
@mock.patch('nova.privsep.linux_net.device_exists', return_value=True)
10921116
@mock.patch('nova.privsep.linux_net.set_device_mtu')
@@ -1101,14 +1125,14 @@ def test_plug_tap_mq_ignored_virt_type(
11011125
d1 = vif.LibvirtGenericVIFDriver()
11021126
ins = objects.Instance(
11031127
id=1, uuid='f0000000-0000-0000-0000-000000000001',
1128+
flavor=self.flavor_2vcpu,
11041129
project_id=723, system_metadata={
11051130
'image_hw_vif_multiqueue_enabled': 'True'
11061131
}
11071132
)
11081133
d1.plug(ins, self.vif_tap)
1109-
mock_create_tap_dev.assert_called_once_with('tap-xxx-yyy-zzz',
1110-
None,
1111-
multiqueue=False)
1134+
mock_create_tap_dev.assert_called_once_with(
1135+
'tap-xxx-yyy-zzz', None, multiqueue=False)
11121136

11131137
@mock.patch('nova.privsep.linux_net.device_exists', return_value=True)
11141138
@mock.patch('nova.privsep.linux_net.set_device_mtu')
@@ -1119,15 +1143,15 @@ def test_plug_tap_mq_ignored_vif_model(
11191143
d1 = vif.LibvirtGenericVIFDriver()
11201144
ins = objects.Instance(
11211145
id=1, uuid='f0000000-0000-0000-0000-000000000001',
1146+
flavor=self.flavor_2vcpu,
11221147
project_id=723, system_metadata={
11231148
'image_hw_vif_multiqueue_enabled': 'True',
11241149
'image_hw_vif_model': 'e1000',
11251150
}
11261151
)
11271152
d1.plug(ins, self.vif_tap)
1128-
mock_create_tap_dev.assert_called_once_with('tap-xxx-yyy-zzz',
1129-
None,
1130-
multiqueue=False)
1153+
mock_create_tap_dev.assert_called_once_with(
1154+
'tap-xxx-yyy-zzz', None, multiqueue=False)
11311155

11321156
def test_unplug_tap(self):
11331157
d = vif.LibvirtGenericVIFDriver()

nova/virt/libvirt/vif.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,8 @@ def plug_tap(self, instance, vif):
666666
vif_model = self.get_vif_model(image_meta=image_meta)
667667
# TODO(ganso): explore whether multiqueue works for other vif models
668668
# that go through this code path.
669-
multiqueue = (self._requests_multiqueue(image_meta) and
669+
multiqueue = (instance.get_flavor().vcpus > 1 and
670+
self._requests_multiqueue(image_meta) and
670671
vif_model == network_model.VIF_MODEL_VIRTIO)
671672
nova.privsep.linux_net.create_tap_dev(dev, mac, multiqueue=multiqueue)
672673
network = vif.get('network')
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
Addressed an issue that prevented instances with 1 vcpu using multiqueue
5+
feature from being created successfully when their vif_type is TAP.

0 commit comments

Comments
 (0)