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 1 of 8] [CA-31705] Improves error handling within vm-me

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH 1 of 8] [CA-31705] Improves error handling within vm-memory-target-wait
From: Jonathan Knowles <jonathan.knowles@xxxxxxxxxxxxx>
Date: Mon, 1 Feb 2010 09:19:03 +0000
Delivery-date: Mon, 01 Feb 2010 01:33:59 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1265015942@radon>
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>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Jonathan Knowles <jonathan.knowles@xxxxxxxxxxxxx>
# Date 1264782173 0
# Node ID 46461dc60f7b6a35ec0cc9dcfef7e76adce51f65
# Parent  30154ec586aed04136e324230a1a25889ba23c7e
[CA-31705] Improves error handling within vm-memory-target-wait.

Reformats code to meet OCaml development best practices guide.

Signed-off-by: Jonathan Knowles <jonathan.knowles@xxxxxxxxxxxxx>

diff -r 30154ec586ae -r 46461dc60f7b ocaml/xapi/xapi_vm_helpers.ml
--- a/ocaml/xapi/xapi_vm_helpers.ml     Fri Jan 29 16:17:44 2010 +0000
+++ b/ocaml/xapi/xapi_vm_helpers.ml     Fri Jan 29 16:22:53 2010 +0000
@@ -649,8 +649,8 @@
        ?(timeout_seconds = wait_memory_target_timeout_seconds)
        ?(tolerance_bytes = wait_memory_target_tolerance_bytes)
        () =
-       let raise_error error =
-               raise (Api_errors.Server_error (error, [Ref.string_of 
(Context.get_task_id __context)])) in
+       let raise_error error = raise (Api_errors.Server_error (
+               error, [Ref.string_of (Context.get_task_id __context)])) in
        let rec wait accumulated_wait_time_seconds =
                if accumulated_wait_time_seconds > 
wait_memory_target_timeout_seconds
                        then raise_error 
Api_errors.vm_memory_target_wait_timeout;
@@ -658,28 +658,40 @@
                        then raise_error Api_errors.task_cancelled;
                (* Fetch up-to-date value of memory_actual via a hypercall to 
Xen. *)
                let domain_id = Helpers.domid_of_vm ~__context ~self in
-               let domain_info = Vmopshelpers.with_xc (fun xc -> 
Xc.domain_getinfo xc domain_id) in
-               let memory_actual_pages = Int64.of_nativeint 
domain_info.Xc.total_memory_pages in
-               let memory_actual_kib = Xc.pages_to_kib memory_actual_pages in 
+               let domain_info = Vmopshelpers.with_xc
+                       (fun xc -> Xc.domain_getinfo xc domain_id) in
+               let memory_actual_pages = Int64.of_nativeint
+                       domain_info.Xc.total_memory_pages in
+               let memory_actual_kib = Xc.pages_to_kib memory_actual_pages in
                let memory_actual_bytes = Memory.bytes_of_kib memory_actual_kib 
in
                (* Fetch up-to-date value of target from xenstore. *)
-               let memory_target_kib = Int64.of_string (Vmopshelpers.with_xs 
(fun xs -> xs.Xs.read (xs.Xs.getdomainpath domain_id ^ "/memory/target"))) in
+               let memory_target_kib = Int64.of_string
+                       (Vmopshelpers.with_xs
+                               (fun xs -> xs.Xs.read
+                                       (xs.Xs.getdomainpath domain_id ^ 
"/memory/target"))) in
                let memory_target_bytes = Memory.bytes_of_kib memory_target_kib 
in
-               let difference_bytes = Int64.abs (Int64.sub memory_actual_bytes 
memory_target_bytes) in
-               debug "memory_actual = %Ld; memory_target = %Ld; difference = 
%Ld %s tolerance (%Ld)" memory_actual_bytes memory_target_bytes 
difference_bytes (if difference_bytes <= tolerance_bytes then "<=" else ">") 
tolerance_bytes;
+               let difference_bytes = Int64.abs
+                       (Int64.sub memory_actual_bytes memory_target_bytes) in
+               debug
+                       "memory_actual = %Ld; memory_target = %Ld; \
+                        difference = %Ld %s tolerance (%Ld)"
+                       memory_actual_bytes memory_target_bytes difference_bytes
+                       (if difference_bytes <= tolerance_bytes then "<=" else 
">")
+                       tolerance_bytes;
                if difference_bytes <= tolerance_bytes then
                        (* The memory target has been reached: use the most *)
                        (* recent value of memory_actual to update the same *)
                        (* field within the VM's metrics record, presenting *)
                        (* a consistent view to the world.                  *)
                        let vm_metrics_ref = Db.VM.get_metrics ~__context ~self 
in
-                       Db.VM_metrics.set_memory_actual ~__context 
~self:vm_metrics_ref ~value:memory_actual_bytes
+                       Db.VM_metrics.set_memory_actual ~__context 
~self:vm_metrics_ref
+                               ~value:memory_actual_bytes
                else begin
                        (* At exponentially increasing intervals, write  *)
                        (* a debug message saying how long we've waited: *)
                        if is_power_of_2 accumulated_wait_time_seconds then 
debug
                                "Waited %i second(s) for domain %i to reach \
-                               its target = %Ld bytes; actual = %Ld bytes."
+                                its target = %Ld bytes; actual = %Ld bytes."
                                accumulated_wait_time_seconds domain_id
                                memory_target_bytes memory_actual_bytes;
                        (* The memory target has not yet been reached: *)
1 file changed, 22 insertions(+), 10 deletions(-)
ocaml/xapi/xapi_vm_helpers.ml |   32 ++++++++++++++++++++++----------


Attachment: xen-api.hg-8.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api