Skip to content

Commit

Permalink
IH-728: Refactor tracing logic
Browse files Browse the repository at this point in the history
Previously a task was constructed based on the log and tracing of a dbg
of the type Debug_info.t, and then later on a dbg is constructed based
on the previously constructued task. Instead of that, just convert the
first dbg into a string and thread it through the call.

Signed-off-by: Vincent Liu <[email protected]>
  • Loading branch information
Vincent-lau committed Oct 25, 2024
1 parent 00257c2 commit 5cc0fa3
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions ocaml/xapi/storage_migrate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,6 @@ let add_to_sm_config vdi_info key value =
let vdi_info = remove_from_sm_config vdi_info key in
{vdi_info with sm_config= (key, value) :: vdi_info.sm_config}

let dbg_and_tracing_of_task task =
Debug_info.make
~log:(Storage_task.get_dbg task)
~tracing:(Storage_task.tracing task)
|> Debug_info.to_string

(** This module [MigrateLocal] consists of the concrete implementations of the
migration part of SMAPI. Functions inside this module are sender driven, which means
they tend to be executed on the sender side. although there is not a hard rule
Expand Down Expand Up @@ -716,7 +710,7 @@ module MigrateLocal = struct
| e ->
raise (Storage_error (Internal_error (Printexc.to_string e)))

let start ~task ~dbg:_ ~sr ~vdi ~dp ~url ~dest ~verify_dest =
let start ~task ~dbg ~sr ~vdi ~dp ~url ~dest ~verify_dest =
SXM.info "%s sr:%s vdi:%s url:%s dest:%s verify_dest:%B" __FUNCTION__
(Storage_interface.Sr.string_of sr)
(Storage_interface.Vdi.string_of vdi)
Expand All @@ -730,7 +724,6 @@ module MigrateLocal = struct
(Storage_utils.connection_args_of_uri ~verify_dest url)
end)) in
(* Find the local VDI *)
let dbg = dbg_and_tracing_of_task task in
let vdis = Local.SR.scan dbg sr in
let local_vdi =
try List.find (fun x -> x.vdi = vdi) vdis
Expand Down Expand Up @@ -1383,14 +1376,14 @@ let with_task_and_thread ~dbg f =

let copy ~dbg ~sr ~vdi ~url ~dest ~verify_dest =
with_task_and_thread ~dbg (fun task ->
MigrateLocal.copy_into_sr ~task ~dbg:dbg.Debug_info.log ~sr ~vdi ~url
~dest ~verify_dest
MigrateLocal.copy_into_sr ~task ~dbg:(Debug_info.to_string dbg) ~sr ~vdi
~url ~dest ~verify_dest
)

let start ~dbg ~sr ~vdi ~dp ~url ~dest ~verify_dest =
with_task_and_thread ~dbg (fun task ->
MigrateLocal.start ~task ~dbg:dbg.Debug_info.log ~sr ~vdi ~dp ~url ~dest
~verify_dest
MigrateLocal.start ~task ~dbg:(Debug_info.to_string dbg) ~sr ~vdi ~dp ~url
~dest ~verify_dest
)

(* XXX: PR-1255: copy the xenopsd 'raise Exception' pattern *)
Expand Down

0 comments on commit 5cc0fa3

Please sign in to comment.