diff --git a/ocaml/xcp-rrdd/bin/rrdp-cpu/rrdp_cpu.ml b/ocaml/xcp-rrdd/bin/rrdp-cpu/rrdp_cpu.ml index 30a66a29fb..a86fc8fb59 100644 --- a/ocaml/xcp-rrdd/bin/rrdp-cpu/rrdp_cpu.ml +++ b/ocaml/xcp-rrdd/bin/rrdp-cpu/rrdp_cpu.ml @@ -60,6 +60,24 @@ let dss_vcpus xc doms = let ( ++ ) = Int64.add in try let ri = Xenctrl.domain_get_runstate_info xc domid in + let runnable_vcpus_ds = + match ri.Xenctrl.runnable with + | 0L -> + [] + | _ -> + [ + ( Rrd.VM uuid + , Ds.ds_make ~name:"runnable_vcpus" ~units:"(fraction)" + ~value: + (Rrd.VT_Float + (Int64.to_float ri.Xenctrl.runnable /. 1.0e9) + ) + ~description: + "Fraction of time that vCPUs of the domain are runnable" + ~ty:Rrd.Derive ~default:false ~min:0.0 ~max:1.0 () + ) + ] + in ( Rrd.VM uuid , Ds.ds_make ~name:"runstate_fullrun" ~units:"(fraction)" ~value:(Rrd.VT_Float (Int64.to_float ri.Xenctrl.time0 /. 1.0e9)) @@ -133,6 +151,7 @@ let dss_vcpus xc doms = ~min:0.0 ~max:1.0 () ) :: dss + @ runnable_vcpus_ds with _ -> dss in try cpus 0 dss with _ -> dss diff --git a/ocaml/xenopsd/c_stubs/xenctrlext_stubs.c b/ocaml/xenopsd/c_stubs/xenctrlext_stubs.c index 4af5e60c8e..7f88ff1e39 100644 --- a/ocaml/xenopsd/c_stubs/xenctrlext_stubs.c +++ b/ocaml/xenopsd/c_stubs/xenctrlext_stubs.c @@ -113,11 +113,14 @@ CAMLprim value stub_xenctrlext_get_runstate_info(value xch_val, value domid) CAMLparam2(xch_val, domid); #if defined(XENCTRL_HAS_GET_RUNSTATE_INFO) CAMLlocal1(result); - xc_runstate_info_t info; + xc_runstate_info_t info = { 0 }; int retval; xc_interface *xch = xch_of_val(xch_val); + uint32_t c_domid = Int_val(domid); - retval = xc_get_runstate_info(xch, Int_val(domid), &info); + caml_release_runtime_system(); + retval = xc_get_runstate_info(xch, c_domid, &info); + caml_acquire_runtime_system(); if (retval < 0) failwith_xc(xch); @@ -126,8 +129,9 @@ CAMLprim value stub_xenctrlext_get_runstate_info(value xch_val, value domid) 1 : missed_changes (int32) 2 : state_entry_time (int64) 3-8 : times (int64s) + 9 : runnable (int64) */ - result = caml_alloc_tuple(9); + result = caml_alloc_tuple(10); Store_field(result, 0, caml_copy_int32(info.state)); Store_field(result, 1, caml_copy_int32(info.missed_changes)); Store_field(result, 2, caml_copy_int64(info.state_entry_time)); @@ -137,6 +141,7 @@ CAMLprim value stub_xenctrlext_get_runstate_info(value xch_val, value domid) Store_field(result, 6, caml_copy_int64(info.time[3])); Store_field(result, 7, caml_copy_int64(info.time[4])); Store_field(result, 8, caml_copy_int64(info.time[5])); + Store_field(result, 9, caml_copy_int64(info.runnable)); CAMLreturn(result); #else diff --git a/ocaml/xenopsd/xc/xenctrlext.ml b/ocaml/xenopsd/xc/xenctrlext.ml index 4078ee7b94..11216dcfec 100644 --- a/ocaml/xenopsd/xc/xenctrlext.ml +++ b/ocaml/xenopsd/xc/xenctrlext.ml @@ -63,6 +63,7 @@ type runstateinfo = { ; time3: int64 ; time4: int64 ; time5: int64 + ; runnable: int64 } external domain_get_runstate_info : handle -> int -> runstateinfo diff --git a/ocaml/xenopsd/xc/xenctrlext.mli b/ocaml/xenopsd/xc/xenctrlext.mli index 2199f42c45..7a20947c1f 100644 --- a/ocaml/xenopsd/xc/xenctrlext.mli +++ b/ocaml/xenopsd/xc/xenctrlext.mli @@ -45,6 +45,7 @@ type runstateinfo = { ; time3: int64 ; time4: int64 ; time5: int64 + ; runnable: int64 } external domain_get_runstate_info : handle -> int -> runstateinfo