Skip to content

Commit aad27b3

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 aad27b3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

ocaml/xapi-storage-script/main.ml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -637,10 +637,8 @@ 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} ;
643-
( match !state_path with
640+
let update_state_path () =
641+
match !state_path with
644642
| None ->
645643
Lwt.return_unit
646644
| Some path ->
@@ -650,8 +648,11 @@ module Attached_SRs = struct
650648
in
651649
let dir = Filename.dirname path in
652650
Sys.mkdir_p dir >>= fun () -> Sys.save path ~contents
653-
)
654-
>>= fun () -> return ()
651+
652+
let add smapiv2 plugin uids =
653+
let key = Storage_interface.Sr.string_of smapiv2 in
654+
Base.Hashtbl.set !sr_table ~key ~data:{sr= plugin; uids} ;
655+
update_state_path () >>= fun () -> return ()
655656

656657
let find smapiv2 =
657658
let key = Storage_interface.Sr.string_of smapiv2 in
@@ -674,7 +675,7 @@ module Attached_SRs = struct
674675
let remove smapiv2 =
675676
let key = Storage_interface.Sr.string_of smapiv2 in
676677
Base.Hashtbl.remove !sr_table key ;
677-
return ()
678+
update_state_path () >>= fun () -> return ()
678679

679680
let list () =
680681
let srs =

0 commit comments

Comments
 (0)