Andrew Cooper
2013-Feb-21 15:46 UTC
[PATCH 3 of 5 v2] tools/libxc: Implement xc_readconsolering_buffer()
Functions identically to xc_readconsolering(), but uses a user-provided xc_hypercall_buffer_t to save using a bounce buffer. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> -- Changes since v1: * Reduce xc_readconsolering() to use xc_readconsolering_buffer() diff -r 1ffce9bf90f5 -r 1e6c7f7cec6f tools/libxc/xc_misc.c --- a/tools/libxc/xc_misc.c +++ b/tools/libxc/xc_misc.c @@ -70,13 +70,29 @@ int xc_readconsolering(xc_interface *xch int clear, int incremental, uint32_t *pindex) { int ret; - unsigned int nr_chars = *pnr_chars; - DECLARE_SYSCTL; - DECLARE_HYPERCALL_BOUNCE(buffer, nr_chars, XC_HYPERCALL_BUFFER_BOUNCE_OUT); + DECLARE_HYPERCALL_BOUNCE(buffer, *pnr_chars, XC_HYPERCALL_BUFFER_BOUNCE_OUT); if ( xc_hypercall_bounce_pre(xch, buffer) ) return -1; + ret = xc_readconsolering_buffer(xch, HYPERCALL_BUFFER(buffer), + pnr_chars, clear, incremental, pindex); + + xc_hypercall_bounce_post(xch, buffer); + + return ret; +} + +int xc_readconsolering_buffer(xc_interface *xch, + xc_hypercall_buffer_t *buffer, + unsigned int *pnr_chars, + int clear, int incremental, uint32_t *pindex) +{ + int ret; + unsigned int nr_chars = *pnr_chars; + DECLARE_SYSCTL; + DECLARE_HYPERCALL_BUFFER_ARGUMENT(buffer); + sysctl.cmd = XEN_SYSCTL_readconsole; set_xen_guest_handle(sysctl.u.readconsole.buffer, buffer); sysctl.u.readconsole.count = nr_chars; @@ -95,8 +111,6 @@ int xc_readconsolering(xc_interface *xch *pindex = sysctl.u.readconsole.index; } - xc_hypercall_bounce_post(xch, buffer); - return ret; } diff -r 1ffce9bf90f5 -r 1e6c7f7cec6f tools/libxc/xenctrl.h --- a/tools/libxc/xenctrl.h +++ b/tools/libxc/xenctrl.h @@ -998,6 +998,10 @@ int xc_readconsolering(xc_interface *xch char *buffer, unsigned int *pnr_chars, int clear, int incremental, uint32_t *pindex); +int xc_readconsolering_buffer(xc_interface *xch, + xc_hypercall_buffer_t *buffer, + unsigned int *pnr_chars, + int clear, int incremental, uint32_t *pindex); int xc_consoleringsize(xc_interface *xch, uint64_t * psize); int xc_send_debug_keys(xc_interface *xch, char *keys);
Ian Campbell
2013-Mar-12 17:15 UTC
Re: [PATCH 3 of 5 v2] tools/libxc: Implement xc_readconsolering_buffer()
On Thu, 2013-02-21 at 15:46 +0000, Andrew Cooper wrote:> Functions identically to xc_readconsolering(), but uses a user-provided > xc_hypercall_buffer_t to save using a bounce buffer. > > Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> > > -- > Changes since v1: > * Reduce xc_readconsolering() to use xc_readconsolering_buffer() > > diff -r 1ffce9bf90f5 -r 1e6c7f7cec6f tools/libxc/xc_misc.c > --- a/tools/libxc/xc_misc.c > +++ b/tools/libxc/xc_misc.c > @@ -70,13 +70,29 @@ int xc_readconsolering(xc_interface *xch > int clear, int incremental, uint32_t *pindex) > { > int ret; > - unsigned int nr_chars = *pnr_chars; > - DECLARE_SYSCTL; > - DECLARE_HYPERCALL_BOUNCE(buffer, nr_chars, XC_HYPERCALL_BUFFER_BOUNCE_OUT); > + DECLARE_HYPERCALL_BOUNCE(buffer, *pnr_chars, XC_HYPERCALL_BUFFER_BOUNCE_OUT);While you are hear this could really use a comment (in the header) that *pnr_chars is both an input (buffer size) and an output. Same is true of the new function I think? [...]> diff -r 1ffce9bf90f5 -r 1e6c7f7cec6f tools/libxc/xenctrl.h > --- a/tools/libxc/xenctrl.h > +++ b/tools/libxc/xenctrl.h > @@ -998,6 +998,10 @@ int xc_readconsolering(xc_interface *xch > char *buffer, > unsigned int *pnr_chars, > int clear, int incremental, uint32_t *pindex); > +int xc_readconsolering_buffer(xc_interface *xch, > + xc_hypercall_buffer_t *buffer, > + unsigned int *pnr_chars, > + int clear, int incremental, uint32_t *pindex); > int xc_consoleringsize(xc_interface *xch, uint64_t * psize); > > int xc_send_debug_keys(xc_interface *xch, char *keys);