@@ -44,19 +44,25 @@ type host_info = {
4444}
4545
4646let read_localhost_info () =
47- let xen_verstring =
47+ let xen_verstring, total_memory_mib =
4848 try
4949 let xc = Xenctrl. interface_open () in
5050 let v = Xenctrl. version xc in
5151 Xenctrl. interface_close xc;
5252 let open Xenctrl in
53- Printf. sprintf " %d.%d%s" v.major v.minor v.extra
53+ let xen_verstring = Printf. sprintf " %d.%d%s" v.major v.minor v.extra in
54+ let total_memory_mib =
55+ let open Xenops_client in
56+ Client.HOST. get_total_memory_mib " read_localhost_info" in
57+ xen_verstring, total_memory_mib
5458 with e ->
5559 if Pool_role. is_unit_test ()
56- then " 0.0.0"
60+ then " 0.0.0" , 0L
5761 else begin
5862 warn " Failed to read xen version" ;
59- " unknown"
63+ match Balloon. get_memtotal () with
64+ | None -> " unknown" , 0L
65+ | Some x -> " unknown" , Int64. (div x (mul 1024L 1024L ))
6066 end
6167 and linux_verstring =
6268 let verstring = ref " " in
@@ -69,21 +75,21 @@ let read_localhost_info () =
6975 let me = Helpers. get_localhost_uuid () in
7076 let lookup_inventory_nofail k = try Some (Xapi_inventory. lookup k) with _ -> None in
7177 let this_host_name = Helpers. get_hostname() in
72- let total_memory_mib =
73- let open Xenops_client in
74- Client.HOST. get_total_memory_mib " read_localhost_info" in
75-
76- let dom0_static_max =
77- (* Query the balloon driver to determine how much memory is available for domain 0. *)
78- (* We cannot ask XenControl for this information, since for domain 0, the value of *)
79- (* max_memory_pages is hard-wired to the maximum native integer value ("infinity"). *)
80- let map = Balloon. parse_proc_xen_balloon () in
81- let lookup = fun x -> Opt. unbox (List. assoc x map) in
82- let keys = [Balloon. _low_mem_balloon; Balloon. _high_mem_balloon; Balloon. _current_allocation] in
83- let values = List. map lookup keys in
84- let result = List. fold_left Int64. add 0L values in
85- Int64. mul 1024L result in
8678
79+ let dom0_static_max =
80+ try
81+ (* Query the balloon driver to determine how much memory is available for domain 0. *)
82+ (* We cannot ask XenControl for this information, since for domain 0, the value of *)
83+ (* max_memory_pages is hard-wired to the maximum native integer value ("infinity"). *)
84+ let map = Balloon. parse_proc_xen_balloon () in
85+ let lookup = fun x -> Opt. unbox (List. assoc x map) in
86+ let keys = [Balloon. _low_mem_balloon; Balloon. _high_mem_balloon; Balloon. _current_allocation] in
87+ let values = List. map lookup keys in
88+ let result = List. fold_left Int64. add 0L values in
89+ Int64. mul 1024L result
90+ with e ->
91+ info " Failed to query balloon driver, assuming target = static_max" ;
92+ Int64. (mul total_memory_mib (mul 1024L 1024L )) in
8793 {
8894 name_label= this_host_name;
8995 xen_verstring= xen_verstring;
0 commit comments