Skip to content

Commit 6285222

Browse files
authored
CA-408492: Add back receive_finalize2 as well (#6465)
Sorry guys, forgot about `receive_finalize2` 🤪. I hope there is no more....
2 parents 3b34ea1 + 96f8ba9 commit 6285222

9 files changed

+67
-30
lines changed

ocaml/xapi-idl/storage/storage_interface.ml

+22-8
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ module StorageAPI (R : RPC) = struct
11431143
)
11441144

11451145
(** Called on the receiving end to prepare for receipt of the storage. This
1146-
function should be used in conjunction with [receive_finalize2]*)
1146+
function should be used in conjunction with [receive_finalize3]*)
11471147
let receive_start3 =
11481148
let similar_p = Param.mk ~name:"similar" Mirror.similars in
11491149
let result = Param.mk ~name:"result" Mirror.mirror_receive_result in
@@ -1162,18 +1162,27 @@ module StorageAPI (R : RPC) = struct
11621162
(** Called on the receiving end
11631163
@deprecated This function is deprecated, and is only here to keep backward
11641164
compatibility with old xapis that call Remote.DATA.MIRROR.receive_finalize
1165-
during SXM. Use the receive_finalize2 function instead.
1165+
during SXM. Use the receive_finalize3 function instead.
11661166
*)
11671167
let receive_finalize =
11681168
declare "DATA.MIRROR.receive_finalize" []
11691169
(dbg_p @-> id_p @-> returning unit_p err)
11701170

1171-
(** [receive_finalize2 dbg id] will stop the mirroring process and compose
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+
1180+
(** [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
11741183
should be used in conjunction with [receive_start3] *)
1175-
let receive_finalize2 =
1176-
declare "DATA.MIRROR.receive_finalize2" []
1184+
let receive_finalize3 =
1185+
declare "DATA.MIRROR.receive_finalize3" []
11771186
(dbg_p
11781187
@-> id_p
11791188
@-> sr_p
@@ -1316,7 +1325,9 @@ module type MIRROR = sig
13161325

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

1319-
val receive_finalize2 :
1328+
val receive_finalize2 : context -> dbg:debug_info -> id:Mirror.id -> unit
1329+
1330+
val receive_finalize3 :
13201331
context
13211332
-> dbg:debug_info
13221333
-> mirror_id:Mirror.id
@@ -1817,8 +1828,11 @@ module Server (Impl : Server_impl) () = struct
18171828
S.DATA.MIRROR.receive_finalize (fun dbg id ->
18181829
Impl.DATA.MIRROR.receive_finalize () ~dbg ~id
18191830
) ;
1820-
S.DATA.MIRROR.receive_finalize2 (fun dbg mirror_id sr url verify_dest ->
1821-
Impl.DATA.MIRROR.receive_finalize2 () ~dbg ~mirror_id ~sr ~url
1831+
S.DATA.MIRROR.receive_finalize2 (fun dbg id ->
1832+
Impl.DATA.MIRROR.receive_finalize2 () ~dbg ~id
1833+
) ;
1834+
S.DATA.MIRROR.receive_finalize3 (fun dbg mirror_id sr url verify_dest ->
1835+
Impl.DATA.MIRROR.receive_finalize3 () ~dbg ~mirror_id ~sr ~url
18221836
~verify_dest
18231837
) ;
18241838
S.DATA.MIRROR.pre_deactivate_hook (fun dbg dp sr vdi ->

ocaml/xapi-idl/storage/storage_skeleton.ml

+4-2
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,10 @@ module DATA = struct
178178

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

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

184186
let receive_cancel ctx ~dbg ~id = u "DATA.MIRROR.receive_cancel"
185187

ocaml/xapi-storage-script/main.ml

+1
Original file line numberDiff line numberDiff line change
@@ -1926,6 +1926,7 @@ let bind ~volume_script_dir =
19261926
S.DATA.MIRROR.receive_start3 (u "DATA.MIRROR.receive_start3") ;
19271927
S.DATA.MIRROR.receive_finalize (u "DATA.MIRROR.receive_finalize") ;
19281928
S.DATA.MIRROR.receive_finalize2 (u "DATA.MIRROR.receive_finalize2") ;
1929+
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") ;
19311932
S.DATA.MIRROR.pre_deactivate_hook (u "DATA.MIRROR.pre_deactivate_hook") ;

ocaml/xapi/storage_migrate.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ let choose_backend dbg sr =
4040
(** module [MigrateRemote] is similar to [MigrateLocal], but most of these functions
4141
tend to be executed on the receiver side. *)
4242
module MigrateRemote = struct
43-
(** [receive_finalize2 dbg mirror_id sr url verify_dest] takes an [sr] parameter
43+
(** [receive_finalize3 dbg mirror_id sr url verify_dest] takes an [sr] parameter
4444
which is the source sr and multiplexes based on the type of that *)
45-
let receive_finalize2 ~dbg ~mirror_id ~sr ~url ~verify_dest =
45+
let receive_finalize3 ~dbg ~mirror_id ~sr ~url ~verify_dest =
4646
let (module Migrate_Backend) = choose_backend dbg sr in
47-
Migrate_Backend.receive_finalize2 () ~dbg ~mirror_id ~sr ~url ~verify_dest
47+
Migrate_Backend.receive_finalize3 () ~dbg ~mirror_id ~sr ~url ~verify_dest
4848

4949
let receive_cancel2 ~dbg ~mirror_id ~url ~verify_dest =
5050
let (module Remote) =
@@ -332,12 +332,12 @@ let post_deactivate_hook ~sr ~vdi ~dp:_ =
332332
r.remote_info
333333
in
334334
let (module Remote) = get_remote_backend r.url verify_dest in
335-
debug "Calling receive_finalize2" ;
335+
debug "Calling receive_finalize3" ;
336336
log_and_ignore_exn (fun () ->
337-
MigrateRemote.receive_finalize2 ~dbg:"Mirror-cleanup" ~mirror_id:id
337+
MigrateRemote.receive_finalize3 ~dbg:"Mirror-cleanup" ~mirror_id:id
338338
~sr ~url:r.url ~verify_dest
339339
) ;
340-
debug "Finished calling receive_finalize2" ;
340+
debug "Finished calling receive_finalize3" ;
341341
State.remove_local_mirror id ;
342342
debug "Removed active local mirror: %s" id ;
343343
Option.iter (fun id -> Scheduler.cancel scheduler id) r.watchdog

ocaml/xapi/storage_mux.ml

+6-1
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,12 @@ 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:_ ~mirror_id:_ ~sr:_ ~url:_ ~verify_dest:_ =
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+
869+
let receive_finalize3 () ~dbg:_ ~mirror_id:_ ~sr:_ ~url:_ ~verify_dest:_ =
865870
u __FUNCTION__
866871

867872
let receive_cancel () ~dbg ~id =

ocaml/xapi/storage_smapiv1.ml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,9 @@ module SMAPIv1 : Server_impl = struct
11531153

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

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

ocaml/xapi/storage_smapiv1_migrate.ml

+18-11
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ module MIRROR : SMAPIv2_MIRROR = struct
681681
stored in memory on different hosts. If receive_start is called, by an older
682682
host, this State.add is run on the destination host. On the other hand, if
683683
receive_start3 is called, this will be stored in memory on the source host.
684-
receive_finalize2 and receive_cancel2 handles this similarly. *)
684+
receive_finalize3 and receive_cancel2 handles this similarly. *)
685685
State.add id
686686
State.(
687687
Recv_op
@@ -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_finalize2 _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

+5-1
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,11 @@ 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:_ ~mirror_id:_ ~sr:_ ~url:_
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+
1225+
let receive_finalize3 _context ~dbg:_ ~mirror_id:_ ~sr:_ ~url:_
12221226
~verify_dest:_ =
12231227
(* see storage_smapiv{1,3}_migrate *)
12241228
u __FUNCTION__

ocaml/xapi/storage_smapiv3_migrate.ml

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ module MIRROR : SMAPIv2_MIRROR = struct
3737

3838
let receive_finalize2 _ctx = u __FUNCTION__
3939

40+
let receive_finalize3 _ctx = u __FUNCTION__
41+
4042
let receive_cancel _ctx = u __FUNCTION__
4143

4244
let receive_cancel2 _ctx = u __FUNCTION__

0 commit comments

Comments
 (0)