Skip to content

Commit 057891a

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "hardware: refactor the code for CPU policy sanity check"
2 parents c1a4828 + c4e9e2e commit 057891a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

nova/virt/hardware.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,9 +1944,6 @@ def numa_get_constraints(flavor, image_meta):
19441944
# 'dedicated' policy.
19451945
if dedicated_cpus:
19461946
raise exception.RequiredMixedInstancePolicy()
1947-
# But for an instance with 'dedicated' CPU allocation policy, all
1948-
# CPUs are 'dedicated' CPUs, which is 1:1 pinned to a host CPU.
1949-
dedicated_cpus = set(range(flavor.vcpus))
19501947
else: # MIXED
19511948
# FIXME(huaqiang): So far, 'mixed' instance is not supported
19521949
# and the 'dedicated_cpus' variable is set to 'None' due to being not
@@ -1960,7 +1957,13 @@ def numa_get_constraints(flavor, image_meta):
19601957
pagesize = _get_numa_pagesize_constraint(flavor, image_meta)
19611958
vpmems = get_vpmems(flavor)
19621959

1960+
# If 'hw:cpu_dedicated_mask' is not found in flavor extra specs, the
1961+
# 'dedicated_cpus' variable is None, while we hope it being an empty set.
19631962
dedicated_cpus = dedicated_cpus or set()
1963+
if cpu_policy == fields.CPUAllocationPolicy.DEDICATED:
1964+
# But for an instance with 'dedicated' CPU allocation policy, all
1965+
# CPUs are 'dedicated' CPUs, which is 1:1 pinned to a host CPU.
1966+
dedicated_cpus = set(range(flavor.vcpus))
19641967

19651968
# NOTE(stephenfin): There are currently four things that will configure a
19661969
# NUMA topology for an instance:

0 commit comments

Comments
 (0)