Merge "virt: add constraint to handle realtime policy"
This commit is contained in:
commit
e0bb3d38bf
@ -1956,3 +1956,8 @@ class UnsupportedImageModel(Invalid):
|
|||||||
|
|
||||||
class HostMappingNotFound(Invalid):
|
class HostMappingNotFound(Invalid):
|
||||||
msg_fmt = _("Host '%(name)s' is not mapped to any cell")
|
msg_fmt = _("Host '%(name)s' is not mapped to any cell")
|
||||||
|
|
||||||
|
|
||||||
|
class RealtimeConfigurationInvalid(Invalid):
|
||||||
|
msg_fmt = _("Cannot set realtime policy in a non dedicated "
|
||||||
|
"cpu pinning policy")
|
||||||
|
@ -1090,6 +1090,18 @@ class NUMATopologyTest(test.NoDBTestCase):
|
|||||||
},
|
},
|
||||||
"expect": exception.ImageCPUPinningForbidden,
|
"expect": exception.ImageCPUPinningForbidden,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
# Invalid CPU pinning policy with realtime
|
||||||
|
"flavor": objects.Flavor(vcpus=4, memory_mb=2048,
|
||||||
|
extra_specs={
|
||||||
|
"hw:cpu_policy": "shared",
|
||||||
|
"hw:cpu_realtime": "yes",
|
||||||
|
}),
|
||||||
|
"image": {
|
||||||
|
"properties": {}
|
||||||
|
},
|
||||||
|
"expect": exception.RealtimeConfigurationInvalid,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
for testitem in testdata:
|
for testitem in testdata:
|
||||||
|
@ -958,6 +958,11 @@ def _numa_get_constraints_manual(nodes, flavor, cpu_list, mem_list):
|
|||||||
return objects.InstanceNUMATopology(cells=cells)
|
return objects.InstanceNUMATopology(cells=cells)
|
||||||
|
|
||||||
|
|
||||||
|
def is_realtime_enabled(flavor):
|
||||||
|
flavor_rt = flavor.get('extra_specs', {}).get("hw:cpu_realtime")
|
||||||
|
return strutils.bool_from_string(flavor_rt)
|
||||||
|
|
||||||
|
|
||||||
def _numa_get_constraints_auto(nodes, flavor):
|
def _numa_get_constraints_auto(nodes, flavor):
|
||||||
if ((flavor.vcpus % nodes) > 0 or
|
if ((flavor.vcpus % nodes) > 0 or
|
||||||
(flavor.memory_mb % nodes) > 0):
|
(flavor.memory_mb % nodes) > 0):
|
||||||
@ -988,6 +993,11 @@ def _add_cpu_pinning_constraint(flavor, image_meta, numa_topology):
|
|||||||
else:
|
else:
|
||||||
requested = image_pinning == "dedicated"
|
requested = image_pinning == "dedicated"
|
||||||
|
|
||||||
|
rt = is_realtime_enabled(flavor)
|
||||||
|
pi = image_pinning or flavor_pinning
|
||||||
|
if rt and pi != "dedicated":
|
||||||
|
raise exception.RealtimeConfigurationInvalid()
|
||||||
|
|
||||||
if not requested:
|
if not requested:
|
||||||
return numa_topology
|
return numa_topology
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user