compute: introduce cpu_shared_set option
The CONF.compute.cpu_shared_set option will be used for best-effort guest vCPU resources. It's to note that an other effort done by spec cpu-resources will use that same option to provide isolation between dedicated and shared instances. But currently outside of the scope of that whole serie. Change-Id: Ibedd31e284ec9bc70e257e6a88b4d82b021db0fd Partial-implement: bp/overhead-pin-set Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@redhat.com>
This commit is contained in:
@@ -655,6 +655,17 @@ node.
|
|||||||
Possible values:
|
Possible values:
|
||||||
|
|
||||||
* Any positive integer in seconds.
|
* Any positive integer in seconds.
|
||||||
|
"""),
|
||||||
|
cfg.StrOpt('cpu_shared_set',
|
||||||
|
help="""
|
||||||
|
Defines which physical CPUs (pCPUs) will be used for best-effort guest vCPU
|
||||||
|
resources.
|
||||||
|
|
||||||
|
Currently only used by libvirt driver to place guest emulator threads when
|
||||||
|
hw:emulator_threads_policy:share.
|
||||||
|
|
||||||
|
::
|
||||||
|
cpu_shared_set = "4-12,^8,15"
|
||||||
""")
|
""")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -61,11 +61,25 @@ class CpuSetTestCase(test.NoDBTestCase):
|
|||||||
cpuset_ids = hw.get_vcpu_pin_set()
|
cpuset_ids = hw.get_vcpu_pin_set()
|
||||||
self.assertEqual(set([1, 3, 5]), cpuset_ids)
|
self.assertEqual(set([1, 3, 5]), cpuset_ids)
|
||||||
|
|
||||||
|
def test_get_cpu_shared_set(self):
|
||||||
|
self.flags(cpu_shared_set="0-5,6,^2", group='compute')
|
||||||
|
cpuset_ids = hw.get_cpu_shared_set()
|
||||||
|
self.assertEqual(set([0, 1, 3, 4, 5, 6]), cpuset_ids)
|
||||||
|
|
||||||
def test_parse_cpu_spec_none_returns_none(self):
|
def test_parse_cpu_spec_none_returns_none(self):
|
||||||
self.flags(vcpu_pin_set=None)
|
self.flags(vcpu_pin_set=None)
|
||||||
cpuset_ids = hw.get_vcpu_pin_set()
|
cpuset_ids = hw.get_vcpu_pin_set()
|
||||||
self.assertIsNone(cpuset_ids)
|
self.assertIsNone(cpuset_ids)
|
||||||
|
|
||||||
|
def test_parse_cpu_shared_set_returns_none(self):
|
||||||
|
self.flags(cpu_shared_set=None, group='compute')
|
||||||
|
cpuset_ids = hw.get_cpu_shared_set()
|
||||||
|
self.assertIsNone(cpuset_ids)
|
||||||
|
|
||||||
|
def test_parse_cpu_shared_set_error(self):
|
||||||
|
self.flags(cpu_shared_set="0-1,^0,^1", group='compute')
|
||||||
|
self.assertRaises(exception.Invalid, hw.get_cpu_shared_set)
|
||||||
|
|
||||||
def test_parse_cpu_spec_valid_syntax_works(self):
|
def test_parse_cpu_spec_valid_syntax_works(self):
|
||||||
cpuset_ids = hw.parse_cpu_spec("1")
|
cpuset_ids = hw.parse_cpu_spec("1")
|
||||||
self.assertEqual(set([1]), cpuset_ids)
|
self.assertEqual(set([1]), cpuset_ids)
|
||||||
|
|||||||
@@ -54,6 +54,22 @@ def get_vcpu_pin_set():
|
|||||||
return cpuset_ids
|
return cpuset_ids
|
||||||
|
|
||||||
|
|
||||||
|
def get_cpu_shared_set():
|
||||||
|
"""Parse cpu_shared_set config.
|
||||||
|
|
||||||
|
:returns: a set of pcpu ids can be used for best effort workloads
|
||||||
|
"""
|
||||||
|
if not CONF.compute.cpu_shared_set:
|
||||||
|
return None
|
||||||
|
|
||||||
|
shared_ids = parse_cpu_spec(CONF.compute.cpu_shared_set)
|
||||||
|
if not shared_ids:
|
||||||
|
raise exception.Invalid(_("No CPUs available after parsing "
|
||||||
|
"cpu_shared_set config. %r ") %
|
||||||
|
CONF.compute.cpu_shared_set)
|
||||||
|
return shared_ids
|
||||||
|
|
||||||
|
|
||||||
def parse_cpu_spec(spec):
|
def parse_cpu_spec(spec):
|
||||||
"""Parse a CPU set specification.
|
"""Parse a CPU set specification.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user