|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 19/30] libxl: ocaml: add xen_console_read
Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>
---
tools/ocaml/libs/xl/xenlight.ml.in | 1 +
tools/ocaml/libs/xl/xenlight.mli.in | 1 +
tools/ocaml/libs/xl/xenlight_stubs.c | 27 +++++++++++++++++++++++++++
3 files changed, 29 insertions(+)
diff --git a/tools/ocaml/libs/xl/xenlight.ml.in
b/tools/ocaml/libs/xl/xenlight.ml.in
index 883df0c..fd5c4ce 100644
--- a/tools/ocaml/libs/xl/xenlight.ml.in
+++ b/tools/ocaml/libs/xl/xenlight.ml.in
@@ -61,5 +61,6 @@ external test_raise_exception: unit -> unit =
"stub_raise_exception"
external send_trigger : ctx -> domid -> trigger -> int -> unit =
"stub_xl_send_trigger"
external send_sysrq : ctx -> domid -> char -> unit = "stub_xl_send_sysrq"
external send_debug_keys : ctx -> string -> unit = "stub_xl_send_debug_keys"
+external xen_console_read : ctx -> string list = "stub_xl_xen_console_read"
let _ = Callback.register_exception "Xenlight.Error" (Error(Fail, ""))
diff --git a/tools/ocaml/libs/xl/xenlight.mli.in
b/tools/ocaml/libs/xl/xenlight.mli.in
index 34b1ce5..11ea43c 100644
--- a/tools/ocaml/libs/xl/xenlight.mli.in
+++ b/tools/ocaml/libs/xl/xenlight.mli.in
@@ -46,3 +46,4 @@ external test_raise_exception: unit -> unit =
"stub_raise_exception"
external send_trigger : ctx -> domid -> trigger -> int -> unit =
"stub_xl_send_trigger"
external send_sysrq : ctx -> domid -> char -> unit = "stub_xl_send_sysrq"
external send_debug_keys : ctx -> string -> unit = "stub_xl_send_debug_keys"
+external xen_console_read : ctx -> string list = "stub_xl_xen_console_read"
diff --git a/tools/ocaml/libs/xl/xenlight_stubs.c
b/tools/ocaml/libs/xl/xenlight_stubs.c
index e801643..cacaaca 100644
--- a/tools/ocaml/libs/xl/xenlight_stubs.c
+++ b/tools/ocaml/libs/xl/xenlight_stubs.c
@@ -557,6 +557,33 @@ value stub_xl_send_debug_keys(value ctx, value keys)
CAMLreturn(Val_unit);
}
+value stub_xl_xen_console_read(value ctx)
+{
+ CAMLparam1(ctx);
+ CAMLlocal3(list, cons, ml_line);
+ int i = 0, ret;
+ char *console[32768], *line;
+ libxl_xen_console_reader *cr;
+
+ cr = libxl_xen_console_read_start(CTX, 0);
+ if (cr)
+ for (i = 0; libxl_xen_console_read_line(CTX, cr, &line) > 0;
i++)
+ console[i] = strdup(line);
+ libxl_xen_console_read_finish(CTX, cr);
+
+ list = Val_emptylist;
+ for (; i > 0; i--) {
+ ml_line = caml_copy_string(console[i - 1]);
+ free(console[i - 1]);
+ cons = caml_alloc(2, 0);
+ Store_field(cons, 0, ml_line); // head
+ Store_field(cons, 1, list); // tail
+ list = cons;
+ }
+
+ CAMLreturn(list);
+}
+
/*
* Local variables:
* indent-tabs-mode: t
--
1.7.10.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |