aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xenstore
diff options
context:
space:
mode:
authorOlaf Hering <olaf@aepfle.de>2011-08-09 08:53:40 +0100
committerOlaf Hering <olaf@aepfle.de>2011-08-09 08:53:40 +0100
commit2346303a425b8adcea86397e49739c8ab206903d (patch)
tree9d55311606d44b14eb37f8a5ff0bfc3c125cf4ec /tools/xenstore
parent9f1687725292f90c8bc9e7266f062b2e7ec029df (diff)
downloadxen-2346303a425b8adcea86397e49739c8ab206903d.tar.gz
xen-2346303a425b8adcea86397e49739c8ab206903d.tar.bz2
xen-2346303a425b8adcea86397e49739c8ab206903d.zip
xenstored: allow guests to reintroduce themselves
During kexec all old watches have to be removed, otherwise the new kernel will receive unexpected events. Allow a guest to introduce itself and cleanup all of its watches. Signed-off-by: Olaf Hering <olaf@aepfle.de>
Diffstat (limited to 'tools/xenstore')
-rw-r--r--tools/xenstore/xenstored_domain.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
index 654185d4bb..bfaf8413ed 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -315,7 +315,7 @@ void do_introduce(struct connection *conn, struct buffered_data *in)
{
struct domain *domain;
char *vec[3];
- unsigned int domid;
+ unsigned int domid, target;
unsigned long mfn;
evtchn_port_t port;
int rc;
@@ -326,7 +326,7 @@ void do_introduce(struct connection *conn, struct buffered_data *in)
return;
}
- if (conn->id != 0 || !conn->can_write) {
+ if (!conn->can_write) {
send_error(conn, EACCES);
return;
}
@@ -340,19 +340,26 @@ void do_introduce(struct connection *conn, struct buffered_data *in)
send_error(conn, EINVAL);
return;
}
+ /* Allow guest to reset all watches */
+ if (domid != DOMID_SELF && conn->id != 0) {
+ send_error(conn, EACCES);
+ return;
+ }
- domain = find_domain_by_domid(domid);
+ target = domid == DOMID_SELF ? conn->id : domid;
+
+ domain = find_domain_by_domid(target);
if (domain == NULL) {
interface = xc_map_foreign_range(
- *xc_handle, domid,
+ *xc_handle, target,
getpagesize(), PROT_READ|PROT_WRITE, mfn);
if (!interface) {
send_error(conn, errno);
return;
}
/* Hang domain off "in" until we're finished. */
- domain = new_domain(in, domid, port);
+ domain = new_domain(in, target, port);
if (!domain) {
munmap(interface, getpagesize());
send_error(conn, errno);
@@ -365,11 +372,11 @@ void do_introduce(struct connection *conn, struct buffered_data *in)
talloc_steal(domain->conn, domain);
fire_watches(NULL, "@introduceDomain", false);
- } else if ((domain->mfn == mfn) && (domain->conn != conn)) {
+ } else if ((domain->mfn == mfn) && ((domain->conn != conn) || domid == DOMID_SELF)) {
/* Use XS_INTRODUCE for recreating the xenbus event-channel. */
if (domain->port)
xc_evtchn_unbind(xce_handle, domain->port);
- rc = xc_evtchn_bind_interdomain(xce_handle, domid, port);
+ rc = xc_evtchn_bind_interdomain(xce_handle, target, port);
domain->port = (rc == -1) ? 0 : rc;
domain->remote_port = port;
} else {