Skip to content

Commit 3f0e977

Browse files
committed
xenguestHelper: Don't dump errors on End_of_file
non_debug_receive will dump an error after reading the last bits of the header, which is expected and handled by the caller appropriately: ``` xenopsd-xc: [error||67 |Async.VM.resume R:beac7be348f1|xenguesthelper] Memory F 6019464 KiB S 0 KiB T 8183 MiB <--- dumping error xenopsd-xc: [debug||67 |Async.VM.resume R:beac7be348f1|mig64] Finished emu-manager result processing <---- End_of_file expected and handled ``` Don't pollute the logs and instead just log the same info with 'debug' when the error is End_of_file. Signed-off-by: Andrii Sultanov <[email protected]>
1 parent a4b992c commit 3f0e977

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

ocaml/xenopsd/xc/xenguestHelper.ml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,14 @@ let rec non_debug_receive ?(debug_callback = fun s -> debug "%s" s) cnx =
200200
201201
(* Dump memory statistics on failure *)
202202
let non_debug_receive ?debug_callback cnx =
203-
let debug_memory () =
203+
let debug_memory log_type =
204204
Xenctrl.with_intf (fun xc ->
205205
let open Memory in
206206
let open Int64 in
207207
let open Xenctrl in
208208
let p = Xenctrl.physinfo xc in
209-
error "Memory F %Ld KiB S %Ld KiB T %Ld MiB"
209+
(match log_type with Syslog.Debug -> debug | _ -> error)
210+
"Memory F %Ld KiB S %Ld KiB T %Ld MiB"
210211
(p.free_pages |> of_nativeint |> kib_of_pages)
211212
(p.scrub_pages |> of_nativeint |> kib_of_pages)
212213
(p.total_pages |> of_nativeint |> mib_of_pages_free)
@@ -215,10 +216,18 @@ let non_debug_receive ?debug_callback cnx =
215216
try
216217
match non_debug_receive ?debug_callback cnx with
217218
| Error y as x ->
218-
error "Received: %s" y ; debug_memory () ; x
219+
error "Received: %s" y ; debug_memory Syslog.Err ; x
219220
| x ->
220221
x
221-
with e -> debug_memory () ; raise e
222+
with
223+
| End_of_file as e ->
224+
Unixext.raise_with_preserved_backtrace e (fun () ->
225+
debug_memory Syslog.Debug
226+
)
227+
| e ->
228+
Unixext.raise_with_preserved_backtrace e (fun () ->
229+
debug_memory Syslog.Err
230+
)
222231
223232
(** For the simple case where we just want the successful result, return it. If
224233
we get an error message (or suspend) then throw an exception. *)

0 commit comments

Comments
 (0)