There is currently an asymmetry between HVM where the page is cleared and PV where the contents are restored.
Add xc_dom_console_set_disconnected() to only set the connection flag for PV guests. xenconsoled is responsible for setting the console connected when it attaches. Signed-off-by: Jason Andryuk <jason.andr...@amd.com> --- v2: New --- tools/include/xenguest.h | 2 ++ tools/libs/guest/xg_dom_boot.c | 24 ++++++++++++++++++++---- tools/libs/guest/xg_sr_restore_x86_hvm.c | 2 +- tools/libs/guest/xg_sr_restore_x86_pv.c | 1 + 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/tools/include/xenguest.h b/tools/include/xenguest.h index 1d5a6d3509..c88958faa9 100644 --- a/tools/include/xenguest.h +++ b/tools/include/xenguest.h @@ -337,6 +337,8 @@ int xc_dom_boot_image(struct xc_dom_image *dom); int xc_dom_compat_check(struct xc_dom_image *dom); int xc_dom_console_init(xc_interface *xch, uint32_t guest_domid, xen_pfn_t console_gfn); +int xc_dom_console_set_disconnected(xc_interface *xch, uint32_t guest_domid, + xen_pfn_t console_gfn); int xc_dom_gnttab_init(struct xc_dom_image *dom); int xc_dom_gnttab_seed(xc_interface *xch, uint32_t guest_domid, bool is_hvm, diff --git a/tools/libs/guest/xg_dom_boot.c b/tools/libs/guest/xg_dom_boot.c index b5f248e642..f51b6a78c8 100644 --- a/tools/libs/guest/xg_dom_boot.c +++ b/tools/libs/guest/xg_dom_boot.c @@ -428,9 +428,10 @@ int xc_dom_gnttab_init(struct xc_dom_image *dom) dom->console_domid, dom->xenstore_domid); } -int xc_dom_console_init(xc_interface *xch, - uint32_t domid, - unsigned long dst_pfn) +static int dom_console_init(xc_interface *xch, + uint32_t domid, + unsigned long dst_pfn, + bool clear) { const size_t size = PAGE_SIZE; struct xencons_interface *xencons = xc_map_foreign_range( @@ -439,7 +440,8 @@ int xc_dom_console_init(xc_interface *xch, if ( xencons == NULL ) return -1; - memset(xencons, 0, size); + if (clear) + memset(xencons, 0, size); xencons->connection = XENCONSOLE_DISCONNECTED; munmap(xencons, size); @@ -447,6 +449,20 @@ int xc_dom_console_init(xc_interface *xch, return 0; } +int xc_dom_console_init(xc_interface *xch, + uint32_t domid, + unsigned long dst_pfn) +{ + return dom_console_init(xch, domid, dst_pfn, true); +} + +int xc_dom_console_set_disconnected(xc_interface *xch, + uint32_t domid, + unsigned long dst_pfn) +{ + return dom_console_init(xch, domid, dst_pfn, false); +} + /* * Local variables: * mode: C diff --git a/tools/libs/guest/xg_sr_restore_x86_hvm.c b/tools/libs/guest/xg_sr_restore_x86_hvm.c index d6ea6f3012..a5d1511fde 100644 --- a/tools/libs/guest/xg_sr_restore_x86_hvm.c +++ b/tools/libs/guest/xg_sr_restore_x86_hvm.c @@ -62,7 +62,7 @@ static int handle_hvm_params(struct xc_sr_context *ctx, { case HVM_PARAM_CONSOLE_PFN: ctx->restore.console_gfn = entry->value; - xc_clear_domain_page(xch, ctx->domid, entry->value); + xc_dom_console_init(xch, ctx->domid, entry->value); break; case HVM_PARAM_STORE_PFN: ctx->restore.xenstore_gfn = entry->value; diff --git a/tools/libs/guest/xg_sr_restore_x86_pv.c b/tools/libs/guest/xg_sr_restore_x86_pv.c index 9cd6a88022..876748c11e 100644 --- a/tools/libs/guest/xg_sr_restore_x86_pv.c +++ b/tools/libs/guest/xg_sr_restore_x86_pv.c @@ -208,6 +208,7 @@ static int process_start_info(struct xc_sr_context *ctx, goto err; } + xc_dom_console_set_disconnected(xch, ctx->domid, mfn); ctx->restore.console_gfn = mfn; SET_FIELD(guest_start_info, console.domU.mfn, mfn, ctx->x86.pv.width); SET_FIELD(guest_start_info, console.domU.evtchn, -- 2.50.1