Files
xen/tools/ocaml/test/list_domains.ml
T
Christian Lindig f99941871a tools/ocaml: cleanup to reduce compiler warnings
This commit cleans up code to reduce compiler warnings:

* remove unused open statements (warning 33)
* remove unused 'rec' declarations (warnign 39)
* remove unused type declarations (warning 34)
* mark unused variables with an underscore (warning 27)
* mark unused value declarations with an underscore (warning 32)

This commit does not include changes to fix compiler warnings 52
(matching against strings in exceptions). These changes have no impact
on functionality.

Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
2018-11-14 18:22:09 +00:00

27 lines
947 B
OCaml

open Printf
let bool_as_char b c = if b then c else '-'
let print_dominfo dominfo =
let id = dominfo.Xenlight.Dominfo.domid
and running = bool_as_char dominfo.Xenlight.Dominfo.running 'r'
and blocked = bool_as_char dominfo.Xenlight.Dominfo.blocked 'b'
and paused = bool_as_char dominfo.Xenlight.Dominfo.paused 'p'
and shutdown = bool_as_char dominfo.Xenlight.Dominfo.shutdown 's'
and dying = bool_as_char dominfo.Xenlight.Dominfo.dying 'd'
and memory = dominfo.Xenlight.Dominfo.current_memkb
in
printf "Dom %d: %c%c%c%c%c %LdKB\n" id running blocked paused shutdown dying memory
let _ =
let logger = Xtl.create_stdio_logger (*~level:Xentoollog.Debug*) () in
let ctx = Xenlight.ctx_alloc logger in
try
let domains = Xenlight.Dominfo.list ctx in
List.iter (fun d -> print_dominfo d) domains
with Xenlight.Error(err, fn) -> begin
printf "Caught Exception: %s: %s\n" (Xenlight.string_of_error err) fn;
end