[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Add @introduceDomain event-watch and replace consoled watch on /console.



# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID 22599cd6aae053fc196ba630fc9d0a253e03b90b
# Parent  7f941f9c237bcb587731fdd61fc7b45790152513
Add @introduceDomain event-watch and replace consoled watch on /console.
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r 7f941f9c237b -r 22599cd6aae0 tools/console/daemon/io.c
--- a/tools/console/daemon/io.c Mon Sep  5 18:55:08 2005
+++ b/tools/console/daemon/io.c Mon Sep  5 19:43:04 2005
@@ -212,12 +212,10 @@
 
 static int domain_create_ring(struct domain *dom)
 {
-       char *dompath, *path;
+       char *dompath;
        int err;
 
-       asprintf(&path, "/console/%d/domain", dom->domid);
-       dompath = xs_read(xs, path, NULL);
-       free(path);
+       dompath = xs_get_domain_path(xs, dom->domid);
        if (!dompath)
                return ENOENT;
 
@@ -452,6 +450,7 @@
                if (dom && (dom->evtchn_fd == -1 || dom->page == NULL))
                        domain_create_ring(dom);
        }
+       enum_domains();
 
        xs_acknowledge_watch(xs, vec[1]);
        free(vec);
diff -r 7f941f9c237b -r 22599cd6aae0 tools/console/daemon/utils.c
--- a/tools/console/daemon/utils.c      Mon Sep  5 18:55:08 2005
+++ b/tools/console/daemon/utils.c      Mon Sep  5 19:43:04 2005
@@ -233,8 +233,8 @@
                goto out_close_data;
        }
 
-       if (!xs_watch(xs, "/console", "console")) {
-               dolog(LOG_ERR, "xenstore watch on /console fails.");
+       if (!xs_watch(xs, "@introduceDomain", "console")) {
+               dolog(LOG_ERR, "xenstore watch on @introduceDomain fails.");
                goto out_close_data;
        }
 
diff -r 7f941f9c237b -r 22599cd6aae0 tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c   Mon Sep  5 18:55:08 2005
+++ b/tools/xenstore/xenstored_core.c   Mon Sep  5 19:43:04 2005
@@ -826,6 +826,15 @@
         * which case we return EACCES even if it's ENOENT or EIO. */
        errno = errno_from_parents(conn, node, errno);
        return false;
+}
+
+bool check_event_node(const char *node)
+{
+       if (!node || !strstarts(node, "@")) {
+               errno = EINVAL;
+               return false;
+       }
+       return true;
 }
 
 static void send_directory(struct connection *conn, const char *node)
diff -r 7f941f9c237b -r 22599cd6aae0 tools/xenstore/xenstored_core.h
--- a/tools/xenstore/xenstored_core.h   Mon Sep  5 18:55:08 2005
+++ b/tools/xenstore/xenstored_core.h   Mon Sep  5 19:43:04 2005
@@ -133,6 +133,9 @@
 bool check_node_perms(struct connection *conn, const char *node,
                      enum xs_perm_type perm);
 
+/* Check if node is an event node. */
+bool check_event_node(const char *node);
+
 /* Path to this node outside transaction. */
 char *node_dir_outside_transaction(const char *node);
 
diff -r 7f941f9c237b -r 22599cd6aae0 tools/xenstore/xenstored_domain.c
--- a/tools/xenstore/xenstored_domain.c Mon Sep  5 18:55:08 2005
+++ b/tools/xenstore/xenstored_domain.c Mon Sep  5 19:43:04 2005
@@ -33,6 +33,7 @@
 #include "talloc.h"
 #include "xenstored_core.h"
 #include "xenstored_domain.h"
+#include "xenstored_watch.h"
 #include "xenstored_test.h"
 
 static int *xc_handle;
@@ -308,6 +309,9 @@
 
        /* Now domain belongs to its connection. */
        talloc_steal(domain->conn, domain);
+
+       fire_watches(conn, "@introduceDomain", false);
+
        send_ack(conn, XS_INTRODUCE);
 }
 
diff -r 7f941f9c237b -r 22599cd6aae0 tools/xenstore/xenstored_watch.c
--- a/tools/xenstore/xenstored_watch.c  Mon Sep  5 18:55:08 2005
+++ b/tools/xenstore/xenstored_watch.c  Mon Sep  5 19:43:04 2005
@@ -103,7 +103,8 @@
        /* Check read permission: no permission, no watch event.
         * If it doesn't exist, we need permission to read parent.
         */
-       if (!check_node_perms(conn, node, XS_PERM_READ|XS_PERM_ENOENT_OK)) {
+       if (!check_node_perms(conn, node, XS_PERM_READ|XS_PERM_ENOENT_OK) &&
+           !check_event_node(node)) {
                fprintf(stderr, "No permission for %s\n", node);
                return;
        }
@@ -213,11 +214,16 @@
                return;
        }
 
-       relative = !strstarts(vec[0], "/");
-       vec[0] = canonicalize(conn, vec[0]);
-       if (!is_valid_nodename(vec[0])) {
-               send_error(conn, errno);
-               return;
+       if (strstarts(vec[0], "@")) {
+               relative = false;
+               /* check if valid event */
+       } else {
+               relative = !strstarts(vec[0], "/");
+               vec[0] = canonicalize(conn, vec[0]);
+               if (!is_valid_nodename(vec[0])) {
+                       send_error(conn, errno);
+                       return;
+               }
        }
 
        watch = talloc(conn, struct watch);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.