Skip to content

Commit 96f8ba9

Browse files
committed
CA-408492: Add back receive_finalize2
Similar to receive_start2 Signed-off-by: Vincent Liu <[email protected]>
1 parent 1b57d09 commit 96f8ba9

File tree

8 files changed

+47
-10
lines changed

8 files changed

+47
-10
lines changed

ocaml/xapi-idl/storage/storage_interface.ml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,15 @@ module StorageAPI (R : RPC) = struct
11681168
declare "DATA.MIRROR.receive_finalize" []
11691169
(dbg_p @-> id_p @-> returning unit_p err)
11701170

1171+
(** Called on the receiving end
1172+
@deprecated This function is deprecated, and is only here to keep backward
1173+
compatibility with old xapis that call Remote.DATA.MIRROR.receive_finalize
1174+
during SXM. Use the receive_finalize3 function instead.
1175+
*)
1176+
let receive_finalize2 =
1177+
declare "DATA.MIRROR.receive_finalize2" []
1178+
(dbg_p @-> id_p @-> returning unit_p err)
1179+
11711180
(** [receive_finalize3 dbg id] will stop the mirroring process and compose
11721181
the snapshot VDI with the mirror VDI. It also cleans up the storage resources
11731182
used by mirroring. It is called after the the source VM is paused. This fucntion
@@ -1316,6 +1325,8 @@ module type MIRROR = sig
13161325

13171326
val receive_finalize : context -> dbg:debug_info -> id:Mirror.id -> unit
13181327

1328+
val receive_finalize2 : context -> dbg:debug_info -> id:Mirror.id -> unit
1329+
13191330
val receive_finalize3 :
13201331
context
13211332
-> dbg:debug_info
@@ -1817,6 +1828,9 @@ module Server (Impl : Server_impl) () = struct
18171828
S.DATA.MIRROR.receive_finalize (fun dbg id ->
18181829
Impl.DATA.MIRROR.receive_finalize () ~dbg ~id
18191830
) ;
1831+
S.DATA.MIRROR.receive_finalize2 (fun dbg id ->
1832+
Impl.DATA.MIRROR.receive_finalize2 () ~dbg ~id
1833+
) ;
18201834
S.DATA.MIRROR.receive_finalize3 (fun dbg mirror_id sr url verify_dest ->
18211835
Impl.DATA.MIRROR.receive_finalize3 () ~dbg ~mirror_id ~sr ~url
18221836
~verify_dest

ocaml/xapi-idl/storage/storage_skeleton.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ module DATA = struct
178178

179179
let receive_finalize ctx ~dbg ~id = u "DATA.MIRROR.receive_finalize"
180180

181+
let receive_finalize2 ctx ~dbg ~id = u "DATA.MIRROR.receive_finalize2"
182+
181183
let receive_finalize3 ctx ~dbg ~mirror_id ~sr ~url ~verify_dest =
182184
u "DATA.MIRROR.receive_finalize3"
183185

ocaml/xapi-storage-script/main.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,6 +1925,7 @@ let bind ~volume_script_dir =
19251925
S.DATA.MIRROR.receive_start2 (u "DATA.MIRROR.receive_start2") ;
19261926
S.DATA.MIRROR.receive_start3 (u "DATA.MIRROR.receive_start3") ;
19271927
S.DATA.MIRROR.receive_finalize (u "DATA.MIRROR.receive_finalize") ;
1928+
S.DATA.MIRROR.receive_finalize2 (u "DATA.MIRROR.receive_finalize2") ;
19281929
S.DATA.MIRROR.receive_finalize3 (u "DATA.MIRROR.receive_finalize3") ;
19291930
S.DATA.MIRROR.receive_cancel (u "DATA.MIRROR.receive_cancel") ;
19301931
S.DATA.MIRROR.receive_cancel2 (u "DATA.MIRROR.receive_cancel2") ;

ocaml/xapi/storage_mux.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,11 @@ module Mux = struct
861861
info "%s dbg: %s mirror_id: %s" __FUNCTION__ dbg id ;
862862
Storage_smapiv1_migrate.MIRROR.receive_finalize () ~dbg:di.log ~id
863863

864+
let receive_finalize2 () ~dbg ~id =
865+
with_dbg ~name:"DATA.MIRROR.receive_finalize2" ~dbg @@ fun di ->
866+
info "%s dbg: %s mirror_id: %s" __FUNCTION__ dbg id ;
867+
Storage_smapiv1_migrate.MIRROR.receive_finalize2 () ~dbg:di.log ~id
868+
864869
let receive_finalize3 () ~dbg:_ ~mirror_id:_ ~sr:_ ~url:_ ~verify_dest:_ =
865870
u __FUNCTION__
866871

ocaml/xapi/storage_smapiv1.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,8 @@ module SMAPIv1 : Server_impl = struct
11531153

11541154
let receive_finalize _context ~dbg:_ ~id:_ = assert false
11551155

1156+
let receive_finalize2 _context ~dbg:_ ~id:_ = assert false
1157+
11561158
let receive_finalize3 _context ~dbg:_ ~mirror_id:_ ~sr:_ ~url:_
11571159
~verify_dest:_ =
11581160
assert false

ocaml/xapi/storage_smapiv1_migrate.ml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -749,12 +749,7 @@ module MIRROR : SMAPIv2_MIRROR = struct
749749
Option.iter (fun r -> Local.DP.destroy dbg r.leaf_dp false) recv_state ;
750750
State.remove_receive_mirror id
751751

752-
let receive_finalize3 _ctx ~dbg ~mirror_id ~sr ~url ~verify_dest =
753-
D.debug "%s dbg:%s id: %s sr: %s url: %s verify_dest: %B" __FUNCTION__ dbg
754-
mirror_id (s_of_sr sr) url verify_dest ;
755-
let (module Remote) =
756-
Storage_migrate_helper.get_remote_backend url verify_dest
757-
in
752+
let receive_finalize_common ~dbg ~mirror_id (module SMAPI : SMAPIv2) =
758753
let recv_state = State.find_active_receive_mirror mirror_id in
759754
let open State.Receive_state in
760755
Option.iter
@@ -764,16 +759,28 @@ module MIRROR : SMAPIv2_MIRROR = struct
764759
__FUNCTION__ (Sr.string_of r.sr)
765760
(Vdi.string_of r.parent_vdi)
766761
(Vdi.string_of r.leaf_vdi) ;
767-
Remote.DP.destroy2 dbg r.leaf_dp r.sr r.leaf_vdi r.mirror_vm false ;
768-
Remote.VDI.compose dbg r.sr r.parent_vdi r.leaf_vdi ;
762+
SMAPI.DP.destroy2 dbg r.leaf_dp r.sr r.leaf_vdi r.mirror_vm false ;
763+
SMAPI.VDI.compose dbg r.sr r.parent_vdi r.leaf_vdi ;
769764
(* On SMAPIv3, compose would have removed the now invalid dummy vdi, so
770765
there is no need to destroy it anymore, while this is necessary on SMAPIv1 SRs. *)
771-
D.log_and_ignore_exn (fun () -> Remote.VDI.destroy dbg r.sr r.dummy_vdi) ;
772-
Remote.VDI.remove_from_sm_config dbg r.sr r.leaf_vdi "base_mirror"
766+
D.log_and_ignore_exn (fun () -> SMAPI.VDI.destroy dbg r.sr r.dummy_vdi) ;
767+
SMAPI.VDI.remove_from_sm_config dbg r.sr r.leaf_vdi "base_mirror"
773768
)
774769
recv_state ;
775770
State.remove_receive_mirror mirror_id
776771

772+
let receive_finalize2 _ctx ~dbg ~id =
773+
D.debug "%s dbg:%s id: %s" __FUNCTION__ dbg id ;
774+
receive_finalize_common ~dbg ~mirror_id:id (module Local)
775+
776+
let receive_finalize3 _ctx ~dbg ~mirror_id ~sr ~url ~verify_dest =
777+
D.debug "%s dbg:%s id: %s sr: %s url: %s verify_dest: %B" __FUNCTION__ dbg
778+
mirror_id (s_of_sr sr) url verify_dest ;
779+
let (module Remote) =
780+
Storage_migrate_helper.get_remote_backend url verify_dest
781+
in
782+
receive_finalize_common ~dbg ~mirror_id (module Remote)
783+
777784
let receive_cancel _ctx ~dbg ~id =
778785
D.debug "%s dbg:%s mirror_id:%s" __FUNCTION__ dbg id ;
779786
let receive_state = State.find_active_receive_mirror id in

ocaml/xapi/storage_smapiv1_wrapper.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,10 @@ functor
12181218
info "DATA.MIRROR.receive_finalize dbg:%s id:%s" dbg id ;
12191219
Impl.DATA.MIRROR.receive_finalize context ~dbg ~id
12201220

1221+
let receive_finalize2 context ~dbg ~id =
1222+
info "DATA.MIRROR.receive_finalize2 dbg:%s id:%s" dbg id ;
1223+
Impl.DATA.MIRROR.receive_finalize2 context ~dbg ~id
1224+
12211225
let receive_finalize3 _context ~dbg:_ ~mirror_id:_ ~sr:_ ~url:_
12221226
~verify_dest:_ =
12231227
(* see storage_smapiv{1,3}_migrate *)

ocaml/xapi/storage_smapiv3_migrate.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ module MIRROR : SMAPIv2_MIRROR = struct
3535

3636
let receive_finalize _ctx = u __FUNCTION__
3737

38+
let receive_finalize2 _ctx = u __FUNCTION__
39+
3840
let receive_finalize3 _ctx = u __FUNCTION__
3941

4042
let receive_cancel _ctx = u __FUNCTION__

0 commit comments

Comments
 (0)