Skip to content

Commit 7ecda57

Browse files
committed
Bring back DATA.MIRROR.list to storage_mux
Previously this was deleted in commit 1fe6389 as it was not multiplexed, but looks like we still need to keep it in storage_mux because sm-cli needs to make rpc calls to storage_mux when trying to list all the mirrors to make it work properly, due to the fact that the sr plugins are stored in the address space of the xapi process. There are other invocations in sm-cli such as `Storage_migrate.start` which may have similar problems. But I have left them alone as I don't any reasonable way of calling them from the cli. Signed-off-by: Vincent Liu <[email protected]>
1 parent cb805a5 commit 7ecda57

File tree

9 files changed

+26
-1
lines changed

9 files changed

+26
-1
lines changed

ocaml/xapi-idl/storage/storage_interface.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,12 @@ module StorageAPI (R : RPC) = struct
11901190
in
11911191
declare "DATA.MIRROR.is_mirror_failed" []
11921192
(dbg_p @-> id_p @-> sr_p @-> returning mirror_failed_p err)
1193+
1194+
let list =
1195+
let result_p =
1196+
Param.mk ~name:"mirrors" TypeCombinators.(list (pair Mirror.(id, t)))
1197+
in
1198+
declare "DATA.MIRROR.list" [] (dbg_p @-> returning result_p err)
11931199
end
11941200
end
11951201

@@ -1302,6 +1308,8 @@ module type MIRROR = sig
13021308

13031309
val is_mirror_failed :
13041310
context -> dbg:debug_info -> mirror_id:Mirror.id -> sr:Sr.t -> bool
1311+
1312+
val list : context -> dbg:debug_info -> (Mirror.id * Mirror.t) list
13051313
end
13061314

13071315
module type Server_impl = sig
@@ -1782,6 +1790,7 @@ module Server (Impl : Server_impl) () = struct
17821790
S.DATA.MIRROR.is_mirror_failed (fun dbg mirror_id sr ->
17831791
Impl.DATA.MIRROR.is_mirror_failed () ~dbg ~mirror_id ~sr
17841792
) ;
1793+
S.DATA.MIRROR.list (fun dbg -> Impl.DATA.MIRROR.list () ~dbg) ;
17851794
S.DATA.import_activate (fun dbg dp sr vdi vm ->
17861795
Impl.DATA.import_activate () ~dbg ~dp ~sr ~vdi ~vm
17871796
) ;

ocaml/xapi-idl/storage/storage_skeleton.ml

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

189189
let is_mirror_failed ctx ~dbg ~mirror_id ~sr =
190190
u "DATA.MIRROR.is_mirror_failed"
191+
192+
let list ctx ~dbg = u "DATA.MIRROR.list"
191193
end
192194
end
193195

ocaml/xapi-storage-cli/main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ let string_of_file filename =
149149

150150
let mirror_list common_opts =
151151
wrap common_opts (fun () ->
152-
let list = Storage_migrate.list ~dbg in
152+
let list = Client.DATA.MIRROR.list dbg in
153153
List.iter
154154
(fun (id, status) -> Printf.printf "%s" (string_of_mirror id status))
155155
list

ocaml/xapi-storage-script/main.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,7 @@ let bind ~volume_script_dir =
19291929
S.DATA.MIRROR.receive_cancel2 (u "DATA.MIRROR.receive_cancel2") ;
19301930
S.DATA.MIRROR.pre_deactivate_hook (u "DATA.MIRROR.pre_deactivate_hook") ;
19311931
S.DATA.MIRROR.is_mirror_failed (u "DATA.MIRROR.is_mirror_failed") ;
1932+
S.DATA.MIRROR.list (u "DATA.MIRROR.list") ;
19321933
S.DP.create (u "DP.create") ;
19331934
S.TASK.cancel (u "TASK.cancel") ;
19341935
S.TASK.list (u "TASK.list") ;

ocaml/xapi/storage_mux.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,11 @@ module Mux = struct
863863

864864
let is_mirror_failed _ctx ~dbg:_ ~mirror_id:_ ~sr:_ =
865865
u "DATA.MIRROR.is_mirror_failed"
866+
867+
let list () ~dbg =
868+
with_dbg ~name:"DATA.MIRROR.list" ~dbg @@ fun di ->
869+
info "%s dbg: %s" __FUNCTION__ dbg ;
870+
Storage_migrate.list ~dbg:di.log
866871
end
867872
end
868873

ocaml/xapi/storage_smapiv1.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,8 @@ module SMAPIv1 : Server_impl = struct
11611161
let pre_deactivate_hook _context ~dbg:_ ~dp:_ ~sr:_ ~vdi:_ = assert false
11621162

11631163
let is_mirror_failed _context ~dbg:_ ~mirror_id:_ ~sr:_ = assert false
1164+
1165+
let list _context ~dbg:_ = assert false
11641166
end
11651167
end
11661168

ocaml/xapi/storage_smapiv1_migrate.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,4 +825,6 @@ module MIRROR : SMAPIv2_MIRROR = struct
825825
)
826826
| _ ->
827827
false
828+
829+
let list _ctx = u __FUNCTION__
828830
end

ocaml/xapi/storage_smapiv1_wrapper.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,8 @@ functor
12241224
u __FUNCTION__
12251225

12261226
let is_mirror_failed _context ~dbg:_ ~mirror_id:_ ~sr:_ = u __FUNCTION__
1227+
1228+
let list _context ~dbg:_ = u __FUNCTION__
12271229
end
12281230
end
12291231

ocaml/xapi/storage_smapiv3_migrate.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ module MIRROR : SMAPIv2_MIRROR = struct
4242
let is_mirror_failed _ctx = u __FUNCTION__
4343

4444
let pre_deactivate_hook _ctx = u __FUNCTION__
45+
46+
let list _ctx = u __FUNCTION__
4547
end

0 commit comments

Comments
 (0)