Skip to content

Commit 9549173

Browse files
committed
CP-54072: Define new MIRROR.send_start function
The `send_start` function is a subroutine inside the `Storage_migrate.start` function, which takes the mirror prepared by the `receive_start` and initiates mirroring to the remote VDI. This commit only defines the interface, which means this function is currently unused. Signed-off-by: Vincent Liu <shuntian.liu2@cloud.com>
1 parent a5bd8f0 commit 9549173

6 files changed

Lines changed: 99 additions & 0 deletions

File tree

ocaml/xapi-idl/storage/storage_interface.ml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,8 +1027,43 @@ module StorageAPI (R : RPC) = struct
10271027
)
10281028

10291029
module MIRROR = struct
1030+
let mirror_vm_p = Param.mk ~name:"mirror_vm" Vm.t
1031+
1032+
let copy_vm_p = Param.mk ~name:"copy_vm" Vm.t
1033+
1034+
let live_vm_p = Param.mk ~name:"live_vm" Vm.t
1035+
10301036
let id_p = Param.mk ~name:"id" Mirror.id
10311037

1038+
(** [send_start dbg dp task src_sr vdi mirror_vm mirror_id local_vdi copy_vm
1039+
live_vm url remote_mirror dest_sr verify_dest]
1040+
takes the remote mirror [remote_mirror] prepared by the destination host
1041+
and initiates the mirroring of [vdi] from the source *)
1042+
let send_start =
1043+
let recv_result_p =
1044+
Param.mk ~name:"recv_result" Mirror.mirror_receive_result
1045+
in
1046+
let local_vdi_p = Param.mk ~name:"local_vdi" vdi_info in
1047+
let src_sr_p = Param.mk ~name:"src_sr" Sr.t in
1048+
let dest_sr_p = Param.mk ~name:"dest_sr" Sr.t in
1049+
declare "DATA.MIRROR.send_start" []
1050+
(dbg_p
1051+
@-> dp_p
1052+
@-> task_id_p
1053+
@-> src_sr_p
1054+
@-> vdi_p
1055+
@-> mirror_vm_p
1056+
@-> id_p
1057+
@-> local_vdi_p
1058+
@-> copy_vm_p
1059+
@-> live_vm_p
1060+
@-> url_p
1061+
@-> recv_result_p
1062+
@-> dest_sr_p
1063+
@-> verify_dest_p
1064+
@-> returning unit_p err
1065+
)
1066+
10321067
(** Called on the receiving end
10331068
@deprecated This function is deprecated, and is only here to keep backward
10341069
compatibility with old xapis that call Remote.DATA.MIRROR.receive_start during SXM.
@@ -1130,6 +1165,24 @@ end
11301165
module type MIRROR = sig
11311166
type context = unit
11321167

1168+
val send_start :
1169+
context
1170+
-> dbg:debug_info
1171+
-> task_id:Task.id
1172+
-> dp:dp
1173+
-> sr:sr
1174+
-> vdi:vdi
1175+
-> mirror_vm:vm
1176+
-> mirror_id:Mirror.id
1177+
-> local_vdi:vdi_info
1178+
-> copy_vm:vm
1179+
-> live_vm:vm
1180+
-> url:string
1181+
-> remote_mirror:Mirror.mirror_receive_result
1182+
-> dest_sr:sr
1183+
-> verify_dest:bool
1184+
-> unit
1185+
11331186
val receive_start :
11341187
context
11351188
-> dbg:debug_info
@@ -1586,6 +1639,27 @@ module Server (Impl : Server_impl) () = struct
15861639
S.DATA.copy (fun dbg sr vdi vm url dest verify_dest ->
15871640
Impl.DATA.copy () ~dbg ~sr ~vdi ~vm ~url ~dest ~verify_dest
15881641
) ;
1642+
S.DATA.MIRROR.send_start
1643+
(fun
1644+
dbg
1645+
task_id
1646+
dp
1647+
sr
1648+
vdi
1649+
mirror_vm
1650+
mirror_id
1651+
local_vdi
1652+
copy_vm
1653+
live_vm
1654+
url
1655+
remote_mirror
1656+
dest_sr
1657+
verify_dest
1658+
->
1659+
Impl.DATA.MIRROR.send_start () ~dbg ~task_id ~dp ~sr ~vdi ~mirror_vm
1660+
~mirror_id ~local_vdi ~copy_vm ~live_vm ~url ~remote_mirror ~dest_sr
1661+
~verify_dest
1662+
) ;
15891663
S.DATA.MIRROR.receive_start (fun dbg sr vdi_info id similar ->
15901664
Impl.DATA.MIRROR.receive_start () ~dbg ~sr ~vdi_info ~id ~similar
15911665
) ;

ocaml/xapi-idl/storage/storage_skeleton.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ module DATA = struct
162162
module MIRROR = struct
163163
type context = unit
164164

165+
let send_start ctx ~dbg ~task_id ~dp ~sr ~vdi ~mirror_vm ~mirror_id
166+
~local_vdi ~copy_vm ~live_vm ~url ~remote_mirror ~dest_sr ~verify_dest =
167+
u "DATA.MIRROR.send_start"
168+
165169
let receive_start ctx ~dbg ~sr ~vdi_info ~id ~similar =
166170
u "DATA.MIRROR.receive_start"
167171

ocaml/xapi-storage-script/main.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,6 +1920,7 @@ let bind ~volume_script_dir =
19201920
S.VDI.similar_content (u "VDI.similar_content") ;
19211921
S.DATA.copy (u "DATA.copy") ;
19221922
S.DP.stat_vdi (u "DP.stat_vdi") ;
1923+
S.DATA.MIRROR.send_start (u "DATA.MIRROR.send_start") ;
19231924
S.DATA.MIRROR.receive_start (u "DATA.MIRROR.receive_start") ;
19241925
S.DATA.MIRROR.receive_start2 (u "DATA.MIRROR.receive_start2") ;
19251926
S.DATA.MIRROR.receive_finalize (u "DATA.MIRROR.receive_finalize") ;

ocaml/xapi/storage_mux.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,13 @@ module Mux = struct
760760
module MIRROR = struct
761761
type context = unit
762762

763+
let u x = raise Storage_interface.(Storage_error (Errors.Unimplemented x))
764+
765+
let send_start _ctx ~dbg:_ ~task_id:_ ~dp:_ ~sr:_ ~vdi:_ ~mirror_vm:_
766+
~mirror_id:_ ~local_vdi:_ ~copy_vm:_ ~live_vm:_ ~url:_
767+
~remote_mirror:_ ~dest_sr:_ ~verify_dest:_ =
768+
u "DATA.MIRROR.send_start" (* see storage_smapi{v1,v3}_migrate.ml *)
769+
763770
let receive_start () ~dbg ~sr ~vdi_info ~id ~similar =
764771
with_dbg ~name:"DATA.MIRROR.receive_start" ~dbg @@ fun di ->
765772
info "%s dbg: %s sr: %s vdi_info: %s mirror_id: %s similar: %s"

ocaml/xapi/storage_smapiv1.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,11 @@ module SMAPIv1 : Server_impl = struct
12191219
module MIRROR = struct
12201220
type context = unit
12211221

1222+
let send_start _ctx ~dbg:_ ~task_id:_ ~dp:_ ~sr:_ ~vdi:_ ~mirror_vm:_
1223+
~mirror_id:_ ~local_vdi:_ ~copy_vm:_ ~live_vm:_ ~url:_
1224+
~remote_mirror:_ ~dest_sr:_ ~verify_dest:_ =
1225+
assert false
1226+
12221227
let receive_start _context ~dbg:_ ~sr:_ ~vdi_info:_ ~id:_ ~similar:_ =
12231228
assert false
12241229

ocaml/xapi/storage_smapiv1_wrapper.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,14 @@ functor
11861186
module MIRROR = struct
11871187
type context = unit
11881188

1189+
let u x =
1190+
raise Storage_interface.(Storage_error (Errors.Unimplemented x))
1191+
1192+
let send_start _ctx ~dbg:_ ~task_id:_ ~dp:_ ~sr:_ ~vdi:_ ~mirror_vm:_
1193+
~mirror_id:_ ~local_vdi:_ ~copy_vm:_ ~live_vm:_ ~url:_
1194+
~remote_mirror:_ ~dest_sr:_ ~verify_dest:_ =
1195+
u "DATA.MIRROR.send_start"
1196+
11891197
let receive_start context ~dbg ~sr ~vdi_info ~id ~similar =
11901198
info "DATA.MIRROR.receive_start dbg:%s sr:%s id:%s similar:[%s]" dbg
11911199
(s_of_sr sr) id

0 commit comments

Comments
 (0)