@@ -172,27 +172,29 @@ def validate_all_dedicated_cpus(self) -> None:
172
172
if not CONF .libvirt .cpu_power_management :
173
173
return
174
174
cpu_dedicated_set = hardware .get_cpu_dedicated_set () or set ()
175
- governors = set ()
176
- cpu_states = set ()
175
+ pcpus = []
177
176
for pcpu in cpu_dedicated_set :
178
177
if (pcpu == 0 and
179
178
CONF .libvirt .cpu_power_management_strategy == 'cpu_state' ):
180
179
LOG .warning ('CPU0 is in cpu_dedicated_set, '
181
180
'but it is not eligible for state management '
182
181
'and will be ignored' )
183
182
continue
184
- pcpu = self .core (pcpu )
185
183
# we need to collect the governors strategy and the CPU states
186
- governors .add (pcpu .governor )
187
- cpu_states .add (pcpu .online )
184
+ pcpus .append (self .core (pcpu ))
188
185
if CONF .libvirt .cpu_power_management_strategy == 'cpu_state' :
186
+ # NOTE(sbauza): offline cores can't have a governor, it returns a
187
+ # DeviceBusy exception.
188
+ governors = set ([pcpu .governor for pcpu in pcpus
189
+ if pcpu .online ])
189
190
# all the cores need to have the same governor strategy
190
191
if len (governors ) > 1 :
191
192
msg = _ ("All the cores need to have the same governor strategy"
192
193
"before modifying the CPU states. You can reboot the "
193
194
"compute node if you prefer." )
194
195
raise exception .InvalidConfiguration (msg )
195
196
elif CONF .libvirt .cpu_power_management_strategy == 'governor' :
197
+ cpu_states = set ([pcpu .online for pcpu in pcpus ])
196
198
# all the cores need to be online
197
199
if False in cpu_states :
198
200
msg = _ ("All the cores need to be online before modifying the "
0 commit comments