diff --git a/tools/helpers/Makefile b/tools/helpers/Makefile index 8e42997052..8d78ab1e90 100644 --- a/tools/helpers/Makefile +++ b/tools/helpers/Makefile @@ -46,7 +46,7 @@ init-xenstore-domain: $(INIT_XENSTORE_DOMAIN_OBJS) $(CC) $(LDFLAGS) -o $@ $(INIT_XENSTORE_DOMAIN_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenlight) $(APPEND_LDFLAGS) init-dom0less: $(INIT_DOM0LESS_OBJS) - $(CC) $(LDFLAGS) -o $@ $(INIT_DOM0LESS_OBJS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenevtchn) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) $(LDLIBS_libxenlight) $(LDLIBS_libxenguest) $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) -o $@ $(INIT_DOM0LESS_OBJS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenevtchn) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) $(LDLIBS_libxenlight) $(LDLIBS_libxenguest) $(LDLIBS_libxenforeignmemory) $(APPEND_LDFLAGS) .PHONY: install install: all diff --git a/tools/helpers/init-dom0less.c b/tools/helpers/init-dom0less.c index dc9ccee868..329aa44da6 100644 --- a/tools/helpers/init-dom0less.c +++ b/tools/helpers/init-dom0less.c @@ -9,9 +9,12 @@ #include #include #include +#include #include "init-dom-json.h" +#define XS_CONNECTION_STATE_OFFSET (2068/4) +#define XS_CONNECTION_STATE_RECONNECTING 0x1 #define XENSTORE_PFN_OFFSET 1 #define STR_MAX_LENGTH 64 @@ -215,12 +218,18 @@ err: static int init_domain(struct xs_handle *xsh, libxl_dominfo *info) { struct xc_interface_core *xch; + xenforeignmemory_handle *xfh; libxl_uuid uuid; uint64_t xenstore_evtchn, xenstore_pfn; int rc; + uint32_t *page; printf("Init dom0less domain: %u\n", info->domid); xch = xc_interface_open(0, 0, 0); + xfh = xenforeignmemory_open(0, 0); + + if (xch == NULL || xfh == NULL) + err(1, "Cannot open xc/xenforeignmemory interfaces\n"); rc = xc_hvm_param_get(xch, info->domid, HVM_PARAM_STORE_EVTCHN, &xenstore_evtchn); @@ -235,6 +244,14 @@ static int init_domain(struct xs_handle *xsh, libxl_dominfo *info) return 1; } + page = xenforeignmemory_map(xfh, info->domid, XS_READ | XS_WRITE, 1, &xenstore_pfn, NULL); + if (!page) { + printf("Error mapping xenstore page\n"); + return 1; + } + page[XS_CONNECTION_STATE_OFFSET] = XS_CONNECTION_STATE_RECONNECTING; + xenforeignmemory_unmap(xfh, page, 1); + rc = xc_dom_gnttab_seed(xch, info->domid, true, (xen_pfn_t)-1, xenstore_pfn, 0, 0); if (rc) diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c index 0543f49670..7bb8c64d33 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -494,6 +494,7 @@ static struct domain *introduce_domain(const void *ctx, talloc_steal(domain->conn, domain); /* Notify the domain that xenstore is available */ + interface->connection = 0x0; xenevtchn_notify(xce_handle, domain->port); if (!is_master_domain && !restore)