From 62f2a22772eb5675c054d0b0dc2fd21f1a0a57a8 Mon Sep 17 00:00:00 2001 From: Daniel Stodden Date: Mon, 15 Mar 2010 09:22:23 +0000 Subject: [PATCH] CA-38567: Catch I/O errors during VM.suspend Signed-off-by: Daniel Stodden --- ocaml/xapi/vmops.ml | 8 +++++++- ocaml/xapi/xapi_vm_snapshot.ml | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ocaml/xapi/vmops.ml b/ocaml/xapi/vmops.ml index b7261629..801a59e8 100644 --- a/ocaml/xapi/vmops.ml +++ b/ocaml/xapi/vmops.ml @@ -950,7 +950,13 @@ let suspend ~live ~progress_cb ~__context ~xc ~xs ~vm = 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 *) diff --git a/ocaml/xapi/xapi_vm_snapshot.ml b/ocaml/xapi/xapi_vm_snapshot.ml index 9f027063..120b7cfe 100644 --- a/ocaml/xapi/xapi_vm_snapshot.ml +++ b/ocaml/xapi/xapi_vm_snapshot.ml @@ -192,6 +192,7 @@ let checkpoint ~__context ~vm ~new_name = | 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; -- 2.39.5