objects: Add 'socket' PCI NUMA affinity

This patch adds the 'socket' value to the allowed PCI NUMA affinity
policies, both to the 'hw:pci_numa_affinity_policy' flavor extra spec,
and the 'hw_pci_numa_affinity_policy' image property.

For now the new value is a no-op and remains undocumented. It will be
wired-in in a subsequent patch.

Implements: blueprint pci-socket-affinity
Change-Id: I0680d4e21f3e317ac702b55afef4c87e8acbfc3a
This commit is contained in:
Artom Lifshitz 2021-01-27 10:50:38 -05:00 committed by Stephen Finucane
parent 95b9481aa4
commit be80dfdc71
12 changed files with 41 additions and 15 deletions

View File

@ -4,5 +4,5 @@
"hw_architecture": "x86_64"
},
"nova_object.name": "ImageMetaPropsPayload",
"nova_object.version": "1.5"
"nova_object.version": "1.6"
}

View File

@ -223,6 +223,7 @@ numa_validators = [
'required',
'preferred',
'legacy',
'socket',
],
},
),

View File

@ -122,7 +122,8 @@ class ImageMetaPropsPayload(base.NotificationPayloadBase):
# Version 1.3: Added hw_mem_encryption, hw_pmu and hw_time_hpet fields
# Version 1.4: Added 'mixed' to hw_cpu_policy field
# Version 1.5: Added 'hw_tpm_model' and 'hw_tpm_version' fields
VERSION = '1.5'
# Version 1.6: Added 'socket' to hw_pci_numa_affinity_policy
VERSION = '1.6'
SCHEMA = {
k: ('image_meta_props', k) for k in image_meta.ImageMetaProps.fields}

View File

@ -240,7 +240,8 @@ class InstancePCIRequestsPayload(base.NotificationPayloadBase):
@nova_base.NovaObjectRegistry.register_notification
class InstancePCIRequestPayload(base.NotificationPayloadBase):
# Version 1.0: Initial version
VERSION = '1.0'
# Version 1.1: Added 'socket' to numa_policy field
VERSION = '1.1'
SCHEMA = {
'count': ('pci_request', 'count'),

View File

@ -758,8 +758,9 @@ class PCINUMAAffinityPolicy(BaseNovaEnum):
REQUIRED = "required"
LEGACY = "legacy"
PREFERRED = "preferred"
SOCKET = "socket"
ALL = (REQUIRED, LEGACY, PREFERRED)
ALL = (REQUIRED, LEGACY, PREFERRED, SOCKET)
class DiskFormat(BaseNovaEnum):

View File

@ -176,14 +176,23 @@ class ImageMetaProps(base.NovaObject):
# Version 1.25: Added 'hw_pci_numa_affinity_policy' field
# Version 1.26: Added 'mixed' to 'hw_cpu_policy' field
# Version 1.27: Added 'hw_tpm_model' and 'hw_tpm_version' fields
# Version 1.28: Added 'socket' to 'hw_pci_numa_affinity_policy'
# NOTE(efried): When bumping this version, the version of
# ImageMetaPropsPayload must also be bumped. See its docstring for details.
VERSION = '1.27'
VERSION = '1.28'
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, 28):
policy = primitive.get('hw_pci_numa_affinity_policy', None)
if policy == fields.PCINUMAAffinityPolicy.SOCKET:
raise exception.ObjectActionError(
action='obj_make_compatible',
reason='hw_numa_affinity_policy=%s not supported '
'in version %s' %
(policy, target_version))
if target_version < (1, 27):
primitive.pop('hw_tpm_model', None)
primitive.pop('hw_tpm_version', None)

View File

@ -23,10 +23,11 @@ from nova.objects import fields
class InstancePCIRequest(base.NovaObject,
base.NovaObjectDictCompat):
# Version 1.0: Initial version
# Version 1.1: Add request_id
# Version 1.2: Add PCI NUMA affinity policy
# Version 1.3: Add requester_id
VERSION = '1.3'
# Version 1.1: Added request_id field
# Version 1.2: Added numa_policy field
# Version 1.3: Added requester_id field
# Version 1.4: Added 'socket' to numa_policy field
VERSION = '1.4'
# Possible sources for a PCI request:
# FLAVOR_ALIAS : Request originated from a flavor alias.

View File

@ -1233,7 +1233,7 @@ class TestInstanceNotificationSample(
'nova_object.data': {},
'nova_object.name': 'ImageMetaPropsPayload',
'nova_object.namespace': 'nova',
'nova_object.version': u'1.5',
'nova_object.version': u'1.6',
},
'image.size': 58145823,
'image.tags': [],
@ -1329,7 +1329,7 @@ class TestInstanceNotificationSample(
'nova_object.data': {},
'nova_object.name': 'ImageMetaPropsPayload',
'nova_object.namespace': 'nova',
'nova_object.version': u'1.5',
'nova_object.version': u'1.6',
},
'image.size': 58145823,
'image.tags': [],

View File

@ -70,6 +70,9 @@ class TestValidators(test.NoDBTestCase):
('hw:cpu_thread_policy', 'prefer'),
('hw:emulator_threads_policy', 'isolate'),
('hw:pci_numa_affinity_policy', 'legacy'),
('hw:pci_numa_affinity_policy', 'required'),
('hw:pci_numa_affinity_policy', 'preferred'),
('hw:pci_numa_affinity_policy', 'socket'),
('hw:cpu_policy', 'mixed'),
)
for key, value in valid_specs:
@ -86,6 +89,9 @@ class TestValidators(test.NoDBTestCase):
('hw:cpu_thread_policy', 'preferred'),
('hw:emulator_threads_policy', 'iisolate'),
('hw:pci_numa_affinity_policy', 'lgacy'),
('hw:pci_numa_affinity_policy', 'requird'),
('hw:pci_numa_affinity_policy', 'prefrred'),
('hw:pci_numa_affinity_policy', 'socet'),
)
for key, value in invalid_specs:
with testtools.ExpectedException(exception.ValidationError):

View File

@ -387,7 +387,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.5-f4074a974d4a9f77e302a53ee9340287',
'ImageMetaPropsPayload': '1.6-2be4d0bdd1d19a541c46a0d69e244d3f',
'InstanceActionNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
'InstanceActionPayload': '1.8-4fa3da9cbf0761f1f700ae578f36dc2f',
'InstanceActionRebuildNotification':
@ -413,7 +413,7 @@ notification_object_data = {
'InstanceExistsPayload': '1.2-e082c02438ee57164829afaeee3bf7f8',
'InstanceNUMACellPayload': '1.2-a367add3378c71c21c817ab2b23db3bf',
'InstanceNUMATopologyPayload': '1.0-247361b152047c18ae9ad1da2544a3c9',
'InstancePCIRequestPayload': '1.0-12d0d61baf183daaafd93cbeeed2956f',
'InstancePCIRequestPayload': '1.1-bda86a95ef04bdc27789342466b81bb5',
'InstancePCIRequestsPayload': '1.0-6751cffe0c0fabd212aad624f672429a',
'InstanceStateUpdatePayload': '1.0-07e111c0fa0f6db0f79b0726d593e3da',
'InstanceUpdateNotification': '1.0-a73147b93b520ff0061865849d3dfa56',

View File

@ -423,3 +423,9 @@ class TestImageMetaProps(test.NoDBTestCase):
primitive = obj.obj_to_primitive('1.26')
self.assertNotIn('hw_tpm_model', primitive['nova_object.data'])
self.assertNotIn('hw_tpm_version', primitive['nova_object.data'])
def test_obj_make_compatible_socket_policy(self):
obj = objects.ImageMetaProps(
hw_pci_numa_affinity_policy=fields.PCINUMAAffinityPolicy.SOCKET)
self.assertRaises(exception.ObjectActionError,
obj.obj_to_primitive, '1.27')

View File

@ -1074,7 +1074,7 @@ object_data = {
'HyperVLiveMigrateData': '1.4-e265780e6acfa631476c8170e8d6fce0',
'IDEDeviceBus': '1.0-29d4c9f27ac44197f01b6ac1b7e16502',
'ImageMeta': '1.8-642d1b2eb3e880a367f37d72dd76162d',
'ImageMetaProps': '1.27-f3f17d5e35146a0dbb56420ffc4f3990',
'ImageMetaProps': '1.28-a55674868f9e319a6b49d688e558d0aa',
'Instance': '2.7-d187aec68cad2e4d8b8a03a68e4739ce',
'InstanceAction': '1.2-9a5abc87fdd3af46f45731960651efb5',
'InstanceActionEvent': '1.4-5b1f361bd81989f8bb2c20bb7e8a4cb4',
@ -1092,7 +1092,7 @@ object_data = {
'InstanceMappingList': '1.3-d34b6ebb076d542ae0f8b440534118da',
'InstanceNUMACell': '1.6-25d9120d83a18356f4146f2a6fe2cc8d',
'InstanceNUMATopology': '1.3-ec0030cb0402a49c96da7051c037082a',
'InstancePCIRequest': '1.3-f6d324f1c337fad4f34892ed5f484c9a',
'InstancePCIRequest': '1.4-b27808ae189699df27f8f5b908b6393e',
'InstancePCIRequests': '1.1-65e38083177726d806684cb1cc0136d2',
'KeyPair': '1.4-1244e8d1b103cc69d038ed78ab3a8cc6',
'KeyPairList': '1.3-94aad3ac5c938eef4b5e83da0212f506',