Skip to content

Commit b92d19e

Browse files
authored
CA-411477: Fix SM API version check failure (#6552)
When shutdown a VM, xapi will check SM API version to decide if to call `post_deactivate_hook`. But if the SR has already been unplugged, the checking will fail. Solution: Check if the plugin of the SR still exists. If not, skip the SM API checking.
2 parents 2f3eec3 + ec612ae commit b92d19e

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

ocaml/xapi/storage_mux.ml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -644,16 +644,23 @@ module Mux = struct
644644
with_dbg ~name:"VDI.deativate" ~dbg @@ fun di ->
645645
info "VDI.deactivate dbg:%s dp:%s sr:%s vdi:%s vm:%s" dbg dp (s_of_sr sr)
646646
(s_of_vdi vdi) (s_of_vm vm) ;
647-
let module C = StorageAPI (Idl.Exn.GenClient (struct
648-
let rpc = of_sr sr
649-
end)) in
650-
C.VDI.deactivate (Debug_info.to_string di) dp sr vdi vm ;
651-
(*XX The hook should not be called here, nor should storage_mux care about
652-
the SMAPI version of the SR, but as xapi-storage-script cannot call code
653-
xapi, and smapiv1_wrapper has state tracking logic, the hook has to be placed
654-
here for now. *)
655-
if smapi_version_of_sr sr = SMAPIv3 then
656-
Storage_migrate.post_deactivate_hook ~sr ~vdi ~dp
647+
let open DP_info in
648+
match read dp with
649+
| Some {sr; vdi; vm; _} ->
650+
let module C = StorageAPI (Idl.Exn.GenClient (struct
651+
let rpc = of_sr sr
652+
end)) in
653+
C.VDI.deactivate (Debug_info.to_string di) dp sr vdi vm ;
654+
(*XX The hook should not be called here, nor should storage_mux care about
655+
the SMAPI version of the SR, but as xapi-storage-script cannot call code
656+
xapi, and smapiv1_wrapper has state tracking logic, the hook has to be placed
657+
here for now. *)
658+
if smapi_version_of_sr sr = SMAPIv3 then
659+
Storage_migrate.post_deactivate_hook ~sr ~vdi ~dp
660+
| None ->
661+
info
662+
"dp %s is not associated with a locally attached VDI; nothing to do"
663+
dp
657664

658665
let detach () ~dbg ~dp ~sr ~vdi ~vm =
659666
with_dbg ~name:"VDI.detach" ~dbg @@ fun di ->

0 commit comments

Comments
 (0)