Skip to content

Commit 91c0e1d

Browse files
committed
On vm_install check SR reference using DB.is_valid_ref
Signed-off-by: John Else <[email protected]>
1 parent 63c0ef4 commit 91c0e1d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

ocaml/xapi/cli_operations.ml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,12 +2040,16 @@ let vm_install_real printer rpc session_id template name description params =
20402040

20412041
let suspend_sr_ref = match sr_ref with
20422042
| Some sr ->
2043-
if sr = Ref.null then
2044-
(* Template is a snapshot - copy the suspend_SR from the template *)
2045-
Client.VM.get_suspend_SR rpc session_id template
2046-
else
2043+
let ref_is_valid = Server_helpers.exec_with_new_task
2044+
~session_id "Checking suspend_SR validity"
2045+
(fun __context -> Db.is_valid_ref __context sr)
2046+
in
2047+
if ref_is_valid then
20472048
(* sr-uuid and/or sr-name-label was specified - use this as the suspend_SR *)
20482049
sr
2050+
else
2051+
(* Template is a snapshot - copy the suspend_SR from the template *)
2052+
Client.VM.get_suspend_SR rpc session_id template
20492053
| None ->
20502054
(* Not a snapshot and no sr-uuid or sr-name-label specified - copy the suspend_SR from the template *)
20512055
Client.VM.get_suspend_SR rpc session_id template in

0 commit comments

Comments
 (0)