HVM debug console ring for PV (Windows) drivers Creates a shared memory ring buffer and event channel in HVM domains for passing debug messages from PV drivers on HVM guests For use with the Windows PV drivers (xevtchn, xenutil, ...) Uses standard console (libxl_device_console_add) creation functions Signed-off-by: Owen Smith <owen.smith@citrix.com> _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Stefano Stabellini
2010-Jul-28 17:15 UTC
Re: [Xen-devel] [PATCH] HVM debug console support (v3)
On Wed, 28 Jul 2010, Owen Smith wrote:> HVM debug console ring for PV (Windows) drivers > Creates a shared memory ring buffer for passing debug messages from PV drivers on HVM guests > For use with the Windows PV drivers (xevtchn, xenutil, ...) > Uses standard console (libxl_device_console_add) creation functions > > Signed-off-by: Owen Smith <owen.smith@citrix.com> > > diff --git a/tools/libxc/xc_domain_restore.c b/tools/libxc/xc_domain_restore.c > --- a/tools/libxc/xc_domain_restore.c > +++ b/tools/libxc/xc_domain_restore.c > @@ -640,6 +640,7 @@ > uint64_t vcpumap; > uint64_t identpt; > uint64_t vm86_tss; > + uint64_t console_pfn; > } pagebuf_t; > > static int pagebuf_init(pagebuf_t* buf) > @@ -737,6 +738,16 @@ > return -1; > } > return pagebuf_get_one(xch, ctx, buf, fd, dom); > + } else if (count == -8 ) { > + /* Skip padding 4 bytes then read the console pfn location. */ > + if ( read_exact(fd, &buf->console_pfn, sizeof(uint32_t)) || > + read_exact(fd, &buf->console_pfn, sizeof(uint64_t)) ) > + { > + PERROR("error read the address of the console pfn"); > + return -1; > + } > + // DPRINTF("console pfn location: %llx\n", buf->console_pfn); > + return pagebuf_get_one(xch, ctx, buf, fd, dom); > } else if ( (count > MAX_BATCH_SIZE) || (count < 0) ) { > ERROR("Max batch size exceeded (%d). Giving up.", count); > errno = EMSGSIZE; > @@ -1055,6 +1066,7 @@ > pagebuf_t pagebuf; > tailbuf_t tailbuf, tmptail; > void* vcpup; > + uint64_t console_pfn = 0; > > static struct restore_ctx _ctx = { > .live_p2m = NULL, > @@ -1207,6 +1219,8 @@ > xc_set_hvm_param(xch, dom, HVM_PARAM_IDENT_PT, pagebuf.identpt); > if ( pagebuf.vm86_tss ) > xc_set_hvm_param(xch, dom, HVM_PARAM_VM86_TSS, pagebuf.vm86_tss); > + if ( pagebuf.console_pfn ) > + console_pfn = pagebuf.console_pfn; > break; /* our work here is done */ > } > > @@ -1717,6 +1731,19 @@ > } > *store_mfn = tailbuf.u.hvm.magicpfns[2]; > > + if ( console_pfn ) { > + if ( xc_clear_domain_page(xch, dom, console_pfn) ) { > + PERROR("error zeroing console page"); > + goto out; > + } > + if ( (frc = xc_set_hvm_param(xch, dom, > + HVM_PARAM_CONSOLE_PFN, console_pfn)) ) { > + PERROR("error setting HVM param: %i", frc); > + goto out; > + } > + *console_mfn = console_pfn; > + } > + > frc = xc_domain_hvm_setcontext(xch, dom, tailbuf.u.hvm.hvmbuf, > tailbuf.u.hvm.reclen); > if ( frc ) > diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c > --- a/tools/libxc/xc_domain_save.c > +++ b/tools/libxc/xc_domain_save.c > @@ -1587,6 +1587,17 @@ > PERROR("Error when writing the vm86 TSS for guest"); > goto out; > } > + > + chunk.id = -8; > + xc_get_hvm_param(xch, dom, HVM_PARAM_CONSOLE_PFN, > + (unsigned long *)&chunk.data); > + > + if ( (chunk.data != 0) && > + wrexact(io_fd, &chunk, sizeof(chunk)) ) > + { > + PERROR("Error when writing the console pfn for guest"); > + goto out; > + } > } > > /* Zero terminate */ > diff --git a/tools/libxc/xc_hvm_build.c b/tools/libxc/xc_hvm_build.c > --- a/tools/libxc/xc_hvm_build.c > +++ b/tools/libxc/xc_hvm_build.c > @@ -28,7 +28,8 @@ > #define SPECIALPAGE_XENSTORE 1 > #define SPECIALPAGE_IOREQ 2 > #define SPECIALPAGE_IDENT_PT 3 > -#define NR_SPECIAL_PAGES 4 > +#define SPECIALPAGE_CONSOLE 4 > +#define NR_SPECIAL_PAGES 5 > #define special_pfn(x) (0xff000u - NR_SPECIAL_PAGES + (x)) > > static void build_hvm_info(void *hvm_info_page, uint64_t mem_size) > @@ -354,6 +355,8 @@ > special_pfn(SPECIALPAGE_BUFIOREQ)); > xc_set_hvm_param(xch, dom, HVM_PARAM_IOREQ_PFN, > special_pfn(SPECIALPAGE_IOREQ)); > + xc_set_hvm_param(xch, dom, HVM_PARAM_CONSOLE_PFN, > + special_pfn(SPECIALPAGE_CONSOLE)); > > /* > * Identity-map page table is required for running with CR0.PG=0 when > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c > --- a/tools/libxl/libxl.c > +++ b/tools/libxl/libxl.c > @@ -260,6 +260,7 @@ > char **vments = NULL, **localents = NULL; > struct timeval start_time; > int i, ret; > + libxl_device_console console; > > ret = build_pre(ctx, domid, info, state); > if (ret) goto out; > @@ -277,6 +278,9 @@ > vments[3] = "hvm"; > vments[4] = "start_time"; > vments[5] = libxl_sprintf(ctx, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000); > + // add debug channel info > + libxl_device_console_init(&console, domid, state); > + libxl_device_console_add(ctx, domid, &console); > } else { > ret = build_pv(ctx, domid, info, state); > if (ret) goto out; > @@ -314,6 +318,7 @@ > char **vments = NULL, **localents = NULL; > struct timeval start_time; > int i, ret, esave, flags; > + libxl_device_console console; > > ret = build_pre(ctx, domid, info, state); > if (ret) goto out; > @@ -331,6 +336,9 @@ > vments[3] = "hvm"; > vments[4] = "start_time"; > vments[5] = libxl_sprintf(ctx, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000); > + // add debug channel info > + libxl_device_console_init(&console, domid, state); > + libxl_device_console_add(ctx, domid, &console);These are the right calls but this is not the right place! These calls are supposed to be made by xl_cmdimpl.c, like in the PV case.> } else { > vments = libxl_calloc(ctx, 11, sizeof(char *)); > i = 0; > @@ -1928,6 +1936,16 @@ > > > /******************************************************************************/ > +void libxl_device_console_init(libxl_device_console *console, uint32_t domid, libxl_domain_build_state *state) > +{ > + memset(console, 0, sizeof(libxl_device_console)); > + > + console->build_state = state; > + console->constype = CONSTYPE_XENCONSOLED; > + console->devid = 0; > + console->domid = domid; > +} > +After you move the function calls to xl_cmdimpl.c, you won''t need this function anymore. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel