Skip to content

Commit 4916089

Browse files
author
Christian Lindig
committed
CA-408048 remove SM plugins from DB if unavailable
An SM plugin might become unavailable; we have to remove its record on xapi startup. The canonical case is an upgrade from XS8 to XS9. Signed-off-by: Christian Lindig <christian.lindig@cloud.com>
1 parent 0441299 commit 4916089

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

ocaml/xapi/storage_access.ml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,17 @@ exception Message_switch_failure
109109
(** Synchronise the SM table with the SMAPIv1 plugins on the disk and the SMAPIv2
110110
plugins mentioned in the configuration file whitelist. *)
111111
let on_xapi_start ~__context =
112+
(* An SM is either implemented as a plugin - for which we check its
113+
presence, or via an API *)
114+
let is_available (_rf, rc) =
115+
let ( >>= ) x y = String.compare x y >= 0 in
116+
Sys.file_exists rc.API.sM_driver_filename
117+
|| rc.sM_required_api_version >>= "5.0"
118+
in
112119
let existing =
113-
List.map
114-
(fun (rf, rc) -> (rc.API.sM_type, (rf, rc)))
115-
(Db.SM.get_all_records ~__context)
120+
Db.SM.get_all_records ~__context
121+
|> List.filter is_available
122+
|> List.map (fun (rf, rc) -> (rc.API.sM_type, (rf, rc)))
116123
in
117124
let explicitly_configured_drivers =
118125
List.filter_map

0 commit comments

Comments
 (0)