Skip to content

Commit a841d38

Browse files
authored
CA-409949 CA-408048 remove unavailable SM types at startup (#6463)
On XS9 a previiously available SM type might become unavailable. Make sure we remove it on upgrade. The previius fix in CA-408048 did not work.
2 parents bac8dcf + ddeff67 commit a841d38

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ocaml/xapi/storage_access.ml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,12 @@ exception Message_switch_failure
111111
let on_xapi_start ~__context =
112112
(* An SM is either implemented as a plugin - for which we check its
113113
presence, or via an API *)
114-
let is_available (_rf, rc) =
114+
let is_available rc =
115115
Sys.file_exists rc.API.sM_driver_filename
116116
|| Version.String.ge rc.sM_required_api_version "5.0"
117117
in
118118
let existing =
119119
Db.SM.get_all_records ~__context
120-
|> List.filter is_available
121120
|> List.map (fun (rf, rc) -> (rc.API.sM_type, (rf, rc)))
122121
in
123122
let explicitly_configured_drivers =
@@ -172,6 +171,9 @@ let on_xapi_start ~__context =
172171
in
173172
(* Add all the running SMAPIv2 drivers *)
174173
let to_keep = to_keep @ running_smapiv2_drivers in
174+
let unavailable =
175+
List.filter (fun (_, (_, rc)) -> not (is_available rc)) existing
176+
in
175177
(* Delete all records which aren't configured or in-use *)
176178
List.iter
177179
(fun ty ->
@@ -181,7 +183,12 @@ let on_xapi_start ~__context =
181183
let self, _ = List.assoc ty existing in
182184
try Db.SM.destroy ~__context ~self with _ -> ()
183185
)
184-
(Listext.List.set_difference (List.map fst existing) to_keep) ;
186+
(List.concat
187+
[
188+
Listext.List.set_difference (List.map fst existing) to_keep
189+
; List.map fst unavailable
190+
]
191+
) ;
185192

186193
(* Synchronize SMAPIv1 plugins *)
187194

0 commit comments

Comments
 (0)