WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH 2 of 4] CA-38567: Catch I/O errors during VDI.copy

To: Xen API <xen-api@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-API] [PATCH 2 of 4] CA-38567: Catch I/O errors during VDI.copy
From: Daniel Stodden <daniel.stodden@xxxxxxxxxx>
Date: Fri, 05 Mar 2010 23:20:57 -0000
Delivery-date: Fri, 05 Mar 2010 15:21:44 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1267831255@xxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1267831255@xxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.3.1
# HG changeset patch
# User Daniel Stodden <daniel.stodden@xxxxxxxxxx>
# Date 1267831159 28800
# Node ID 19f971d3238714940e6ada4acf23a7ee7cb9558f
# Parent  04f7f3dde50d56896814e9568e7c3d43d8d9bde7
CA-38567: Catch I/O errors during VDI.copy.

Signed-off-by: Daniel Stodden <daniel.stodden@xxxxxxxxxx>

diff -r 04f7f3dde50d -r 19f971d32387 ocaml/xapi/sm_fs_ops.ml
--- a/ocaml/xapi/sm_fs_ops.ml   Fri Mar 05 15:19:18 2010 -0800
+++ b/ocaml/xapi/sm_fs_ops.ml   Fri Mar 05 15:19:19 2010 -0800
@@ -244,17 +244,20 @@
        with_block_attached_device __context rpc session_id vdi_dst `RW
         (fun device_dst ->
            let ifd=Unix.openfile device_src [Unix.O_RDONLY] 0o600 
-           and ofd=Unix.openfile device_dst [Unix.O_WRONLY] 0o600 in
-           try
-             dd ifd ofd size blocksize;
-             Unix.close ifd;
-             Unix.close ofd
-           with
-             e ->
-               debug "Caught exception %s" (ExnHelper.string_of_exn e);
-               log_backtrace ();
-               Unix.close ifd;
-               Unix.close ofd
+           and ofd=Unix.openfile device_dst [Unix.O_WRONLY; Unix.O_SYNC] 0o600 
in
+           finally
+             (fun () ->
+                try
+                  dd ifd ofd size blocksize;
+                with
+                  | Unix.Unix_error(Unix.EIO, _, _) ->
+                      raise (Api_errors.Server_error (Api_errors.vdi_io_error, 
["Device I/O error"]))
+                  | e ->
+                      debug "Caught exception %s" (ExnHelper.string_of_exn e);
+                      log_backtrace ())
+             (fun () ->
+                Unix.close ifd;
+                Unix.close ofd)
         )
     )
   )
# HG changeset patch
# User Daniel Stodden <daniel.stodden@xxxxxxxxxx>
# Date 1267831159 28800
# Node ID 19f971d3238714940e6ada4acf23a7ee7cb9558f
# Parent  04f7f3dde50d56896814e9568e7c3d43d8d9bde7
CA-38567: Catch I/O errors during VDI.copy.

Signed-off-by: Daniel Stodden <daniel.stodden@xxxxxxxxxx>

diff -r 04f7f3dde50d -r 19f971d32387 ocaml/xapi/sm_fs_ops.ml
--- a/ocaml/xapi/sm_fs_ops.ml   Fri Mar 05 15:19:18 2010 -0800
+++ b/ocaml/xapi/sm_fs_ops.ml   Fri Mar 05 15:19:19 2010 -0800
@@ -244,17 +244,20 @@
        with_block_attached_device __context rpc session_id vdi_dst `RW
         (fun device_dst ->
            let ifd=Unix.openfile device_src [Unix.O_RDONLY] 0o600 
-           and ofd=Unix.openfile device_dst [Unix.O_WRONLY] 0o600 in
-           try
-             dd ifd ofd size blocksize;
-             Unix.close ifd;
-             Unix.close ofd
-           with
-             e ->
-               debug "Caught exception %s" (ExnHelper.string_of_exn e);
-               log_backtrace ();
-               Unix.close ifd;
-               Unix.close ofd
+           and ofd=Unix.openfile device_dst [Unix.O_WRONLY; Unix.O_SYNC] 0o600 
in
+           finally
+             (fun () ->
+                try
+                  dd ifd ofd size blocksize;
+                with
+                  | Unix.Unix_error(Unix.EIO, _, _) ->
+                      raise (Api_errors.Server_error (Api_errors.vdi_io_error, 
["Device I/O error"]))
+                  | e ->
+                      debug "Caught exception %s" (ExnHelper.string_of_exn e);
+                      log_backtrace ())
+             (fun () ->
+                Unix.close ifd;
+                Unix.close ofd)
         )
     )
   )
_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api