vmm_stats: allow vmmapi to fail (and report nothing), more convenient for linux code path
This commit is contained in:
parent
51d1dc63dc
commit
66df394d36
|
@ -69,15 +69,15 @@ let fill_descr ctx =
|
|||
match !descr with
|
||||
| [] ->
|
||||
begin match wrap vmmapi_statnames ctx with
|
||||
| None -> Error (`Msg "vmmapi_statnames failed, shouldn't happen")
|
||||
| None ->
|
||||
Logs.err (fun m -> m "vmmapi_statnames failed, shouldn't happen") ;
|
||||
()
|
||||
| Some d ->
|
||||
Logs.info (fun m -> m "descr are %a" Fmt.(list ~sep:(unit ",@ ") string) d) ;
|
||||
descr := d ;
|
||||
Ok ()
|
||||
descr := d
|
||||
end
|
||||
| ds ->
|
||||
Logs.info (fun m -> m "descr are already %a" Fmt.(list ~sep:(unit ",@ ") string) ds) ;
|
||||
Ok ()
|
||||
Logs.info (fun m -> m "descr are already %a" Fmt.(list ~sep:(unit ",@ ") string) ds)
|
||||
|
||||
let add_pid t pid nics =
|
||||
let name = "ukvm" ^ string_of_int pid in
|
||||
|
@ -85,9 +85,7 @@ let add_pid t pid nics =
|
|||
| None, _ -> Error (`Msg "sysctl ifcount failed")
|
||||
| _, None -> Error (`Msg "vmmapi_open failed")
|
||||
| Some max_nic, Some vmctx ->
|
||||
match fill_descr vmctx with
|
||||
| Error e -> Error e
|
||||
| Ok () ->
|
||||
fill_descr vmctx ;
|
||||
let rec go cnt acc id =
|
||||
if id > 0 && cnt > 0 then
|
||||
match wrap sysctl_ifdata id with
|
||||
|
@ -105,7 +103,11 @@ let stats t pid =
|
|||
try
|
||||
let _, nics = IM.find pid t.pid_nic
|
||||
and ru = IM.find pid t.pid_rusage
|
||||
and vmm = IM.find pid t.pid_vmmapi
|
||||
and vmm =
|
||||
try IM.find pid t.pid_vmmapi with
|
||||
| Not_found ->
|
||||
Logs.err (fun m -> m "failed to find vmm stats for %d" pid);
|
||||
[]
|
||||
in
|
||||
match
|
||||
List.fold_left (fun acc nic ->
|
||||
|
|
|
@ -213,12 +213,12 @@ CAMLprim value vmmanage_sysctl_ifdata (value num) {
|
|||
|
||||
CAMLprim value vmmanage_vmmapi_open (value name) {
|
||||
CAMLparam1(name);
|
||||
uerror("vmmapi_open", Nothing);
|
||||
CAMLreturn(Val_int(0));
|
||||
}
|
||||
|
||||
CAMLprim value vmmanage_vmmapi_close (value name) {
|
||||
CAMLparam1(name);
|
||||
uerror("vmmapi_close", Nothing);
|
||||
CAMLreturn(Val_unit);
|
||||
}
|
||||
|
||||
CAMLprim value vmmanage_vmmapi_stats (value name) {
|
||||
|
|
Loading…
Reference in a new issue