diff --git a/lib/vdsm/taskset.py b/lib/vdsm/taskset.py index f595e18bf..7e2efb8d4 100644 --- a/lib/vdsm/taskset.py +++ b/lib/vdsm/taskset.py @@ -91,10 +91,13 @@ def cpulist_parse(cpu_range): or the output of the 'taskset' and 'lscpu' tools. """ cpus = [] + excluded_cpus = [] for item in cpu_range.split(','): if '-' in item: begin, end = item.split('-', 1) cpus.extend(range(int(begin), int(end) + 1)) + elif item.startswith("^"): + excluded_cpus.append(int(item[1:])) else: cpus.append(int(item)) - return frozenset(cpus) + return frozenset(cpus) - frozenset(excluded_cpus) diff --git a/tests/virt/domaindescriptor_test.py b/tests/virt/domaindescriptor_test.py index afe7e5016..952e979ba 100644 --- a/tests/virt/domaindescriptor_test.py +++ b/tests/virt/domaindescriptor_test.py @@ -112,6 +112,7 @@ + """ @@ -261,9 +262,10 @@ def test_get_number_of_cpus(self, xml_data, expected): def test_pinned_cpus(self): desc = DomainDescriptor(PINNED_CPUS) pinning = desc.pinned_cpus - assert len(pinning) == 2 + assert len(pinning) == 3 assert pinning[0] == frozenset([1, 2, 5, 6, 7]) assert pinning[1] == frozenset([1, 6, 10]) + assert pinning[2] == frozenset([1, 2, 4, 6]) def test_no_pinned_cpus(self): desc = DomainDescriptor(NO_PINNED_CPUS)