debuggers.hg
changeset 6668:22599cd6aae0
Add @introduceDomain event-watch and replace consoled watch on /console.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author | cl349@firebug.cl.cam.ac.uk |
---|---|
date | Mon Sep 05 19:43:04 2005 +0000 (2005-09-05) |
parents | 7f941f9c237b |
children | d105692072a4 |
files | tools/console/daemon/io.c tools/console/daemon/utils.c tools/xenstore/xenstored_core.c tools/xenstore/xenstored_core.h tools/xenstore/xenstored_domain.c tools/xenstore/xenstored_watch.c |
line diff
1.1 --- a/tools/console/daemon/io.c Mon Sep 05 18:55:08 2005 +0000 1.2 +++ b/tools/console/daemon/io.c Mon Sep 05 19:43:04 2005 +0000 1.3 @@ -212,12 +212,10 @@ int xs_gather(struct xs_handle *xs, cons 1.4 1.5 static int domain_create_ring(struct domain *dom) 1.6 { 1.7 - char *dompath, *path; 1.8 + char *dompath; 1.9 int err; 1.10 1.11 - asprintf(&path, "/console/%d/domain", dom->domid); 1.12 - dompath = xs_read(xs, path, NULL); 1.13 - free(path); 1.14 + dompath = xs_get_domain_path(xs, dom->domid); 1.15 if (!dompath) 1.16 return ENOENT; 1.17 1.18 @@ -452,6 +450,7 @@ static void handle_xs(int fd) 1.19 if (dom && (dom->evtchn_fd == -1 || dom->page == NULL)) 1.20 domain_create_ring(dom); 1.21 } 1.22 + enum_domains(); 1.23 1.24 xs_acknowledge_watch(xs, vec[1]); 1.25 free(vec);
2.1 --- a/tools/console/daemon/utils.c Mon Sep 05 18:55:08 2005 +0000 2.2 +++ b/tools/console/daemon/utils.c Mon Sep 05 19:43:04 2005 +0000 2.3 @@ -233,8 +233,8 @@ bool xen_setup(void) 2.4 goto out_close_data; 2.5 } 2.6 2.7 - if (!xs_watch(xs, "/console", "console")) { 2.8 - dolog(LOG_ERR, "xenstore watch on /console fails."); 2.9 + if (!xs_watch(xs, "@introduceDomain", "console")) { 2.10 + dolog(LOG_ERR, "xenstore watch on @introduceDomain fails."); 2.11 goto out_close_data; 2.12 } 2.13
3.1 --- a/tools/xenstore/xenstored_core.c Mon Sep 05 18:55:08 2005 +0000 3.2 +++ b/tools/xenstore/xenstored_core.c Mon Sep 05 19:43:04 2005 +0000 3.3 @@ -828,6 +828,15 @@ bool check_node_perms(struct connection 3.4 return false; 3.5 } 3.6 3.7 +bool check_event_node(const char *node) 3.8 +{ 3.9 + if (!node || !strstarts(node, "@")) { 3.10 + errno = EINVAL; 3.11 + return false; 3.12 + } 3.13 + return true; 3.14 +} 3.15 + 3.16 static void send_directory(struct connection *conn, const char *node) 3.17 { 3.18 char *path, *reply;
4.1 --- a/tools/xenstore/xenstored_core.h Mon Sep 05 18:55:08 2005 +0000 4.2 +++ b/tools/xenstore/xenstored_core.h Mon Sep 05 19:43:04 2005 +0000 4.3 @@ -133,6 +133,9 @@ char *canonicalize(struct connection *co 4.4 bool check_node_perms(struct connection *conn, const char *node, 4.5 enum xs_perm_type perm); 4.6 4.7 +/* Check if node is an event node. */ 4.8 +bool check_event_node(const char *node); 4.9 + 4.10 /* Path to this node outside transaction. */ 4.11 char *node_dir_outside_transaction(const char *node); 4.12
5.1 --- a/tools/xenstore/xenstored_domain.c Mon Sep 05 18:55:08 2005 +0000 5.2 +++ b/tools/xenstore/xenstored_domain.c Mon Sep 05 19:43:04 2005 +0000 5.3 @@ -33,6 +33,7 @@ 5.4 #include "talloc.h" 5.5 #include "xenstored_core.h" 5.6 #include "xenstored_domain.h" 5.7 +#include "xenstored_watch.h" 5.8 #include "xenstored_test.h" 5.9 5.10 static int *xc_handle; 5.11 @@ -308,6 +309,9 @@ void do_introduce(struct connection *con 5.12 5.13 /* Now domain belongs to its connection. */ 5.14 talloc_steal(domain->conn, domain); 5.15 + 5.16 + fire_watches(conn, "@introduceDomain", false); 5.17 + 5.18 send_ack(conn, XS_INTRODUCE); 5.19 } 5.20
6.1 --- a/tools/xenstore/xenstored_watch.c Mon Sep 05 18:55:08 2005 +0000 6.2 +++ b/tools/xenstore/xenstored_watch.c Mon Sep 05 19:43:04 2005 +0000 6.3 @@ -103,7 +103,8 @@ static void add_event(struct connection 6.4 /* Check read permission: no permission, no watch event. 6.5 * If it doesn't exist, we need permission to read parent. 6.6 */ 6.7 - if (!check_node_perms(conn, node, XS_PERM_READ|XS_PERM_ENOENT_OK)) { 6.8 + if (!check_node_perms(conn, node, XS_PERM_READ|XS_PERM_ENOENT_OK) && 6.9 + !check_event_node(node)) { 6.10 fprintf(stderr, "No permission for %s\n", node); 6.11 return; 6.12 } 6.13 @@ -213,11 +214,16 @@ void do_watch(struct connection *conn, s 6.14 return; 6.15 } 6.16 6.17 - relative = !strstarts(vec[0], "/"); 6.18 - vec[0] = canonicalize(conn, vec[0]); 6.19 - if (!is_valid_nodename(vec[0])) { 6.20 - send_error(conn, errno); 6.21 - return; 6.22 + if (strstarts(vec[0], "@")) { 6.23 + relative = false; 6.24 + /* check if valid event */ 6.25 + } else { 6.26 + relative = !strstarts(vec[0], "/"); 6.27 + vec[0] = canonicalize(conn, vec[0]); 6.28 + if (!is_valid_nodename(vec[0])) { 6.29 + send_error(conn, errno); 6.30 + return; 6.31 + } 6.32 } 6.33 6.34 watch = talloc(conn, struct watch);