Skip to content

Commit 01c0635

Browse files
authored
Merge pull request #2775 from jonludlam/CA-182929
CA-182929: Raise an error if the storage backend type is unknown.
2 parents 85afda1 + 4dd92c4 commit 01c0635

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

ocaml/xapi/storage_access.ml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,9 +889,22 @@ let make_service uuid ty =
889889
url = Constants.path [ Constants._services; Constants._driver; uuid; Constants._SM; ty ];
890890
}
891891

892+
let check_queue_exists queue_name =
893+
let t = Xcp_client.(get_ok (Protocol_unix.Client.connect ~switch:!switch_path ())) in
894+
let results =
895+
match Protocol_unix.Client.list ~t ~prefix:!Storage_interface.queue_name ~filter:`Alive () with
896+
| `Ok list -> list
897+
| _ -> failwith "Failed to contact switch" (* Shouldn't ever happen *) in
898+
if not (List.mem queue_name results)
899+
then
900+
let prefix_len = String.length !Storage_interface.queue_name + 1 in
901+
let driver = String.sub queue_name prefix_len (String.length queue_name - prefix_len) in
902+
raise Api_errors.(Server_error(sr_unknown_driver,[driver]))
903+
892904
let external_rpc queue_name uri =
905+
let open Xcp_client in
906+
if !use_switch then check_queue_exists queue_name;
893907
fun call ->
894-
let open Xcp_client in
895908
if !use_switch
896909
then json_switch_rpc queue_name call
897910
else xml_http_rpc

0 commit comments

Comments
 (0)