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 07 of 12] [PCR0047] Adds functions "assert_{valid, va

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH 07 of 12] [PCR0047] Adds functions "assert_{valid, valid_and_pinned_at_static_max, valid_for_current_context}" to module "Xapi_vm_memory_constraints". By default the function "assert_valid_for_current_context" acts as an alias for function "assert_valid"
From: Jonathan Knowles <jonathan.knowles@xxxxxxxxxxxxx>
Date: Mon, 1 Feb 2010 16:32:09 +0000
Delivery-date: Mon, 01 Feb 2010 08:36:38 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1265041922@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 1265039944 0
# Node ID 5de74d499b798f5029454ae8c630b1525037cf08
# Parent  98e9bcbce80e3165aff609962ac2a6fc23ecc22d
[PCR0047] Adds functions "assert_{valid, valid_and_pinned_at_static_max, 
valid_for_current_context}" to module "Xapi_vm_memory_constraints". By default 
the function "assert_valid_for_current_context" acts as an alias for function 
"assert_valid".

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

diff -r 98e9bcbce80e -r 5de74d499b79 ocaml/xapi/xapi_vm_memory_constraints.ml
--- a/ocaml/xapi/xapi_vm_memory_constraints.ml  Mon Feb 01 15:59:03 2010 +0000
+++ b/ocaml/xapi/xapi_vm_memory_constraints.ml  Mon Feb 01 15:59:04 2010 +0000
@@ -20,6 +20,19 @@
 
        include Vm_memory_constraints.T
 
+       (** Asserts for the given set of constraints [c], that
+           [c.static_min] â?¤ [c.dynamic_min] â?¤ [c.dynamic_max] â?¤ 
[c.static_max]. *)
+       val assert_valid : constraints:t -> unit
+
+       (** Asserts for the given set of constraints [c], that
+           [c.static_min] â?¤ [c.dynamic_min] = [c.dynamic_max] = 
[c.static_max]. *)
+       val assert_valid_and_pinned_at_static_max : constraints:t -> unit
+
+       (** Asserts that the given set of constraints [c] is valid for the 
current
+           context. *)
+       val assert_valid_for_current_context :
+               __context:Context.t -> constraints:t -> unit
+
        (** Extracts memory constraints from the given VM record. *)
        val extract : vm_record:API.vM_t -> t
 
@@ -37,6 +50,23 @@
 module Vm_memory_constraints : T = struct
 
        include Vm_memory_constraints.Vm_memory_constraints
+
+       let assert_valid ~constraints =
+               if not (are_valid ~constraints)
+               then raise (Api_errors.Server_error (
+                       Api_errors.memory_constraint_violation,
+                               ["Memory limits must satisfy: \
+                               static_min â?¤ dynamic_min â?¤ dynamic_max â?¤ 
static_max"]))
+
+       let assert_valid_and_pinned_at_static_max ~constraints =
+               if not (are_valid_and_pinned_at_static_max ~constraints)
+               then raise (Api_errors.Server_error (
+                       Api_errors.memory_constraint_violation,
+                               ["Memory limits must satisfy: \
+                               static_min â?¤ dynamic_min = dynamic_max = 
static_max"]))
+
+       let assert_valid_for_current_context ~__context ~constraints =
+               assert_valid ~constraints
 
        let extract ~vm_record = 
        {
1 file changed, 30 insertions(+)
ocaml/xapi/xapi_vm_memory_constraints.ml |   30 ++++++++++++++++++++++++++++++


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

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>