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
This commit is contained in:
Rodrigo Barbieri 2021-08-11 16:03:58 -03:00
parent 370830e944
commit 7fc6fe6fae
3 changed files with 43 additions and 17 deletions

View File

@ -380,6 +380,10 @@ class LibvirtVifTestCase(test.NoDBTestCase):
uuid='f0000000-0000-0000-0000-000000000001',
project_id=723)
flavor_1vcpu = objects.Flavor(vcpus=1, memory=512, root_gb=1)
flavor_2vcpu = objects.Flavor(vcpus=2, memory=512, root_gb=1)
bandwidth = {
'quota:vif_inbound_peak': '200',
'quota:vif_outbound_peak': '20',
@ -1048,32 +1052,50 @@ class LibvirtVifTestCase(test.NoDBTestCase):
@mock.patch('nova.privsep.linux_net.device_exists', return_value=True)
@mock.patch('nova.privsep.linux_net.set_device_mtu')
@mock.patch('nova.privsep.linux_net.create_tap_dev')
def test_plug_tap_kvm_virtio(self, mock_create_tap_dev, mock_set_mtu,
mock_device_exists):
def test_plug_tap_kvm_virtio(
self, mock_create_tap_dev, mock_set_mtu, mock_device_exists):
d1 = vif.LibvirtGenericVIFDriver()
ins = objects.Instance(
id=1, uuid='f0000000-0000-0000-0000-000000000001',
image_ref=uuids.image_ref,
image_ref=uuids.image_ref, flavor=self.flavor_2vcpu,
project_id=723, system_metadata={}
)
d1.plug(ins, self.vif_tap)
mock_create_tap_dev.assert_called_once_with('tap-xxx-yyy-zzz', None,
multiqueue=False)
mock_create_tap_dev.assert_called_once_with(
'tap-xxx-yyy-zzz', None, multiqueue=False)
mock_create_tap_dev.reset_mock()
d2 = vif.LibvirtGenericVIFDriver()
mq_ins = objects.Instance(
id=1, uuid='f0000000-0000-0000-0000-000000000001',
image_ref=uuids.image_ref,
image_ref=uuids.image_ref, flavor=self.flavor_2vcpu,
project_id=723, system_metadata={
'image_hw_vif_multiqueue_enabled': 'True'
}
)
d2.plug(mq_ins, self.vif_tap)
mock_create_tap_dev.assert_called_once_with('tap-xxx-yyy-zzz', None,
multiqueue=True)
mock_create_tap_dev.assert_called_once_with(
'tap-xxx-yyy-zzz', None, multiqueue=True)
@mock.patch('nova.privsep.linux_net.device_exists', return_value=True)
@mock.patch('nova.privsep.linux_net.set_device_mtu')
@mock.patch('nova.privsep.linux_net.create_tap_dev')
def test_plug_tap_mq_ignored_1vcpu(
self, mock_create_tap_dev, mock_set_mtu, mock_device_exists):
d1 = vif.LibvirtGenericVIFDriver()
mq_ins = objects.Instance(
id=1, uuid='f0000000-0000-0000-0000-000000000001',
image_ref=uuids.image_ref, flavor=self.flavor_1vcpu,
project_id=723, system_metadata={
'image_hw_vif_multiqueue_enabled': 'True',
}
)
d1.plug(mq_ins, self.vif_tap)
mock_create_tap_dev.assert_called_once_with(
'tap-xxx-yyy-zzz', None, multiqueue=False)
@mock.patch('nova.privsep.linux_net.device_exists', return_value=True)
@mock.patch('nova.privsep.linux_net.set_device_mtu')
@ -1088,15 +1110,14 @@ class LibvirtVifTestCase(test.NoDBTestCase):
d1 = vif.LibvirtGenericVIFDriver()
ins = objects.Instance(
id=1, uuid='f0000000-0000-0000-0000-000000000001',
image_ref=uuids.image_ref,
image_ref=uuids.image_ref, flavor=self.flavor_2vcpu,
project_id=723, system_metadata={
'image_hw_vif_multiqueue_enabled': 'True'
}
)
d1.plug(ins, self.vif_tap)
mock_create_tap_dev.assert_called_once_with('tap-xxx-yyy-zzz',
None,
multiqueue=False)
mock_create_tap_dev.assert_called_once_with(
'tap-xxx-yyy-zzz', None, multiqueue=False)
@mock.patch('nova.privsep.linux_net.device_exists', return_value=True)
@mock.patch('nova.privsep.linux_net.set_device_mtu')
@ -1107,16 +1128,15 @@ class LibvirtVifTestCase(test.NoDBTestCase):
d1 = vif.LibvirtGenericVIFDriver()
ins = objects.Instance(
id=1, uuid='f0000000-0000-0000-0000-000000000001',
image_ref=uuids.image_ref,
image_ref=uuids.image_ref, flavor=self.flavor_2vcpu,
project_id=723, system_metadata={
'image_hw_vif_multiqueue_enabled': 'True',
'image_hw_vif_model': 'e1000',
}
)
d1.plug(ins, self.vif_tap)
mock_create_tap_dev.assert_called_once_with('tap-xxx-yyy-zzz',
None,
multiqueue=False)
mock_create_tap_dev.assert_called_once_with(
'tap-xxx-yyy-zzz', None, multiqueue=False)
def test_unplug_tap(self):
d = vif.LibvirtGenericVIFDriver()

View File

@ -691,7 +691,8 @@ class LibvirtGenericVIFDriver(object):
vif_model = self.get_vif_model(image_meta=image_meta)
# TODO(ganso): explore whether multiqueue works for other vif models
# that go through this code path.
multiqueue = (self._requests_multiqueue(image_meta) and
multiqueue = (instance.get_flavor().vcpus > 1 and
self._requests_multiqueue(image_meta) and
vif_model == network_model.VIF_MODEL_VIRTIO)
nova.privsep.linux_net.create_tap_dev(dev, mac, multiqueue=multiqueue)
network = vif.get('network')

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Addressed an issue that prevented instances with 1 vcpu using multiqueue
feature from being created successfully when their vif_type is TAP.