@@ -735,12 +735,31 @@ def _handle_conn_event(self, enabled, reason):
735735 {'enabled': enabled, 'reason': reason})
736736 self._set_host_enabled(enabled, reason)
737737
738+ def _init_host_topology(self):
739+ """To work around a bug in libvirt that reports offline CPUs as always
740+ being on socket 0 regardless of their real socket, power up all
741+ dedicated CPUs (the only ones whose socket we actually care about),
742+ then call get_capabilities() to initialize the topology with the
743+ correct socket values. get_capabilities()'s implementation will reuse
744+ these initial socket value, and avoid clobbering them with 0 for
745+ offline CPUs.
746+ """
747+ cpus = hardware.get_cpu_dedicated_set()
748+ if cpus:
749+ self.cpu_api.power_up(cpus)
750+ self._host.get_capabilities()
751+
738752 def init_host(self, host):
739753 self._host.initialize()
740754
741- self._update_host_specific_capabilities()
742-
755+ # NOTE(artom) Do this first to make sure our first call to
756+ # get_capabilities() happens with all dedicated CPUs online and caches
757+ # their correct socket ID. Unused dedicated CPUs will be powered down
758+ # further down in this method.
743759 self._check_cpu_set_configuration()
760+ self._init_host_topology()
761+
762+ self._update_host_specific_capabilities()
744763
745764 self._do_quality_warnings()
746765
0 commit comments