@@ -188,12 +188,15 @@ let dss_hostload xc domains =
188188 let load =
189189 List. fold_left
190190 (fun acc (dom , _ , domid ) ->
191- sum 0 dom.Xenctrl. max_vcpu_id (fun id ->
192- let vcpuinfo = Xenctrl. domain_get_vcpuinfo xc domid id in
193- if vcpuinfo.Xenctrl. online && not vcpuinfo.Xenctrl. blocked then
194- 1
195- else
196- 0
191+ ( try
192+ sum 0 dom.Xenctrl. max_vcpu_id (fun id ->
193+ let vcpuinfo = Xenctrl. domain_get_vcpuinfo xc domid id in
194+ if vcpuinfo.Xenctrl. online && not vcpuinfo.Xenctrl. blocked then
195+ 1
196+ else
197+ 0
198+ )
199+ with _ -> 0
197200 )
198201 + acc
199202 )
@@ -230,14 +233,20 @@ let generate_cpu_ds_list xc () =
230233 let _, domains, _ = Xenctrl_lib. domain_snapshot xc in
231234 dss_pcpus xc @ dss_vcpus xc domains @ dss_loadavg () @ dss_hostload xc domains
232235
236+ (* 32 vCPUS ~8659 bytes, so 64 vCPUs should fit in 5 *)
237+ let cpu_pages_per_vm = 5
238+
233239let _ =
234240 Xenctrl. with_intf (fun xc ->
235241 let _, domains, _ = Xenctrl_lib. domain_snapshot xc in
236242 Process. initialise () ;
237243 (* Share one page per PCPU and dom each *)
238244 let physinfo = Xenctrl. physinfo xc in
239- let shared_page_count = physinfo.Xenctrl. nr_cpus + List. length domains in
240- (* TODO: Can run out of pages if a lot of domains are added at runtime *)
245+ let shared_page_count =
246+ physinfo.Xenctrl. nr_cpus
247+ + Int. max Rrd_interface. max_supported_vms (List. length domains)
248+ * cpu_pages_per_vm
249+ in
241250 Process. main_loop ~neg_shift: 0.5
242251 ~target: (Reporter. Local shared_page_count) ~protocol: Rrd_interface. V2
243252 ~dss_f: (generate_cpu_ds_list xc)
0 commit comments