summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-08-31 21:15:47 +0000
committerGerrit Code Review <review@openstack.org>2021-08-31 21:15:47 +0000
commit14277ac022741cb685544f15a96bd31a31a6ad3c (patch)
tree17822ddadb421f6e9c93aec4fe7687ffe3e4b2c2
parent1eceeebfb25ccdacdb8c74c5171f0fa9e591ce82 (diff)
parentaaa56240b0311ad47ccccc3b7850ddc5b0a21702 (diff)
downloadnova-14277ac022741cb685544f15a96bd31a31a6ad3c.tar.gz
Merge "Fix 1vcpu error with multiqueue and vif_type=tap" into stable/victoria
-rw-r--r--nova/tests/unit/virt/libvirt/test_vif.py48
-rw-r--r--nova/virt/libvirt/vif.py3
-rw-r--r--releasenotes/notes/bug-1939604-547c729b7741831b.yaml5
3 files changed, 43 insertions, 13 deletions
diff --git a/nova/tests/unit/virt/libvirt/test_vif.py b/nova/tests/unit/virt/libvirt/test_vif.py
index b77d704bab..24df5d5aa7 100644
--- a/nova/tests/unit/virt/libvirt/test_vif.py
+++ b/nova/tests/unit/virt/libvirt/test_vif.py
@@ -379,6 +379,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',
@@ -1063,30 +1067,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',
+ 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',
+ 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')
@@ -1101,14 +1125,14 @@ class LibvirtVifTestCase(test.NoDBTestCase):
d1 = vif.LibvirtGenericVIFDriver()
ins = objects.Instance(
id=1, uuid='f0000000-0000-0000-0000-000000000001',
+ 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')
@@ -1119,15 +1143,15 @@ class LibvirtVifTestCase(test.NoDBTestCase):
d1 = vif.LibvirtGenericVIFDriver()
ins = objects.Instance(
id=1, uuid='f0000000-0000-0000-0000-000000000001',
+ 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()
diff --git a/nova/virt/libvirt/vif.py b/nova/virt/libvirt/vif.py
index 5c87223baf..67e0771ad9 100644
--- a/nova/virt/libvirt/vif.py
+++ b/nova/virt/libvirt/vif.py
@@ -666,7 +666,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')
diff --git a/releasenotes/notes/bug-1939604-547c729b7741831b.yaml b/releasenotes/notes/bug-1939604-547c729b7741831b.yaml
new file mode 100644
index 0000000000..e14327c285
--- /dev/null
+++ b/releasenotes/notes/bug-1939604-547c729b7741831b.yaml
@@ -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.