Skip to content

Commit 44145a6

Browse files
committed
CA-405754: Update xapi-storage-script state.db
xapi-storage-script maintains a state.db which is loaded on startup every time. This state.db contains currently attached SRs, and this information can be used later on by xapi to decide whether to plug a PBD in. This information is correctly updated when adding an attached SR in, but not when removing an SR. This will cause problems when an SR is detached, followed by a toolstack restart. As now xapi-storage-script still thinks that SR is attached, but in fact it is not. Signed-off-by: Vincent Liu <[email protected]>
1 parent 3234be2 commit 44145a6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

ocaml/xapi-storage-script/main.ml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,7 @@ module Attached_SRs = struct
637637

638638
let state_path = ref None
639639

640-
let add smapiv2 plugin uids =
641-
let key = Storage_interface.Sr.string_of smapiv2 in
642-
Base.Hashtbl.set !sr_table ~key ~data:{sr= plugin; uids} ;
640+
let update_state_path () =
643641
( match !state_path with
644642
| None ->
645643
Lwt.return_unit
@@ -653,6 +651,11 @@ module Attached_SRs = struct
653651
)
654652
>>= fun () -> return ()
655653

654+
let add smapiv2 plugin uids =
655+
let key = Storage_interface.Sr.string_of smapiv2 in
656+
Base.Hashtbl.set !sr_table ~key ~data:{sr= plugin; uids} ;
657+
update_state_path ()
658+
656659
let find smapiv2 =
657660
let key = Storage_interface.Sr.string_of smapiv2 in
658661
match Base.Hashtbl.find !sr_table key with
@@ -674,7 +677,7 @@ module Attached_SRs = struct
674677
let remove smapiv2 =
675678
let key = Storage_interface.Sr.string_of smapiv2 in
676679
Base.Hashtbl.remove !sr_table key ;
677-
return ()
680+
update_state_path ()
678681

679682
let list () =
680683
let srs =

0 commit comments

Comments
 (0)