Commit e4184aaf authored by Daniel De Graaf's avatar Daniel De Graaf Committed by Konrad Rzeszutek Wilk

xenbus: don't rely on xen_initial_domain to detect local xenstore

The xenstore daemon does not have to run in the xen initial domain;
however, Linux currently uses xen_initial_domain to test if a loopback
event channel should be used instead of the event channel provided in
Xen's start_info structure. Instead, if the event channel passed in the
start_info structure is not valid, assume that this domain will run
xenstored locally and set up the event channel.
Signed-off-by: default avatarDaniel De Graaf <dgdegra@tycho.nsa.gov>
Reviewed-by: default avatarIan Campbell <Ian.Campbell@citrix.com>
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
parent 77447991
...@@ -696,64 +696,74 @@ static int __init xenbus_probe_initcall(void) ...@@ -696,64 +696,74 @@ static int __init xenbus_probe_initcall(void)
device_initcall(xenbus_probe_initcall); device_initcall(xenbus_probe_initcall);
static int __init xenbus_init(void) /* Set up event channel for xenstored which is run as a local process
* (this is normally used only in dom0)
*/
static int __init xenstored_local_init(void)
{ {
int err = 0; int err = 0;
unsigned long page = 0; unsigned long page = 0;
struct evtchn_alloc_unbound alloc_unbound;
DPRINTK(""); /* Allocate Xenstore page */
page = get_zeroed_page(GFP_KERNEL);
if (!page)
goto out_err;
err = -ENODEV; xen_store_mfn = xen_start_info->store_mfn =
if (!xen_domain()) pfn_to_mfn(virt_to_phys((void *)page) >>
return err; PAGE_SHIFT);
/* /* Next allocate a local port which xenstored can bind to */
* Domain0 doesn't have a store_evtchn or store_mfn yet. alloc_unbound.dom = DOMID_SELF;
*/ alloc_unbound.remote_dom = DOMID_SELF;
if (xen_initial_domain()) {
struct evtchn_alloc_unbound alloc_unbound;
/* Allocate Xenstore page */ err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound,
page = get_zeroed_page(GFP_KERNEL); &alloc_unbound);
if (!page) if (err == -ENOSYS)
goto out_error; goto out_err;
xen_store_mfn = xen_start_info->store_mfn = BUG_ON(err);
pfn_to_mfn(virt_to_phys((void *)page) >> xen_store_evtchn = xen_start_info->store_evtchn =
PAGE_SHIFT); alloc_unbound.port;
/* Next allocate a local port which xenstored can bind to */ return 0;
alloc_unbound.dom = DOMID_SELF;
alloc_unbound.remote_dom = DOMID_SELF;
err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, out_err:
&alloc_unbound); if (page != 0)
if (err == -ENOSYS) free_page(page);
goto out_error; return err;
}
BUG_ON(err); static int __init xenbus_init(void)
xen_store_evtchn = xen_start_info->store_evtchn = {
alloc_unbound.port; int err = 0;
xen_store_interface = mfn_to_virt(xen_store_mfn); if (!xen_domain())
return -ENODEV;
if (xen_hvm_domain()) {
uint64_t v = 0;
err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v);
if (err)
goto out_error;
xen_store_evtchn = (int)v;
err = hvm_get_parameter(HVM_PARAM_STORE_PFN, &v);
if (err)
goto out_error;
xen_store_mfn = (unsigned long)v;
xen_store_interface = ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE);
} else { } else {
if (xen_hvm_domain()) { xen_store_evtchn = xen_start_info->store_evtchn;
uint64_t v = 0; xen_store_mfn = xen_start_info->store_mfn;
err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v); if (xen_store_evtchn)
if (err) xenstored_ready = 1;
goto out_error; else {
xen_store_evtchn = (int)v; err = xenstored_local_init();
err = hvm_get_parameter(HVM_PARAM_STORE_PFN, &v);
if (err) if (err)
goto out_error; goto out_error;
xen_store_mfn = (unsigned long)v;
xen_store_interface = ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE);
} else {
xen_store_evtchn = xen_start_info->store_evtchn;
xen_store_mfn = xen_start_info->store_mfn;
xen_store_interface = mfn_to_virt(xen_store_mfn);
xenstored_ready = 1;
} }
xen_store_interface = mfn_to_virt(xen_store_mfn);
} }
/* Initialize the interface to xenstore. */ /* Initialize the interface to xenstore. */
...@@ -772,12 +782,7 @@ static int __init xenbus_init(void) ...@@ -772,12 +782,7 @@ static int __init xenbus_init(void)
proc_mkdir("xen", NULL); proc_mkdir("xen", NULL);
#endif #endif
return 0; out_error:
out_error:
if (page != 0)
free_page(page);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment