From 638efe3cd5a2af9aeef5bd26e9b55bde354b9767 Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Mon, 9 Sep 2024 11:04:32 +0200 Subject: [PATCH] [ovo]Add igb value to hw_vif_model image property Qemu 8.0 and libvirt 9.3.0 added support for qemu emulated igb network device. This patch adds the new igb value for hw_vif_model so nova could eventually support booting VMs with such devices. Subsequent patches will enable libvirt support. Implements: blueprint igb-vif-model Change-Id: I9c8dc1a663d0534d62798c5b4c8d4539551f7ae4 --- .../common_payloads/ImageMetaPropsPayload.json | 2 +- nova/network/model.py | 2 ++ nova/notifications/objects/image.py | 3 ++- nova/objects/image_meta.py | 8 +++++++- .../notification_sample_tests/test_instance.py | 4 ++-- .../notifications/objects/test_notification.py | 2 +- nova/tests/unit/objects/test_image_meta.py | 17 +++++++++++++++++ nova/tests/unit/objects/test_objects.py | 2 +- 8 files changed, 33 insertions(+), 7 deletions(-) diff --git a/doc/notification_samples/common_payloads/ImageMetaPropsPayload.json b/doc/notification_samples/common_payloads/ImageMetaPropsPayload.json index eb100b7c97..cc055229ab 100644 --- a/doc/notification_samples/common_payloads/ImageMetaPropsPayload.json +++ b/doc/notification_samples/common_payloads/ImageMetaPropsPayload.json @@ -4,5 +4,5 @@ "hw_architecture": "x86_64" }, "nova_object.name": "ImageMetaPropsPayload", - "nova_object.version": "1.14" + "nova_object.version": "1.15" } diff --git a/nova/network/model.py b/nova/network/model.py index 1260349bcd..c59161daaf 100644 --- a/nova/network/model.py +++ b/nova/network/model.py @@ -148,6 +148,7 @@ VIF_MODEL_E1000E = 'e1000e' VIF_MODEL_NETFRONT = 'netfront' VIF_MODEL_SPAPR_VLAN = 'spapr-vlan' VIF_MODEL_LAN9118 = 'lan9118' +VIF_MODEL_IGB = 'igb' VIF_MODEL_SRIOV = 'sriov' VIF_MODEL_VMXNET = 'vmxnet' @@ -166,6 +167,7 @@ VIF_MODEL_ALL = ( VIF_MODEL_SRIOV, VIF_MODEL_VMXNET, VIF_MODEL_VMXNET3, + VIF_MODEL_IGB, ) # these types have been leaked to guests in network_data.json diff --git a/nova/notifications/objects/image.py b/nova/notifications/objects/image.py index f714632cd6..513c257b47 100644 --- a/nova/notifications/objects/image.py +++ b/nova/notifications/objects/image.py @@ -132,7 +132,8 @@ class ImageMetaPropsPayload(base.NotificationPayloadBase): # Version 1.12: Added 'hw_viommu_model' field # Version 1.13: Added 'hw_virtio_packed_ring' field # Version 1.14: Added 'hw_firmware_stateless' field - VERSION = '1.14' + # Version 1.15: Added igb value to 'hw_vif_model' enum + VERSION = '1.15' # NOTE(efried): This logic currently relies on all of the fields of # ImageMetaProps being initialized with no arguments. See the docstring. diff --git a/nova/objects/image_meta.py b/nova/objects/image_meta.py index f27cb94a5d..2029b274fd 100644 --- a/nova/objects/image_meta.py +++ b/nova/objects/image_meta.py @@ -16,6 +16,7 @@ import copy from oslo_utils import versionutils +from nova.network import model as network_model from nova import objects from nova.objects import base from nova.objects import fields @@ -196,14 +197,19 @@ class ImageMetaProps(base.NovaObject): # 'hw_maxphysaddr_bits' field # Version 1.37: Added 'hw_ephemeral_encryption_secret_uuid' field # Version 1.38: Added 'hw_firmware_stateless' field + # Version 1.39: Added igb value to 'hw_vif_model' enum # NOTE(efried): When bumping this version, the version of # ImageMetaPropsPayload must also be bumped. See its docstring for details. - VERSION = '1.38' + VERSION = '1.39' def obj_make_compatible(self, primitive, target_version): super(ImageMetaProps, self).obj_make_compatible(primitive, target_version) target_version = versionutils.convert_version_to_tuple(target_version) + if target_version < (1, 39): + base.raise_on_too_new_values( + target_version, primitive, + 'hw_vif_model', (network_model.VIF_MODEL_IGB,)) if target_version < (1, 38): primitive.pop('hw_firmware_stateless', None) if target_version < (1, 37): diff --git a/nova/tests/functional/notification_sample_tests/test_instance.py b/nova/tests/functional/notification_sample_tests/test_instance.py index a3ba04e470..bf04c2b4b1 100644 --- a/nova/tests/functional/notification_sample_tests/test_instance.py +++ b/nova/tests/functional/notification_sample_tests/test_instance.py @@ -1238,7 +1238,7 @@ class TestInstanceNotificationSample( 'nova_object.data': {}, 'nova_object.name': 'ImageMetaPropsPayload', 'nova_object.namespace': 'nova', - 'nova_object.version': '1.14', + 'nova_object.version': '1.15', }, 'image.size': 58145823, 'image.tags': [], @@ -1334,7 +1334,7 @@ class TestInstanceNotificationSample( 'nova_object.data': {}, 'nova_object.name': 'ImageMetaPropsPayload', 'nova_object.namespace': 'nova', - 'nova_object.version': '1.14', + 'nova_object.version': '1.15', }, 'image.size': 58145823, 'image.tags': [], diff --git a/nova/tests/unit/notifications/objects/test_notification.py b/nova/tests/unit/notifications/objects/test_notification.py index 8204d2bd35..521fcbe2b9 100644 --- a/nova/tests/unit/notifications/objects/test_notification.py +++ b/nova/tests/unit/notifications/objects/test_notification.py @@ -385,7 +385,7 @@ notification_object_data = { # ImageMetaProps, so when you see a fail here for that reason, you must # *also* bump the version of ImageMetaPropsPayload. See its docstring for # more information. - 'ImageMetaPropsPayload': '1.14-af9efd17cd034596be792fa25f24e83d', + 'ImageMetaPropsPayload': '1.15-a3d7a75fedbf373bcab2d9d6ece249df', 'InstanceActionNotification': '1.0-a73147b93b520ff0061865849d3dfa56', 'InstanceActionPayload': '1.8-b948818df6ec562e4eb4b23e515e451b', 'InstanceActionRebuildNotification': diff --git a/nova/tests/unit/objects/test_image_meta.py b/nova/tests/unit/objects/test_image_meta.py index 2b86c196af..81b54a19d6 100644 --- a/nova/tests/unit/objects/test_image_meta.py +++ b/nova/tests/unit/objects/test_image_meta.py @@ -17,6 +17,7 @@ import datetime from oslo_utils.fixture import uuidsentinel as uuids from nova import exception +from nova.network import model as network_model from nova import objects from nova.objects import fields from nova import test @@ -608,3 +609,19 @@ class TestImageMetaProps(test.NoDBTestCase): self.assertNotIn( 'hw_firmware_stateless', primitive['nova_object.data']) + + def test_obj_make_compatible_vif_model_igb(self): + obj = objects.ImageMetaProps(hw_vif_model=network_model.VIF_MODEL_IGB) + + primitive = obj.obj_to_primitive('1.39') + self.assertIn( + 'hw_vif_model', + primitive['nova_object.data']) + self.assertEqual( + network_model.VIF_MODEL_IGB, + primitive['nova_object.data']['hw_vif_model']) + + ex = self.assertRaises( + exception.ObjectActionError, obj.obj_to_primitive, '1.38') + self.assertIn( + 'hw_vif_model=igb not supported in version (1, 38)', str(ex)) diff --git a/nova/tests/unit/objects/test_objects.py b/nova/tests/unit/objects/test_objects.py index 94bbb7b9d5..0966783d55 100644 --- a/nova/tests/unit/objects/test_objects.py +++ b/nova/tests/unit/objects/test_objects.py @@ -1105,7 +1105,7 @@ object_data = { 'HyperVLiveMigrateData': '1.4-e265780e6acfa631476c8170e8d6fce0', 'IDEDeviceBus': '1.0-29d4c9f27ac44197f01b6ac1b7e16502', 'ImageMeta': '1.8-642d1b2eb3e880a367f37d72dd76162d', - 'ImageMetaProps': '1.38-1f4f4f1b60413aa543e446d716cfbc20', + 'ImageMetaProps': '1.39-b0fb2690fa477480e42a1469769cb9fc', 'Instance': '2.8-2727dba5e4a078e6cc848c1f94f7eb24', 'InstanceAction': '1.2-9a5abc87fdd3af46f45731960651efb5', 'InstanceActionEvent': '1.4-5b1f361bd81989f8bb2c20bb7e8a4cb4',