Skip to content

Commit 3b34ea1

Browse files
authored
CA-408492: Add back receive_start2 for backwards compat (#6464)
This otherwise breaks migration from xapi-25.3.0 -- xapi-25.17.0 to newer versions of xapi (25.18.0)
2 parents ddea018 + 84b096a commit 3b34ea1

9 files changed

+87
-16
lines changed

ocaml/xapi-idl/storage/storage_interface.ml

+38-7
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ module StorageAPI (R : RPC) = struct
11101110
(** Called on the receiving end
11111111
@deprecated This function is deprecated, and is only here to keep backward
11121112
compatibility with old xapis that call Remote.DATA.MIRROR.receive_start during SXM.
1113-
Use the receive_start2 function instead.
1113+
Use the receive_start3 function instead.
11141114
*)
11151115
let receive_start =
11161116
let similar_p = Param.mk ~name:"similar" Mirror.similars in
@@ -1124,12 +1124,30 @@ module StorageAPI (R : RPC) = struct
11241124
@-> returning result err
11251125
)
11261126

1127-
(** Called on the receiving end to prepare for receipt of the storage. This
1128-
function should be used in conjunction with [receive_finalize2]*)
1127+
(** Called on the receiving end
1128+
@deprecated This function is deprecated, and is only here to keep backward
1129+
compatibility with old xapis that call Remote.DATA.MIRROR.receive_start2 during SXM.
1130+
Use the receive_start3 function instead.
1131+
*)
11291132
let receive_start2 =
11301133
let similar_p = Param.mk ~name:"similar" Mirror.similars in
11311134
let result = Param.mk ~name:"result" Mirror.mirror_receive_result in
11321135
declare "DATA.MIRROR.receive_start2" []
1136+
(dbg_p
1137+
@-> sr_p
1138+
@-> VDI.vdi_info_p
1139+
@-> id_p
1140+
@-> similar_p
1141+
@-> vm_p
1142+
@-> returning result err
1143+
)
1144+
1145+
(** Called on the receiving end to prepare for receipt of the storage. This
1146+
function should be used in conjunction with [receive_finalize2]*)
1147+
let receive_start3 =
1148+
let similar_p = Param.mk ~name:"similar" Mirror.similars in
1149+
let result = Param.mk ~name:"result" Mirror.mirror_receive_result in
1150+
declare "DATA.MIRROR.receive_start3" []
11331151
(dbg_p
11341152
@-> sr_p
11351153
@-> VDI.vdi_info_p
@@ -1153,7 +1171,7 @@ module StorageAPI (R : RPC) = struct
11531171
(** [receive_finalize2 dbg id] will stop the mirroring process and compose
11541172
the snapshot VDI with the mirror VDI. It also cleans up the storage resources
11551173
used by mirroring. It is called after the the source VM is paused. This fucntion
1156-
should be used in conjunction with [receive_start2] *)
1174+
should be used in conjunction with [receive_start3] *)
11571175
let receive_finalize2 =
11581176
declare "DATA.MIRROR.receive_finalize2" []
11591177
(dbg_p
@@ -1175,7 +1193,7 @@ module StorageAPI (R : RPC) = struct
11751193
(dbg_p @-> id_p @-> returning unit_p err)
11761194

11771195
(** [receive_cancel2 dbg mirror_id url verify_dest] cleans up the side effects
1178-
done by [receive_start2] on the destination host when the migration fails. *)
1196+
done by [receive_start3] on the destination host when the migration fails. *)
11791197
let receive_cancel2 =
11801198
declare "DATA.MIRROR.receive_cancel2" []
11811199
(dbg_p @-> id_p @-> url_p @-> verify_dest_p @-> returning unit_p err)
@@ -1279,6 +1297,16 @@ module type MIRROR = sig
12791297
-> dbg:debug_info
12801298
-> sr:sr
12811299
-> vdi_info:vdi_info
1300+
-> id:Mirror.id
1301+
-> similar:Mirror.similars
1302+
-> vm:vm
1303+
-> Mirror.mirror_receive_result
1304+
1305+
val receive_start3 :
1306+
context
1307+
-> dbg:debug_info
1308+
-> sr:sr
1309+
-> vdi_info:vdi_info
12821310
-> mirror_id:Mirror.id
12831311
-> similar:Mirror.similars
12841312
-> vm:vm
@@ -1772,9 +1800,12 @@ module Server (Impl : Server_impl) () = struct
17721800
S.DATA.MIRROR.receive_start (fun dbg sr vdi_info id similar ->
17731801
Impl.DATA.MIRROR.receive_start () ~dbg ~sr ~vdi_info ~id ~similar
17741802
) ;
1775-
S.DATA.MIRROR.receive_start2
1803+
S.DATA.MIRROR.receive_start2 (fun dbg sr vdi_info id similar vm ->
1804+
Impl.DATA.MIRROR.receive_start2 () ~dbg ~sr ~vdi_info ~id ~similar ~vm
1805+
) ;
1806+
S.DATA.MIRROR.receive_start3
17761807
(fun dbg sr vdi_info mirror_id similar vm url verify_dest ->
1777-
Impl.DATA.MIRROR.receive_start2 () ~dbg ~sr ~vdi_info ~mirror_id
1808+
Impl.DATA.MIRROR.receive_start3 () ~dbg ~sr ~vdi_info ~mirror_id
17781809
~similar ~vm ~url ~verify_dest
17791810
) ;
17801811
S.DATA.MIRROR.receive_cancel (fun dbg id ->

ocaml/xapi-idl/storage/storage_skeleton.ml

+5-2
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,13 @@ module DATA = struct
169169
let receive_start ctx ~dbg ~sr ~vdi_info ~id ~similar =
170170
u "DATA.MIRROR.receive_start"
171171

172-
let receive_start2 ctx ~dbg ~sr ~vdi_info ~mirror_id ~similar ~vm ~url
173-
~verify_dest =
172+
let receive_start2 ctx ~dbg ~sr ~vdi_info ~id ~similar ~vm =
174173
u "DATA.MIRROR.receive_start2"
175174

175+
let receive_start3 ctx ~dbg ~sr ~vdi_info ~mirror_id ~similar ~vm ~url
176+
~verify_dest =
177+
u "DATA.MIRROR.receive_start3"
178+
176179
let receive_finalize ctx ~dbg ~id = u "DATA.MIRROR.receive_finalize"
177180

178181
let receive_finalize2 ctx ~dbg ~mirror_id ~sr ~url ~verify_dest =

ocaml/xapi-storage-script/main.ml

+1
Original file line numberDiff line numberDiff line change
@@ -1923,6 +1923,7 @@ let bind ~volume_script_dir =
19231923
S.DATA.MIRROR.send_start (u "DATA.MIRROR.send_start") ;
19241924
S.DATA.MIRROR.receive_start (u "DATA.MIRROR.receive_start") ;
19251925
S.DATA.MIRROR.receive_start2 (u "DATA.MIRROR.receive_start2") ;
1926+
S.DATA.MIRROR.receive_start3 (u "DATA.MIRROR.receive_start3") ;
19261927
S.DATA.MIRROR.receive_finalize (u "DATA.MIRROR.receive_finalize") ;
19271928
S.DATA.MIRROR.receive_finalize2 (u "DATA.MIRROR.receive_finalize2") ;
19281929
S.DATA.MIRROR.receive_cancel (u "DATA.MIRROR.receive_cancel") ;

ocaml/xapi/storage_migrate.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ module MigrateLocal = struct
131131
try
132132
let (module Migrate_Backend) = choose_backend dbg sr in
133133
let similars = similar_vdis ~dbg ~sr ~vdi in
134-
Migrate_Backend.receive_start2 () ~dbg ~sr:dest ~vdi_info:local_vdi
134+
Migrate_Backend.receive_start3 () ~dbg ~sr:dest ~vdi_info:local_vdi
135135
~mirror_id ~similar:similars ~vm:mirror_vm ~url ~verify_dest
136136
with e ->
137137
error "%s Caught error %s while preparing for SXM" __FUNCTION__

ocaml/xapi/storage_mux.ml

+16-2
Original file line numberDiff line numberDiff line change
@@ -837,8 +837,22 @@ module Mux = struct
837837
Storage_smapiv1_migrate.MIRROR.receive_start () ~dbg ~sr ~vdi_info ~id
838838
~similar
839839

840-
(** see storage_smapiv{1,3}_migrate.receive_start2 *)
841-
let receive_start2 () ~dbg:_ ~sr:_ ~vdi_info:_ ~mirror_id:_ ~similar:_
840+
let receive_start2 () ~dbg ~sr ~vdi_info ~id ~similar ~vm =
841+
with_dbg ~name:"DATA.MIRROR.receive_start2" ~dbg @@ fun _di ->
842+
info "%s dbg: %s sr: %s vdi_info: %s mirror_id: %s similar: %s vm: %s"
843+
__FUNCTION__ dbg (s_of_sr sr)
844+
(string_of_vdi_info vdi_info)
845+
id
846+
(String.concat ";" similar)
847+
(s_of_vm vm) ;
848+
info "%s dbg:%s" __FUNCTION__ dbg ;
849+
(* This goes straight to storage_smapiv1_migrate for backwards compatability
850+
reasons, new code should not call receive_start any more *)
851+
Storage_smapiv1_migrate.MIRROR.receive_start2 () ~dbg ~sr ~vdi_info ~id
852+
~similar ~vm
853+
854+
(** see storage_smapiv{1,3}_migrate.receive_start3 *)
855+
let receive_start3 () ~dbg:_ ~sr:_ ~vdi_info:_ ~mirror_id:_ ~similar:_
842856
~vm:_ =
843857
u __FUNCTION__
844858

ocaml/xapi/storage_smapiv1.ml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,11 @@ module SMAPIv1 : Server_impl = struct
11431143
let receive_start _context ~dbg:_ ~sr:_ ~vdi_info:_ ~id:_ ~similar:_ =
11441144
assert false
11451145

1146-
let receive_start2 _context ~dbg:_ ~sr:_ ~vdi_info:_ ~mirror_id:_
1146+
let receive_start2 _context ~dbg:_ ~sr:_ ~vdi_info:_ ~id:_ ~similar:_
1147+
~vm:_ =
1148+
assert false
1149+
1150+
let receive_start3 _context ~dbg:_ ~sr:_ ~vdi_info:_ ~mirror_id:_
11471151
~similar:_ ~vm:_ ~url:_ ~verify_dest:_ =
11481152
assert false
11491153

ocaml/xapi/storage_smapiv1_migrate.ml

+8-2
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ module MIRROR : SMAPIv2_MIRROR = struct
680680
(* The state tracking here does not need to be changed, however, it will be
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
683-
receive_start2 is called, this will be stored in memory on the source host.
683+
receive_start3 is called, this will be stored in memory on the source host.
684684
receive_finalize2 and receive_cancel2 handles this similarly. *)
685685
State.add id
686686
State.(
@@ -724,7 +724,13 @@ module MIRROR : SMAPIv2_MIRROR = struct
724724
receive_start_common ~dbg ~sr ~vdi_info ~id ~similar ~vm:(Vm.of_string "0")
725725
(module Local)
726726

727-
let receive_start2 _ctx ~dbg ~sr ~vdi_info ~mirror_id ~similar ~vm ~url
727+
let receive_start2 _ctx ~dbg ~sr ~vdi_info ~id ~similar ~vm =
728+
D.debug "%s dbg: %s sr: %s vdi: %s id: %s" __FUNCTION__ dbg (s_of_sr sr)
729+
(string_of_vdi_info vdi_info)
730+
id ;
731+
receive_start_common ~dbg ~sr ~vdi_info ~id ~similar ~vm (module Local)
732+
733+
let receive_start3 _ctx ~dbg ~sr ~vdi_info ~mirror_id ~similar ~vm ~url
728734
~verify_dest =
729735
D.debug "%s dbg: %s sr: %s vdi: %s id: %s vm: %s url: %s verify_dest: %B"
730736
__FUNCTION__ dbg (s_of_sr sr)

ocaml/xapi/storage_smapiv1_wrapper.ml

+11-1
Original file line numberDiff line numberDiff line change
@@ -1200,8 +1200,18 @@ functor
12001200
(String.concat "," similar) ;
12011201
Impl.DATA.MIRROR.receive_start context ~dbg ~sr ~vdi_info ~id ~similar
12021202

1203-
let receive_start2 _context ~dbg:_ ~sr:_ ~vdi_info:_ ~mirror_id:_
1203+
let receive_start2 context ~dbg ~sr ~vdi_info ~id ~similar ~vm =
1204+
info
1205+
"DATA.MIRROR.receive_start2 dbg:%s sr:%s id:%s similar:[%s] vm:%s"
1206+
dbg (s_of_sr sr) id
1207+
(String.concat "," similar)
1208+
(s_of_vm vm) ;
1209+
Impl.DATA.MIRROR.receive_start2 context ~dbg ~sr ~vdi_info ~id
1210+
~similar ~vm
1211+
1212+
let receive_start3 _context ~dbg:_ ~sr:_ ~vdi_info:_ ~mirror_id:_
12041213
~similar:_ ~vm:_ =
1214+
(* See Storage_smapiv1_migrate.receive_start3 *)
12051215
u __FUNCTION__
12061216

12071217
let receive_finalize context ~dbg ~id =

ocaml/xapi/storage_smapiv3_migrate.ml

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

3232
let receive_start2 _ctx = u __FUNCTION__
3333

34+
let receive_start3 _ctx = u __FUNCTION__
35+
3436
let receive_finalize _ctx = u __FUNCTION__
3537

3638
let receive_finalize2 _ctx = u __FUNCTION__

0 commit comments

Comments
 (0)