Merge "hardware: Tweak the 'cpu_realtime_mask' handling slightly"
This commit is contained in:
commit
70b70dc17a
@ -625,9 +625,11 @@ CPU real-time policy
|
|||||||
- ``yes``: The guest vCPUs will have a real-time policy
|
- ``yes``: The guest vCPUs will have a real-time policy
|
||||||
|
|
||||||
CPU-REALTIME-MASK (coremask):
|
CPU-REALTIME-MASK (coremask):
|
||||||
A coremask indicating which vCPUs **will not** have a real-time policy. This
|
A coremask indicating which vCPUs **will** or, if starting with a ``^``,
|
||||||
should start with a ``^``. For example, a value of ``^0-1`` indicates that
|
**will not** have a real-time policy. For example, a value of ``0-5``
|
||||||
all vCPUs *except* vCPUs ``0`` and ``1`` will have a real-time policy.
|
indicates that vCPUs ``0`` to ``5`` will have a real-time policy.
|
||||||
|
Conversely, a value of ``^0-1`` indicates that all vCPUs *except* vCPUs
|
||||||
|
``0`` and ``1`` will have a real-time policy.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
@ -641,6 +643,12 @@ CPU real-time policy
|
|||||||
to omit this when an emulator thread policy is configured using the
|
to omit this when an emulator thread policy is configured using the
|
||||||
``hw:emulator_threads_policy`` extra spec.
|
``hw:emulator_threads_policy`` extra spec.
|
||||||
|
|
||||||
|
.. versionchanged:: 22.0.0 (Victoria)
|
||||||
|
|
||||||
|
Previously, the leading carat was necessary and omitting it would be
|
||||||
|
equivalent to not setting the mask, resulting in a failure to spawn
|
||||||
|
the instance.
|
||||||
|
|
||||||
.. _extra-specs-emulator-threads-policy:
|
.. _extra-specs-emulator-threads-policy:
|
||||||
|
|
||||||
Emulator threads policy
|
Emulator threads policy
|
||||||
|
@ -36,8 +36,7 @@ realtime_validators = [
|
|||||||
),
|
),
|
||||||
value={
|
value={
|
||||||
'type': str,
|
'type': str,
|
||||||
# NOTE(stephenfin): Yes, these things *have* to start with '^'
|
'pattern': r'(\^)?\d+((-\d+)?(,\^?\d+(-\d+)?)?)*',
|
||||||
'pattern': r'\^\d+((-\d+)?(,\^?\d+(-\d+)?)?)*',
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -59,6 +59,7 @@ class TestValidators(test.NoDBTestCase):
|
|||||||
def test_value__str(self):
|
def test_value__str(self):
|
||||||
valid_specs = (
|
valid_specs = (
|
||||||
# patterns
|
# patterns
|
||||||
|
('hw:cpu_realtime_mask', '0'),
|
||||||
('hw:cpu_realtime_mask', '^0'),
|
('hw:cpu_realtime_mask', '^0'),
|
||||||
('hw:cpu_realtime_mask', '^0,2-3,1'),
|
('hw:cpu_realtime_mask', '^0,2-3,1'),
|
||||||
('hw:mem_page_size', 'large'),
|
('hw:mem_page_size', 'large'),
|
||||||
@ -74,7 +75,7 @@ class TestValidators(test.NoDBTestCase):
|
|||||||
|
|
||||||
invalid_specs = (
|
invalid_specs = (
|
||||||
# patterns
|
# patterns
|
||||||
('hw:cpu_realtime_mask', '0'),
|
('hw:cpu_realtime_mask', 'a'),
|
||||||
('hw:cpu_realtime_mask', '^0,2-3,b'),
|
('hw:cpu_realtime_mask', '^0,2-3,b'),
|
||||||
('hw:mem_page_size', 'largest'),
|
('hw:mem_page_size', 'largest'),
|
||||||
('hw:mem_page_size', '2kbits'),
|
('hw:mem_page_size', '2kbits'),
|
||||||
|
@ -3818,6 +3818,42 @@ class CPURealtimeTestCase(test.NoDBTestCase):
|
|||||||
rt = hw.get_realtime_cpu_constraint(flavor, image)
|
rt = hw.get_realtime_cpu_constraint(flavor, image)
|
||||||
self.assertEqual(set([2]), rt)
|
self.assertEqual(set([2]), rt)
|
||||||
|
|
||||||
|
def test_success_image_no_exclusion(self):
|
||||||
|
flavor = objects.Flavor(
|
||||||
|
vcpus=3, memory_mb=2048,
|
||||||
|
extra_specs={
|
||||||
|
'hw:cpu_realtime': 'true',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
image = objects.ImageMeta.from_dict(
|
||||||
|
{"properties": {"hw_cpu_realtime_mask": "1-2"}})
|
||||||
|
rt = hw.get_realtime_cpu_constraint(flavor, image)
|
||||||
|
self.assertEqual(set([1, 2]), rt)
|
||||||
|
|
||||||
|
def test_success_image_leading_space(self):
|
||||||
|
flavor = objects.Flavor(
|
||||||
|
vcpus=3, memory_mb=2048,
|
||||||
|
extra_specs={
|
||||||
|
'hw:cpu_realtime': 'true',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
image = objects.ImageMeta.from_dict(
|
||||||
|
{"properties": {"hw_cpu_realtime_mask": " ^1"}})
|
||||||
|
rt = hw.get_realtime_cpu_constraint(flavor, image)
|
||||||
|
self.assertEqual(set([0, 2]), rt)
|
||||||
|
|
||||||
|
def test_success_image_no_implicit_exclusion(self):
|
||||||
|
flavor = objects.Flavor(
|
||||||
|
vcpus=3, memory_mb=2048,
|
||||||
|
extra_specs={
|
||||||
|
'hw:cpu_realtime': 'true',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
image = objects.ImageMeta.from_dict(
|
||||||
|
{"properties": {"hw_cpu_realtime_mask": "1-2,^1"}})
|
||||||
|
rt = hw.get_realtime_cpu_constraint(flavor, image)
|
||||||
|
self.assertEqual(set([2]), rt)
|
||||||
|
|
||||||
def test_no_mask_configured(self):
|
def test_no_mask_configured(self):
|
||||||
flavor = objects.Flavor(
|
flavor = objects.Flavor(
|
||||||
vcpus=3, memory_mb=2048,
|
vcpus=3, memory_mb=2048,
|
||||||
|
@ -1708,7 +1708,10 @@ def get_realtime_cpu_constraint(
|
|||||||
|
|
||||||
vcpus_set = set(range(flavor.vcpus))
|
vcpus_set = set(range(flavor.vcpus))
|
||||||
if mask:
|
if mask:
|
||||||
vcpus_rt = parse_cpu_spec("0-%d,%s" % (flavor.vcpus - 1, mask))
|
if mask.strip().startswith('^'):
|
||||||
|
vcpus_rt = parse_cpu_spec("0-%d,%s" % (flavor.vcpus - 1, mask))
|
||||||
|
else:
|
||||||
|
vcpus_rt = parse_cpu_spec("%s" % (mask))
|
||||||
else:
|
else:
|
||||||
vcpus_rt = set(range(flavor.vcpus))
|
vcpus_rt = set(range(flavor.vcpus))
|
||||||
|
|
||||||
|
@ -9,3 +9,8 @@ features:
|
|||||||
It is now possible to allocate all cores in an instance to realtime and
|
It is now possible to allocate all cores in an instance to realtime and
|
||||||
omit the ``hw:cpu_realtime_mask`` extra spec. This requires specifying the
|
omit the ``hw:cpu_realtime_mask`` extra spec. This requires specifying the
|
||||||
``hw:emulator_threads_policy`` extra spec.
|
``hw:emulator_threads_policy`` extra spec.
|
||||||
|
- |
|
||||||
|
It is now possible to specify a mask in ``hw:cpu_realtime_mask`` without a
|
||||||
|
leading ``^``. When this is ommitted, the value will specify the cores that
|
||||||
|
should be included in the set of realtime cores, as opposed to those that
|
||||||
|
should be excluded.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user