Skip to content

CP-308455 VM.sysprep if CD insert fails, remove ISO #6632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion ocaml/xapi/vm_sysprep.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type error =
| Other of string
| VM_CDR_not_found
| VM_CDR_eject
| VM_CDR_insert
| VM_misses_feature
| VM_not_running
| VM_sysprep_timeout
Expand Down Expand Up @@ -212,6 +213,8 @@ let eject ~rpc ~session_id ~vbd ~iso =
Client.VBD.eject ~rpc ~session_id ~vbd ;
Sys.remove iso
with exn ->
Sys.remove iso ;
(* still remove ISO to protect it *)
warn "%s: ejecting CD failed: %s" __FUNCTION__ (Printexc.to_string exn) ;
fail VM_CDR_eject

Expand Down Expand Up @@ -281,7 +284,13 @@ let sysprep ~__context ~vm ~unattend ~timeout =
let uuid = Db.VDI.get_uuid ~__context ~self:vdi in
debug "%s: inserting Sysprep VDI for VM %s" __FUNCTION__ vm_uuid ;
call ~__context @@ fun rpc session_id ->
Client.VBD.insert ~rpc ~session_id ~vdi ~vbd ;
( try Client.VBD.insert ~rpc ~session_id ~vdi ~vbd
with e ->
debug "%s: failed to insert CD, removing ISO %s: %s" __FUNCTION__ iso
(Printexc.to_string e) ;
Sys.remove iso ;
fail VM_CDR_insert
) ;
Thread.delay !Xapi_globs.vm_sysprep_wait ;
match trigger ~rpc ~session_id ~domid ~uuid ~timeout ~vbd ~iso with
| true ->
Expand Down
1 change: 1 addition & 0 deletions ocaml/xapi/vm_sysprep.mli
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type error =
| Other of string
| VM_CDR_not_found
| VM_CDR_eject
| VM_CDR_insert
| VM_misses_feature
| VM_not_running
| VM_sysprep_timeout
Expand Down
5 changes: 4 additions & 1 deletion ocaml/xapi/xapi_vm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1727,10 +1727,13 @@ let sysprep ~__context ~self ~unattend ~timeout =
raise Api_errors.(Server_error (sysprep, [uuid; "VM is not running"]))
| exception Vm_sysprep.Sysprep VM_CDR_eject ->
raise Api_errors.(Server_error (sysprep, [uuid; "VM failed to eject CD"]))
| exception Vm_sysprep.Sysprep VM_CDR_insert ->
raise Api_errors.(Server_error (sysprep, [uuid; "VM failed to insert CD"]))
| exception Vm_sysprep.Sysprep VM_sysprep_timeout ->
raise
Api_errors.(
Server_error (sysprep, [uuid; "sysprep not found running - timeout"])
Server_error
(sysprep, [uuid; "No response from sysprep within allocated time"])
)
| exception Vm_sysprep.Sysprep XML_too_large ->
raise
Expand Down
Loading