]> xenbits.xensource.com Git - people/aperard/xen-unstable.git/commitdiff
tools/oxenstored: Switch to using the plugin for Xenctrl.domain_getinfo
authorAndrii Sultanov <andrii.sultanov@cloud.com>
Mon, 9 Sep 2024 12:02:42 +0000 (13:02 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 9 Sep 2024 13:59:05 +0000 (14:59 +0100)
Also run 'make format' on the file to reformat an adjacent block of code
correctly.

Signed-off-by: Andrii Sultanov <andrii.sultanov@cloud.com>
Acked-by: Christian Lindig <christian.lindig@cloud.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/ocaml/xenstored/domains.ml

index c2330657114f07720727f1939e137b5e9ef2c466..fabca00e6b03e287b1ff209d835e5d8ace869fd0 100644 (file)
@@ -49,8 +49,8 @@ module Plugin =
 let handle = Plugin.interface_open ()
 
 type domains = {
-  eventchn: Event.t;
-  table: (Xenctrl.domid, Domain.t) Hashtbl.t;
+  eventchn : Event.t;
+  table : (Plugin.domid, Domain.t) Hashtbl.t;
 
   (* N.B. the Queue module is not thread-safe but oxenstored is single-threaded. *)
   (* Domains queue up to regain conflict-credit; we have a queue for
@@ -121,30 +121,29 @@ let cleanup doms =
   let notify = ref false in
   let dead_dom = ref [] in
 
-  Hashtbl.iter (fun id _ -> if id <> 0 then
-                   try
-                     let info = Xenctrl.domain_getinfo xc id in
-                     if info.Xenctrl.shutdown || info.Xenctrl.dying then (
-                       debug "Domain %u died (dying=%b, shutdown %b -- code %d)"
-                         id info.Xenctrl.dying info.Xenctrl.shutdown info.Xenctrl.shutdown_code;
-                       if info.Xenctrl.dying then
-                         dead_dom := id :: !dead_dom
-                       else
-                         notify := true;
-                     )
-                   with Xenctrl.Error _ ->
-                     debug "Domain %u died -- no domain info" id;
-                     dead_dom := id :: !dead_dom;
-               ) doms.table;
-  List.iter (fun id ->
-      let dom = Hashtbl.find doms.table id in
-      Domain.close dom;
-      Hashtbl.remove doms.table id;
-      if dom.Domain.conflict_credit <= !Define.conflict_burst_limit
-      then (
-        remove_from_queue dom doms.doms_with_conflict_penalty;
-        if (dom.Domain.conflict_credit <= 0.) then remove_from_queue dom doms.doms_conflict_paused
-      )
+  Hashtbl.iter
+    (fun id _ ->
+       if id <> 0 then (
+         try
+           let info = Plugin.domain_getinfo handle id in
+           if info.Plugin.shutdown || info.Plugin.dying then (
+             debug "Domain %u died (dying=%b, shutdown %b -- code %d)" id
+               info.Plugin.dying info.Plugin.shutdown info.Plugin.shutdown_code;
+             if info.Plugin.dying then dead_dom := id :: !dead_dom else notify := true)
+         with Plugin.Error _ ->
+           debug "Domain %u died -- no domain info" id;
+           dead_dom := id :: !dead_dom))
+    doms.table;
+  List.iter
+    (fun id ->
+       let dom = Hashtbl.find doms.table id in
+       Domain.close dom;
+       Hashtbl.remove doms.table id;
+       if dom.Domain.conflict_credit <= !Define.conflict_burst_limit
+       then (
+         remove_from_queue dom doms.doms_with_conflict_penalty;
+         if (dom.Domain.conflict_credit <= 0.) then remove_from_queue dom doms.doms_conflict_paused
+       )
     ) !dead_dom;
   !notify, !dead_dom