Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Dec 2013 12:21:02 +0100
From:      Roger Pau Monne <roger.pau@citrix.com>
To:        <freebsd-xen@freebsd.org>, <freebsd-current@freebsd.org>, <xen-devel@lists.xenproject.org>, <gibbs@freebsd.org>, <jhb@freebsd.org>, <kib@freebsd.org>, <julien.grall@citrix.com>
Cc:        Roger Pau Monne <roger.pau@citrix.com>
Subject:   [PATCH RFC 13/13] xenstore: changes needed to boot in Dom0 mode
Message-ID:  <1387884062-41154-14-git-send-email-roger.pau@citrix.com>
In-Reply-To: <1387884062-41154-1-git-send-email-roger.pau@citrix.com>
References:  <1387884062-41154-1-git-send-email-roger.pau@citrix.com>

next in thread | previous in thread | raw e-mail | index | archive | help
This patch includes changes to xenstore in order to boot as Dom0. This
is different from booting as a guest, since when booted as Dom0
xenstore is not available. This patch sets up a memory page, an
event channel for xenstore and disables xenbus device probing at boot.
It contains a workaround for xs_watch, that should be fixed when we
are able to start xenstored from Dom0.
---
 sys/xen/xenbus/xenbusb.c    |    6 ++++--
 sys/xen/xenstore/xenstore.c |   22 ++++++++++++++++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/sys/xen/xenbus/xenbusb.c b/sys/xen/xenbus/xenbusb.c
index 1f84795..11be0f5 100644
--- a/sys/xen/xenbus/xenbusb.c
+++ b/sys/xen/xenbus/xenbusb.c
@@ -760,8 +760,10 @@ xenbusb_attach(device_t dev, char *bus_node, u_int id_components)
 	 * bus when they are dynamically attached to us
 	 * by a Xen management action.
 	 */
-	(void)xenbusb_enumerate_bus(xbs);
-	xenbusb_probe_children(dev);
+	if (!xen_initial_domain()) {
+		(void)xenbusb_enumerate_bus(xbs);
+		xenbusb_probe_children(dev);
+	}
 
 	xbs->xbs_device_watch.node = bus_node;
 	xbs->xbs_device_watch.callback = xenbusb_devices_changed;
diff --git a/sys/xen/xenstore/xenstore.c b/sys/xen/xenstore/xenstore.c
index 2893c84..bde3f5d 100644
--- a/sys/xen/xenstore/xenstore.c
+++ b/sys/xen/xenstore/xenstore.c
@@ -1144,6 +1144,24 @@ xs_attach(device_t dev)
 		xs.gpfn = hvm_get_parameter(HVM_PARAM_STORE_PFN);
 		xen_store = pmap_mapdev(xs.gpfn * PAGE_SIZE, PAGE_SIZE);
 	} else if (xen_pv_domain()) {
+		if (!HYPERVISOR_start_info->store_evtchn) {
+			struct evtchn_alloc_unbound alloc_unbound;
+
+			/* Allocate a local event channel for xenstore */
+			alloc_unbound.dom        = DOMID_SELF;
+			alloc_unbound.remote_dom = DOMID_SELF;
+			error = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound,
+			                                    &alloc_unbound);
+			if (error)
+				panic("unable to alloc event channel for Dom0: %d",
+				      error);
+
+			HYPERVISOR_start_info->store_evtchn = alloc_unbound.port;
+
+			/* Allocate memory for the xs shared ring */
+			xen_store = malloc(PAGE_SIZE, M_XENSTORE,
+			                   M_WAITOK | M_ZERO);
+		}
 		xs.evtchn = HYPERVISOR_start_info->store_evtchn;
 	} else {
 		panic("Unknown domain type, cannot initialize xenstore\n");
@@ -1579,6 +1597,10 @@ xs_register_watch(struct xs_watch *watch)
 	char token[sizeof(watch) * 2 + 1];
 	int error;
 
+	/* XXX: this is a hack until we get xenstored working */
+	if (xen_initial_domain())
+		return (0);
+
 	sprintf(token, "%lX", (long)watch);
 
 	sx_slock(&xs.suspend_mutex);
-- 
1.7.7.5 (Apple Git-26)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1387884062-41154-14-git-send-email-roger.pau>