# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1281116102 -3600
# Node ID fe930e1b2ce8f205fb368d0cc86876cc54d761a9
# Parent cd606ea8f96351ce48ce4667e4e48b8edf3c19de
# Parent 6b28b2dac7dd4a78585e43ac901e52b4ebe94387
Merge
---
tools/libxc/xc_domain_restore.c | 27 +++++++++++++++++++++++++++
tools/libxc/xc_domain_save.c | 11 +++++++++++
tools/libxc/xc_hvm_build.c | 5 ++++-
tools/libxl/libxl_dom.c | 2 +-
tools/libxl/libxl_internal.h | 3 ++-
tools/libxl/libxl_utils.c | 11 +++++++----
tools/libxl/xenguest.c | 5 ++++-
tools/libxl/xl_cmdimpl.c | 3 +++
xen/include/public/hvm/params.h | 6 +++++-
9 files changed, 64 insertions(+), 9 deletions(-)
diff -r cd606ea8f963 -r fe930e1b2ce8 tools/libxc/xc_domain_restore.c
--- a/tools/libxc/xc_domain_restore.c Fri Aug 06 16:49:16 2010 +0100
+++ b/tools/libxc/xc_domain_restore.c Fri Aug 06 18:35:02 2010 +0100
@@ -640,6 +640,7 @@ typedef struct {
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 @@ static int pagebuf_get_one(xc_interface
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 @@ int xc_domain_restore(xc_interface *xch,
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 @@ int xc_domain_restore(xc_interface *xch,
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 @@ int xc_domain_restore(xc_interface *xch,
}
*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 -r cd606ea8f963 -r fe930e1b2ce8 tools/libxc/xc_domain_save.c
--- a/tools/libxc/xc_domain_save.c Fri Aug 06 16:49:16 2010 +0100
+++ b/tools/libxc/xc_domain_save.c Fri Aug 06 18:35:02 2010 +0100
@@ -1587,6 +1587,17 @@ int xc_domain_save(xc_interface *xch, in
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 -r cd606ea8f963 -r fe930e1b2ce8 tools/libxc/xc_hvm_build.c
--- a/tools/libxc/xc_hvm_build.c Fri Aug 06 16:49:16 2010 +0100
+++ b/tools/libxc/xc_hvm_build.c Fri Aug 06 18:35:02 2010 +0100
@@ -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 @@ static int setup_guest(xc_interface *xch
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 -r cd606ea8f963 -r fe930e1b2ce8 tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c Fri Aug 06 16:49:16 2010 +0100
+++ b/tools/libxl/libxl_dom.c Fri Aug 06 18:35:02 2010 +0100
@@ -237,7 +237,7 @@ int build_hvm(libxl_ctx *ctx, uint32_t d
return ERROR_FAIL;
}
ret = hvm_build_set_params(ctx->xch, domid, info, state->store_port,
- &state->store_mfn);
+ &state->store_mfn, state->console_port,
&state->console_mfn);
if (ret) {
XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, ret, "hvm build set params failed");
return ERROR_FAIL;
diff -r cd606ea8f963 -r fe930e1b2ce8 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Fri Aug 06 16:49:16 2010 +0100
+++ b/tools/libxl/libxl_internal.h Fri Aug 06 18:35:02 2010 +0100
@@ -173,7 +173,8 @@ int libxl_device_pci_reset(libxl_ctx *ct
/* from xenguest (helper */
int hvm_build_set_params(xc_interface *handle, uint32_t domid,
libxl_domain_build_info *info,
- int store_evtchn, unsigned long *store_mfn);
+ int store_evtchn, unsigned long *store_mfn,
+ int console_evtchn, unsigned long *console_mfn);
/* xl_exec */
diff -r cd606ea8f963 -r fe930e1b2ce8 tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c Fri Aug 06 16:49:16 2010 +0100
+++ b/tools/libxl/libxl_utils.c Fri Aug 06 18:35:02 2010 +0100
@@ -101,6 +101,7 @@ int libxl_name_to_poolid(libxl_ctx *ctx,
int i, nb_pools;
char *poolname;
libxl_poolinfo *poolinfo;
+ int ret = -1;
poolinfo = libxl_list_pool(ctx, &nb_pools);
if (!poolinfo)
@@ -112,10 +113,12 @@ int libxl_name_to_poolid(libxl_ctx *ctx,
continue;
if (strcmp(poolname, name) == 0) {
*poolid = poolinfo[i].poolid;
- return 0;
- }
- }
- return -1;
+ ret = 0;
+ break;
+ }
+ }
+ free(poolinfo);
+ return ret;
}
int libxl_get_stubdom_id(libxl_ctx *ctx, int guest_domid)
diff -r cd606ea8f963 -r fe930e1b2ce8 tools/libxl/xenguest.c
--- a/tools/libxl/xenguest.c Fri Aug 06 16:49:16 2010 +0100
+++ b/tools/libxl/xenguest.c Fri Aug 06 18:35:02 2010 +0100
@@ -23,7 +23,8 @@
int hvm_build_set_params(xc_interface *handle, uint32_t domid,
libxl_domain_build_info *info,
- int store_evtchn, unsigned long *store_mfn)
+ int store_evtchn, unsigned long *store_mfn,
+ int console_evtchn, unsigned long *console_mfn)
{
struct hvm_info_table *va_hvm;
uint8_t *va_map, sum;
@@ -46,6 +47,7 @@ int hvm_build_set_params(xc_interface *h
munmap(va_map, XC_PAGE_SIZE);
xc_get_hvm_param(handle, domid, HVM_PARAM_STORE_PFN, store_mfn);
+ xc_get_hvm_param(handle, domid, HVM_PARAM_CONSOLE_PFN, console_mfn);
xc_set_hvm_param(handle, domid, HVM_PARAM_PAE_ENABLED, info->u.hvm.pae);
#if defined(__i386__) || defined(__x86_64__)
xc_set_hvm_param(handle, domid, HVM_PARAM_VIRIDIAN, info->u.hvm.viridian);
@@ -54,5 +56,6 @@ int hvm_build_set_params(xc_interface *h
xc_set_hvm_param(handle, domid, HVM_PARAM_TIMER_MODE, (unsigned long)
info->u.hvm.timer_mode);
xc_set_hvm_param(handle, domid, HVM_PARAM_VPT_ALIGN, (unsigned long)
info->u.hvm.vpt_align);
xc_set_hvm_param(handle, domid, HVM_PARAM_STORE_EVTCHN, store_evtchn);
+ xc_set_hvm_param(handle, domid, HVM_PARAM_CONSOLE_EVTCHN, console_evtchn);
return 0;
}
diff -r cd606ea8f963 -r fe930e1b2ce8 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Fri Aug 06 16:49:16 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c Fri Aug 06 18:35:02 2010 +0100
@@ -1433,6 +1433,9 @@ start:
}
}
if (d_config.c_info.hvm) {
+ init_console_info(&console, 0, &state);
+ console.domid = domid;
+ libxl_device_console_add(&ctx, domid, &console);
dm_info.domid = domid;
MUST( libxl_create_device_model(&ctx, &dm_info,
d_config.disks, d_config.num_disks,
diff -r cd606ea8f963 -r fe930e1b2ce8 xen/include/public/hvm/params.h
--- a/xen/include/public/hvm/params.h Fri Aug 06 16:49:16 2010 +0100
+++ b/xen/include/public/hvm/params.h Fri Aug 06 18:35:02 2010 +0100
@@ -109,6 +109,10 @@
/* Boolean: Enable aligning all periodic vpts to reduce interrupts */
#define HVM_PARAM_VPT_ALIGN 16
-#define HVM_NR_PARAMS 17
+/* Console debug shared memory ring and event channel */
+#define HVM_PARAM_CONSOLE_PFN 17
+#define HVM_PARAM_CONSOLE_EVTCHN 18
+
+#define HVM_NR_PARAMS 19
#endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|