Skip to content

Commit

Permalink
CP-4319: Add field host.cpu_info:socket_count
Browse files Browse the repository at this point in the history
Signed-off-by: John Else <john.else@citrix.com>
  • Loading branch information
johnelse committed Apr 3, 2013
1 parent 84aa08b commit f800ae2
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions ocaml/xapi/create_misc.ml
Expand Up @@ -400,12 +400,16 @@ let make_software_version () =
make_packs_info ()

let create_host_cpu ~__context =
let get_nb_cpus () =
let xc = Xenctrl.interface_open () in
let p = Xenctrl.physinfo xc in
Xenctrl.interface_close xc;
p.Xenctrl.Phys_info.nr_cpus
let get_cpu_layout () =
let open Xenctrl in
let p = Vmopshelpers.with_xc (fun xc -> physinfo xc) in
let cpu_count = p.Phys_info.nr_cpus in
let socket_count =
p.Phys_info.nr_cpus /
(p.Phys_info.threads_per_core * p.Phys_info.cores_per_socket)
in
cpu_count, socket_count
in
let trim_end s =
let i = ref (String.length s - 1) in
while !i > 0 && (List.mem s.[!i] [ ' '; '\t'; '\n'; '\r' ])
Expand Down Expand Up @@ -452,7 +456,7 @@ let create_host_cpu ~__context =
Hashtbl.find tbl "cpu family"
in
let vendor, modelname, cpu_mhz, flags, stepping, model, family = get_cpuinfo () in
let number = get_nb_cpus () in
let cpu_count, socket_count = get_cpu_layout () in
let host = Helpers.get_localhost ~__context in

(* Fill in Host.cpu_info *)
Expand All @@ -466,7 +470,8 @@ let create_host_cpu ~__context =
| Cpuid.Full -> "full"
in
let cpu = [
"cpu_count", string_of_int number;
"cpu_count", string_of_int cpu_count;
"socket_count", string_of_int socket_count;
"vendor", vendor;
"speed", cpu_mhz;
"modelname", modelname;
Expand All @@ -490,7 +495,7 @@ let create_host_cpu ~__context =
(* Recreate all Host_cpu objects *)
let host_cpus = List.filter (fun (_, s) -> s.API.host_cpu_host = host) (Db.Host_cpu.get_all_records ~__context) in
List.iter (fun (r, _) -> Db.Host_cpu.destroy ~__context ~self:r) host_cpus;
for i = 0 to number - 1
for i = 0 to cpu_count - 1
do
let uuid = Uuid.to_string (Uuid.make_uuid ())
and ref = Ref.make () in
Expand Down

0 comments on commit f800ae2

Please sign in to comment.