[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 18/28] libxl: ocaml: add xen_console_read
[...] > >> +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); > > > > Is it obvious why i is always < 32768? Or is 32768 "too big to fail"? > > (Sorry, couldn't resist) > > This is 32K entries of 4 or 8 bytes (for 32/64bit system), meaning 128K or > 256K of data on the stack. > > I am surprised that this didn't segfault instantly, but this does seem an > unreasonably large amount of data, especially for some library bindings. I basically copied the value from the libxc bindings without thinking too much about it (although a static variable is used there)...: #define RING_SIZE 32768 static char ring[RING_SIZE]; CAMLprim value stub_xc_readconsolering(value xch) { unsigned int size = RING_SIZE - 1; char *ring_ptr = ring; int retval; CAMLparam1(xch); caml_enter_blocking_section(); retval = xc_readconsolering(_H(xch), ring_ptr, &size, 0, 0, NULL); caml_leave_blocking_section(); if (retval) failwith_xc(_H(xch)); ring[size] = '\0'; CAMLreturn(caml_copy_string(ring)); } > If you want to end up with a list of lines, I would suggest using my patch > series to grab the entire console ring at once, counting the number of '\n's > present and working with that. I am happy enough to just get the entire ring, which is what the old xc binding did. Is there a libxl function that does this, or is this something new in your patch? Cheers, Rob _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |