1open Printf
2
3let bool_as_char b c = if b then c else '-'
4
5let print_dominfo dominfo =
6  let id = dominfo.Xenlight.Dominfo.domid
7  and running = bool_as_char dominfo.Xenlight.Dominfo.running 'r'
8  and blocked = bool_as_char dominfo.Xenlight.Dominfo.blocked 'b'
9  and paused = bool_as_char dominfo.Xenlight.Dominfo.paused 'p'
10  and shutdown = bool_as_char dominfo.Xenlight.Dominfo.shutdown 's'
11  and dying = bool_as_char dominfo.Xenlight.Dominfo.dying 'd'
12  and memory = dominfo.Xenlight.Dominfo.current_memkb
13  in
14  printf "Dom %d: %c%c%c%c%c %LdKB\n" id running blocked paused shutdown dying memory
15
16let _ =
17  let logger = Xtl.create_stdio_logger (*~level:Xentoollog.Debug*) () in
18  let ctx = Xenlight.ctx_alloc logger in
19  try
20    let domains = Xenlight.Dominfo.list ctx in
21    List.iter (fun d -> print_dominfo d) domains
22  with Xenlight.Error(err, fn) -> begin
23    printf "Caught Exception: %s: %s\n" (Xenlight.string_of_error err) fn;
24  end
25
26
27