@@ -172,27 +172,29 @@ def validate_all_dedicated_cpus(self) -> None:
172172 if not CONF .libvirt .cpu_power_management :
173173 return
174174 cpu_dedicated_set = hardware .get_cpu_dedicated_set () or set ()
175- governors = set ()
176- cpu_states = set ()
175+ pcpus = []
177176 for pcpu in cpu_dedicated_set :
178177 if (pcpu == 0 and
179178 CONF .libvirt .cpu_power_management_strategy == 'cpu_state' ):
180179 LOG .warning ('CPU0 is in cpu_dedicated_set, '
181180 'but it is not eligible for state management '
182181 'and will be ignored' )
183182 continue
184- pcpu = self .core (pcpu )
185183 # 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 ))
188185 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 ])
189190 # all the cores need to have the same governor strategy
190191 if len (governors ) > 1 :
191192 msg = _ ("All the cores need to have the same governor strategy"
192193 "before modifying the CPU states. You can reboot the "
193194 "compute node if you prefer." )
194195 raise exception .InvalidConfiguration (msg )
195196 elif CONF .libvirt .cpu_power_management_strategy == 'governor' :
197+ cpu_states = set ([pcpu .online for pcpu in pcpus ])
196198 # all the cores need to be online
197199 if False in cpu_states :
198200 msg = _ ("All the cores need to be online before modifying the "
0 commit comments