vmm_stats: don't attempt to open vmctx in add_pid, only in gather
This commit is contained in:
parent
15e1f5ecf6
commit
f64583c74c
|
@ -52,12 +52,9 @@ let remove_vmid t vmid =
|
||||||
| None -> Logs.warn (fun m -> m "no pid found for %a" Vmm_core.Name.pp vmid) ; t
|
| None -> Logs.warn (fun m -> m "no pid found for %a" Vmm_core.Name.pp vmid) ; t
|
||||||
| Some pid ->
|
| Some pid ->
|
||||||
Logs.info (fun m -> m "removing pid %d" pid) ;
|
Logs.info (fun m -> m "removing pid %d" pid) ;
|
||||||
(try
|
(match IM.find_opt pid t.pid_nic with
|
||||||
match IM.find pid t.pid_nic with
|
| Some (Ok vmctx, _, _) -> ignore (wrap vmmapi_close vmctx)
|
||||||
| Ok vmctx, _, _ -> ignore (wrap vmmapi_close vmctx)
|
| _ -> ()) ;
|
||||||
| Error _, _, _ -> ()
|
|
||||||
with
|
|
||||||
_ -> ()) ;
|
|
||||||
let pid_nic = IM.remove pid t.pid_nic
|
let pid_nic = IM.remove pid t.pid_nic
|
||||||
and vmid_pid = Vmm_trie.remove vmid t.vmid_pid
|
and vmid_pid = Vmm_trie.remove vmid t.vmid_pid
|
||||||
in
|
in
|
||||||
|
@ -76,7 +73,7 @@ let fill_descr ctx =
|
||||||
end
|
end
|
||||||
| ds -> Logs.debug (fun m -> m "%d descr are already present" (List.length ds))
|
| ds -> Logs.debug (fun m -> m "%d descr are already present" (List.length ds))
|
||||||
|
|
||||||
let open_vmmapi ?(retries = 4) name =
|
let open_vmmapi ~retries name =
|
||||||
if retries = 0 then begin
|
if retries = 0 then begin
|
||||||
Logs.debug (fun m -> m "(ignored 0) vmmapi_open failed for %s" name) ;
|
Logs.debug (fun m -> m "(ignored 0) vmmapi_open failed for %s" name) ;
|
||||||
Error 0
|
Error 0
|
||||||
|
@ -112,7 +109,7 @@ let gather pid vmctx nics =
|
||||||
| None ->
|
| None ->
|
||||||
Logs.warn (fun m -> m "failed to get ifdata for %s" nname) ;
|
Logs.warn (fun m -> m "failed to get ifdata for %s" nname) ;
|
||||||
ifd
|
ifd
|
||||||
| Some data -> { data with bridge }::ifd)
|
| Some data -> { data with Stats.bridge }::ifd)
|
||||||
[] nics
|
[] nics
|
||||||
|
|
||||||
let tick t =
|
let tick t =
|
||||||
|
@ -171,10 +168,8 @@ let add_pid t vmid vmmdev pid nics =
|
||||||
List.rev acc
|
List.rev acc
|
||||||
in
|
in
|
||||||
Ok (go (List.length nics) [] max_nic) >>= fun nic_ids ->
|
Ok (go (List.length nics) [] max_nic) >>= fun nic_ids ->
|
||||||
let vmctx = open_vmmapi vmmdev in
|
Logs.info (fun m -> m "adding %a %d %a" Name.pp vmid pid pp_nics nics) ;
|
||||||
Logs.info (fun m -> m "adding %d %a with vmctx %b" pid pp_nics nics
|
let pid_nic = IM.add pid (Error 4, vmmdev, nic_ids) t.pid_nic
|
||||||
(match vmctx with Error _ -> false | Ok _ -> true)) ;
|
|
||||||
let pid_nic = IM.add pid (vmctx, vmmdev, nic_ids) t.pid_nic
|
|
||||||
and vmid_pid, ret = Vmm_trie.insert vmid pid t.vmid_pid
|
and vmid_pid, ret = Vmm_trie.insert vmid pid t.vmid_pid
|
||||||
in
|
in
|
||||||
assert (ret = None) ;
|
assert (ret = None) ;
|
||||||
|
|
Loading…
Reference in a new issue