File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ type error =
2929 | Other of string
3030 | VM_CDR_not_found
3131 | VM_CDR_eject
32+ | VM_CDR_insert
3233 | VM_misses_feature
3334 | VM_not_running
3435 | VM_sysprep_timeout
@@ -212,6 +213,8 @@ let eject ~rpc ~session_id ~vbd ~iso =
212213 Client.VBD. eject ~rpc ~session_id ~vbd ;
213214 Sys. remove iso
214215 with exn ->
216+ Sys. remove iso ;
217+ (* still remove ISO to protect it *)
215218 warn " %s: ejecting CD failed: %s" __FUNCTION__ (Printexc. to_string exn ) ;
216219 fail VM_CDR_eject
217220
@@ -281,7 +284,13 @@ let sysprep ~__context ~vm ~unattend ~timeout =
281284 let uuid = Db.VDI. get_uuid ~__context ~self: vdi in
282285 debug " %s: inserting Sysprep VDI for VM %s" __FUNCTION__ vm_uuid ;
283286 call ~__context @@ fun rpc session_id ->
284- Client.VBD. insert ~rpc ~session_id ~vdi ~vbd ;
287+ ( try Client.VBD. insert ~rpc ~session_id ~vdi ~vbd
288+ with e ->
289+ debug " %s: failed to insert CD, removing ISO %s: %s" __FUNCTION__ iso
290+ (Printexc. to_string e) ;
291+ Sys. remove iso ;
292+ fail VM_CDR_insert
293+ ) ;
285294 Thread. delay ! Xapi_globs. vm_sysprep_wait ;
286295 match trigger ~rpc ~session_id ~domid ~uuid ~timeout ~vbd ~iso with
287296 | true ->
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ type error =
1818 | Other of string
1919 | VM_CDR_not_found
2020 | VM_CDR_eject
21+ | VM_CDR_insert
2122 | VM_misses_feature
2223 | VM_not_running
2324 | VM_sysprep_timeout
Original file line number Diff line number Diff line change @@ -1727,10 +1727,13 @@ let sysprep ~__context ~self ~unattend ~timeout =
17271727 raise Api_errors. (Server_error (sysprep, [uuid; " VM is not running" ]))
17281728 | exception Vm_sysprep. Sysprep VM_CDR_eject ->
17291729 raise Api_errors. (Server_error (sysprep, [uuid; " VM failed to eject CD" ]))
1730+ | exception Vm_sysprep. Sysprep VM_CDR_insert ->
1731+ raise Api_errors. (Server_error (sysprep, [uuid; " VM failed to insert CD" ]))
17301732 | exception Vm_sysprep. Sysprep VM_sysprep_timeout ->
17311733 raise
17321734 Api_errors. (
1733- Server_error (sysprep, [uuid; " sysprep not found running - timeout" ])
1735+ Server_error
1736+ (sysprep, [uuid; " No response from sysprep within allocated time" ])
17341737 )
17351738 | exception Vm_sysprep. Sysprep XML_too_large ->
17361739 raise
You can’t perform that action at this time.
0 commit comments