|
|
|
|
|
|
|
|
|
|
xen-api
[Xen-API] [PATCH 3 of 4] [XIU]: when a domain target is updated, transfe
# HG changeset patch
# User David Scott <dave.scott@xxxxxxxxxxxxx>
# Date 1259087100 0
# Node ID 3c4e4f66208468379b92ba47ec1e425a6cfc261b
# Parent 25cea9ab5619b4e4d728c4c6592ea673f9ee1a14
[XIU]: when a domain target is updated, transfer the memory immediately from
the host, respecting both the domain's max_mem and the total amount of memory
free on the host.
Signed-off-by: David Scott <dave.scott@xxxxxxxxxxxxx>
diff -r 25cea9ab5619 -r 3c4e4f662084 ocaml/xiu/xiu.ml
--- a/ocaml/xiu/xiu.ml Tue Nov 24 18:24:59 2009 +0000
+++ b/ocaml/xiu/xiu.ml Tue Nov 24 18:25:00 2009 +0000
@@ -152,14 +152,31 @@
try Hashtbl.find domains domid
with Not_found -> raise Domain_not_found
+let round_down_to_page x = (x / 4) * 4
+
+(** Add up to [delta_kib] memory to the domain, reducing the host free memory
by the same amount *)
+let transfer_to_domain dom delta_kib =
+ let available_kib = min !physical_free_kib delta_kib in
+ eprintf "(XIU) transfer_to_domain domid = %d; delta_kib = %d\n%!" dom.domid
delta_kib;
+ dom.tot_mem_kib <- dom.tot_mem_kib + available_kib;
+ physical_free_kib := !physical_free_kib - available_kib
+
(** immediately set the tot_mem_kib to the requested balloon target *)
let read_memory_target xs domid =
let path = Printf.sprintf "/local/domain/%d/memory/target" domid in
try
- let mem = xs.Xs.read path in
+ let mem = int_of_string (xs.Xs.read path) in
let dom = domain_find domid in
- dom.tot_mem_kib <- int_of_string mem
- with e -> eprintf "(XIU) Failed to parse memory target of domid %d\n"
domid
+ (* Enforce the max_mem limit *)
+ if mem > dom.max_mem_kib
+ then eprintf "(XIU) domid %d target = %d KiB but max_mem = %d
KiB\n%!" domid mem dom.max_mem_kib;
+ let requested = round_down_to_page (min mem dom.max_mem_kib) in
+
+ let delta_kib = requested - dom.tot_mem_kib in
+ transfer_to_domain dom delta_kib;
+ if dom.tot_mem_kib <> requested
+ then eprintf "(XIU) domid %d requested %d KiB but only got %d
KiB\n%!" domid requested dom.tot_mem_kib;
+ with e -> eprintf "(XIU) Failed to parse memory target of domid %d\n%!"
domid
(** Maximum number of dummy<N> devices fixed at module-load time *)
let max_dummy_vifs = 1000
1 file changed, 20 insertions(+), 3 deletions(-)
ocaml/xiu/xiu.ml | 23 ++++++++++++++++++++---
xen-api.hg-4.patch
Description: Text Data
_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
|
|
|
|
|