Skip to content

Commit c05a224

Browse files
committed
On vm_install check SR reference using DB.is_valid_ref
Signed-off-by: John Else <john.else@citrix.com>
1 parent 2d0b039 commit c05a224

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
@@ -2037,12 +2037,16 @@ let vm_install_real printer rpc session_id template name description params =
20372037

20382038
let suspend_sr_ref = match sr_ref with
20392039
| Some sr ->
2040-
if sr = Ref.null then
2041-
(* Template is a snapshot - copy the suspend_SR from the template *)
2042-
Client.VM.get_suspend_SR rpc session_id template
2043-
else
2040+
let ref_is_valid = Server_helpers.exec_with_new_task
2041+
~session_id "Checking suspend_SR validity"
2042+
(fun __context -> Db.is_valid_ref __context sr)
2043+
in
2044+
if ref_is_valid then
20442045
(* sr-uuid and/or sr-name-label was specified - use this as the suspend_SR *)
20452046
sr
2047+
else
2048+
(* Template is a snapshot - copy the suspend_SR from the template *)
2049+
Client.VM.get_suspend_SR rpc session_id template
20462050
| None ->
20472051
(* Not a snapshot and no sr-uuid or sr-name-label specified - copy the suspend_SR from the template *)
20482052
Client.VM.get_suspend_SR rpc session_id template in

0 commit comments

Comments
 (0)