suspend_domain ~fd ~hvm ();
(* If the suspend succeeds, set the suspend_VDI *)
Db.VM.set_suspend_VDI ~__context ~self:vm ~value:vdi_ref;)
- (fun () -> Unix.close fd);
+ (fun () ->
+ try
+ Unixext.fsync fd;
+ Unix.close fd
+ with Unix.Unix_error(Unix.EIO, _, _) ->
+ raise (Api_errors.Server_error (Api_errors.vdi_io_error, ["I/O error saving VM suspend image"]))
+ );
debug "suspend: complete");
debug "suspend phase 4/4: recording memory usage";
(* Record the final memory usage of the VM, so that we know how much *)
| Api_errors.Server_error(code, _) as e when code = Api_errors.vm_no_suspend_sr ->
error "No suspend SR available for this VM";
raise e
+ | Api_errors.Server_error(_, _) as e -> raise e
| _ -> raise (Api_errors.Server_error (Api_errors.vm_checkpoint_suspend_failed, [Ref.string_of vm]))
end;