# HG changeset patch
# User Jonathan Knowles <[email protected]>
# Date 1269859684 -3600
# Node ID a2aefdf05e1db543982a258ea46fb35400f8d050
# Parent  3b5a7e206b6d6891070caca584b1398c6d2f535f
[CA-39589] Refactoring: extracts out the "do_final_actions_after_suspend" 
function from a deeply-nested block.

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

diff -r 3b5a7e206b6d -r a2aefdf05e1d ocaml/xapi/vmops.ml
--- a/ocaml/xapi/vmops.ml       Mon Mar 29 11:48:03 2010 +0100
+++ b/ocaml/xapi/vmops.ml       Mon Mar 29 11:48:04 2010 +0100
@@ -957,6 +957,11 @@
                (* CA-31759: avoid using the LBR to simplify upgrade *)
                Db.VM.set_memory_target ~__context ~self:vm 
~value:final_memory_bytes
        in
+       let do_final_actions_after_suspend () =
+               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 _ -> ())
+       in
        Xapi_xenops_errors.handle_xenops_error
                (fun () ->
                        with_xc_and_xs
@@ -964,11 +969,7 @@
                                        if is_paused then Domain.unpause ~xc 
domid;
                                        finally
                                                (do_suspend)
-                                       (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 _ -> ()))))
+                                               
(do_final_actions_after_suspend)))
 
 let resume ~__context ~xc ~xs ~vm =
        let domid = Helpers.domid_of_vm ~__context ~self:vm in
1 file changed, 6 insertions(+), 5 deletions(-)
ocaml/xapi/vmops.ml |   11 ++++++-----


# HG changeset patch
# User Jonathan Knowles <[email protected]>
# Date 1269859684 -3600
# Node ID a2aefdf05e1db543982a258ea46fb35400f8d050
# Parent  3b5a7e206b6d6891070caca584b1398c6d2f535f
[CA-39589] Refactoring: extracts out the "do_final_actions_after_suspend" function from a deeply-nested block.

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

diff -r 3b5a7e206b6d -r a2aefdf05e1d ocaml/xapi/vmops.ml
--- a/ocaml/xapi/vmops.ml	Mon Mar 29 11:48:03 2010 +0100
+++ b/ocaml/xapi/vmops.ml	Mon Mar 29 11:48:04 2010 +0100
@@ -957,6 +957,11 @@
 		(* CA-31759: avoid using the LBR to simplify upgrade *)
 		Db.VM.set_memory_target ~__context ~self:vm ~value:final_memory_bytes
 	in
+	let do_final_actions_after_suspend () =
+		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 _ -> ())
+	in
 	Xapi_xenops_errors.handle_xenops_error
 		(fun () ->
 			with_xc_and_xs
@@ -964,11 +969,7 @@
 					if is_paused then Domain.unpause ~xc domid;
 					finally
 						(do_suspend)
-					(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 _ -> ()))))
+						(do_final_actions_after_suspend)))
 
 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