aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xenstore/xenstored_domain.c
diff options
context:
space:
mode:
authoremellor@ewan <emellor@ewan>2005-10-10 19:04:03 +0100
committeremellor@ewan <emellor@ewan>2005-10-10 19:04:03 +0100
commitbcdb3520757e11d89d2cb16987e23fdd5a8fbe3a (patch)
tree0ba9283802be0c6d5a192a2c79a5c800007a185b /tools/xenstore/xenstored_domain.c
parent99bc4ba13a2cf8dd2ed4ceac43cebbdda4c07bb9 (diff)
downloadxen-bcdb3520757e11d89d2cb16987e23fdd5a8fbe3a.tar.gz
xen-bcdb3520757e11d89d2cb16987e23fdd5a8fbe3a.tar.bz2
xen-bcdb3520757e11d89d2cb16987e23fdd5a8fbe3a.zip
When a domain is introduced to xenstored, check whether this has already
happened, and only return EINVAL if the event channel details have changed. This allows Xend to introduce domains when it starts without having to be concerned about whether xenstored has restarted at the same time. This behaviour used to be subsumed by the bind_interdomain semantics for existing channels, but in the simplification of that interface, the check must now move to userspace. Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools/xenstore/xenstored_domain.c')
-rw-r--r--tools/xenstore/xenstored_domain.c79
1 files changed, 58 insertions, 21 deletions
diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
index e35990b12d..f2b847c4e9 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -53,6 +53,14 @@ struct domain
/* Event channel port */
u16 port;
+ /* The remote end of the event channel, used only to validate
+ repeated domain introductions. */
+ u16 remote_port;
+
+ /* The mfn associated with the event channel, used only to validate
+ repeated domain introductions. */
+ unsigned long mfn;
+
/* Domain path in store. */
char *path;
@@ -322,14 +330,35 @@ static struct domain *new_domain(void *context, domid_t domid,
domain->port = rc;
domain->conn = new_connection(writechn, readchn);
domain->conn->domain = domain;
+
+ domain->remote_port = port;
+ domain->mfn = mfn;
+
return domain;
}
+
+static struct domain *find_domain_by_domid(domid_t domid)
+{
+ struct domain *i;
+
+ list_for_each_entry(i, &domains, list) {
+ if (i->domid == domid)
+ return i;
+ }
+ return NULL;
+}
+
+
/* domid, mfn, evtchn, path */
void do_introduce(struct connection *conn, struct buffered_data *in)
{
struct domain *domain;
char *vec[4];
+ domid_t domid;
+ unsigned long mfn;
+ u16 port;
+ const char *path;
if (get_strings(in, vec, ARRAY_SIZE(vec)) < ARRAY_SIZE(vec)) {
send_error(conn, EINVAL);
@@ -341,36 +370,44 @@ void do_introduce(struct connection *conn, struct buffered_data *in)
return;
}
+ domid = atoi(vec[0]);
+ mfn = atol(vec[1]);
+ port = atoi(vec[2]);
+ path = vec[3];
+
/* Sanity check args. */
- if ((atoi(vec[2]) <= 0) || !is_valid_nodename(vec[3])) {
+ if ((port <= 0) || !is_valid_nodename(path)) {
send_error(conn, EINVAL);
return;
}
- /* Hang domain off "in" until we're finished. */
- domain = new_domain(in, atoi(vec[0]), atol(vec[1]), atol(vec[2]),
- vec[3]);
- if (!domain) {
- send_error(conn, errno);
- return;
- }
- /* Now domain belongs to its connection. */
- talloc_steal(domain->conn, domain);
+ domain = find_domain_by_domid(domid);
- fire_watches(conn, "@introduceDomain", false);
+ if (domain == NULL) {
+ /* Hang domain off "in" until we're finished. */
+ domain = new_domain(in, domid, mfn, port, path);
+ if (!domain) {
+ send_error(conn, errno);
+ return;
+ }
- send_ack(conn, XS_INTRODUCE);
-}
+ /* Now domain belongs to its connection. */
+ talloc_steal(domain->conn, domain);
-static struct domain *find_domain_by_domid(domid_t domid)
-{
- struct domain *i;
-
- list_for_each_entry(i, &domains, list) {
- if (i->domid == domid)
- return i;
+ fire_watches(conn, "@introduceDomain", false);
}
- return NULL;
+ else {
+ /* Check that the given details match the ones we have
+ previously recorded. */
+ if (port != domain->remote_port ||
+ mfn != domain->mfn ||
+ strcmp(path, domain->path) != 0) {
+ send_error(conn, EINVAL);
+ return;
+ }
+ }
+
+ send_ack(conn, XS_INTRODUCE);
}
/* domid */