# HG changeset patch
# User Jonathan Knowles <[email protected]>
# Date 1269859680 -3600
# Node ID 4a9675ecf42df55895f201e2e7928d4ff0c6fc7f
# Parent  56f91be468e5704a0d7b0e7b7c5e2481b46aa12f
[CA-39589] After a VM suspend operation, Xapi now reverses any destructive 
update it makes to XenStore's copy of dynamic-max.

This changeset replaces a "try x catch y" expression with a "finally x y" 
expression.

Signed-off-by: Jonathan Knowles <[email protected]>
Acked-by: Marcus Granado <[email protected]>

diff -r 56f91be468e5 -r 4a9675ecf42d ocaml/xapi/vmops.ml
--- a/ocaml/xapi/vmops.ml       Mon Mar 29 11:47:59 2010 +0100
+++ b/ocaml/xapi/vmops.ml       Mon Mar 29 11:48:00 2010 +0100
@@ -904,7 +904,7 @@
                                        let max = Db.VM.get_memory_dynamic_max 
~__context ~self:vm in
                                        let min = Int64.to_int (Int64.div min 
1024L) in
                                        let max = Int64.to_int (Int64.div max 
1024L) in
-                                       try
+                                       finally (fun () ->
                                                (* Balloon down the guest as 
far as we can to force it to clear unnecessary caches etc. *)
                                                debug "suspend phase 0/4: 
asking guest to balloon down";
                                                Domain.set_memory_dynamic_range 
~xs ~min ~max:min domid;
@@ -960,13 +960,12 @@
                                                let final_memory_bytes = 
Memory.bytes_of_pages (Int64.of_nativeint di.Xc.total_memory_pages) in
                                                debug "total_memory_pages=%Ld; 
storing target=%Ld" (Int64.of_nativeint di.Xc.total_memory_pages) 
final_memory_bytes;
                                                (* CA-31759: avoid using the 
LBR to simplify upgrade *)
-                                               Db.VM.set_memory_target 
~__context ~self:vm ~value:final_memory_bytes;
-                                       with e ->
+                                               Db.VM.set_memory_target 
~__context ~self:vm ~value:final_memory_bytes;)
+                                       (fun () ->
                                                Domain.set_memory_dynamic_range 
~xs ~min ~max domid;
                                                Memory_control.balance_memory 
~__context ~xc ~xs;
                                                if is_paused then
-                                                       (try Domain.pause ~xc 
domid with _ -> ());
-                                               raise e))
+                                                       (try Domain.pause ~xc 
domid with _ -> ()))))
 
 let resume ~__context ~xc ~xs ~vm =
        let domid = Helpers.domid_of_vm ~__context ~self:vm in
1 file changed, 4 insertions(+), 5 deletions(-)
ocaml/xapi/vmops.ml |    9 ++++-----


# HG changeset patch
# User Jonathan Knowles <[email protected]>
# Date 1269859680 -3600
# Node ID 4a9675ecf42df55895f201e2e7928d4ff0c6fc7f
# Parent  56f91be468e5704a0d7b0e7b7c5e2481b46aa12f
[CA-39589] After a VM suspend operation, Xapi now reverses any destructive update it makes to XenStore's copy of dynamic-max.

This changeset replaces a "try x catch y" expression with a "finally x y" expression.

Signed-off-by: Jonathan Knowles <[email protected]>
Acked-by: Marcus Granado <[email protected]>

diff -r 56f91be468e5 -r 4a9675ecf42d ocaml/xapi/vmops.ml
--- a/ocaml/xapi/vmops.ml	Mon Mar 29 11:47:59 2010 +0100
+++ b/ocaml/xapi/vmops.ml	Mon Mar 29 11:48:00 2010 +0100
@@ -904,7 +904,7 @@
 					let max = Db.VM.get_memory_dynamic_max ~__context ~self:vm in
 					let min = Int64.to_int (Int64.div min 1024L) in
 					let max = Int64.to_int (Int64.div max 1024L) in
-					try
+					finally (fun () ->
 						(* Balloon down the guest as far as we can to force it to clear unnecessary caches etc. *)
 						debug "suspend phase 0/4: asking guest to balloon down";
 						Domain.set_memory_dynamic_range ~xs ~min ~max:min domid;
@@ -960,13 +960,12 @@
 						let final_memory_bytes = Memory.bytes_of_pages (Int64.of_nativeint di.Xc.total_memory_pages) in
 						debug "total_memory_pages=%Ld; storing target=%Ld" (Int64.of_nativeint di.Xc.total_memory_pages) final_memory_bytes;
 						(* CA-31759: avoid using the LBR to simplify upgrade *)
-						Db.VM.set_memory_target ~__context ~self:vm ~value:final_memory_bytes;
-					with e ->
+						Db.VM.set_memory_target ~__context ~self:vm ~value:final_memory_bytes;)
+					(fun () ->
 						Domain.set_memory_dynamic_range ~xs ~min ~max domid;
 						Memory_control.balance_memory ~__context ~xc ~xs;
 						if is_paused then
-							(try Domain.pause ~xc domid with _ -> ());
-						raise e))
+							(try Domain.pause ~xc domid with _ -> ()))))
 
 let resume ~__context ~xc ~xs ~vm =
 	let domid = Helpers.domid_of_vm ~__context ~self:vm in
_______________________________________________
xen-api mailing list
[email protected]
http://lists.xensource.com/mailman/listinfo/xen-api

Reply via email to