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

[PATCH v2 7/9] tools/xenstored: expand special watch handling with depth feature


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Juergen Gross <jgross@xxxxxxxx>
  • Date: Tue, 21 Apr 2026 09:42:09 +0200
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References"; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References"
  • Authentication-results: smtp-out2.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=dKdo7mVN
  • Cc: Juergen Gross <jgross@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>
  • Delivery-date: Tue, 21 Apr 2026 07:42:55 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

With XENSTORE_SERVER_FEATURE_WATCHDEPTH available, special watch
handling needs to be extended:

- when a special watch is set with depth = 1, the domid is added to
  the watch event

- it is possible to watch for @releaseDomain/<domid>

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
Reviewed-by: Jason Andryuk <jason.andryuk@xxxxxxx>
---
V2:
- remove stray {} addition (Jason Andryuk)
---
 tools/xenstored/domain.c | 34 ++++++++++++++++++++++++++--------
 1 file changed, 26 insertions(+), 8 deletions(-)

diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index 7f2fa16cf2..a5258dae6d 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -616,7 +616,12 @@ static void domain_tree_remove(struct domain *domain)
        walk_node_tree(domain, NULL, "@introduceDomain", &walkfuncs, domain);
 }
 
-static void fire_special_watches(const char *name)
+#define WATCH_NODOM    1       /* Fire watches without <domid> extension. */
+#define WATCH_DOM      2       /* Fire watches with <domid> extension. */
+#define WATCH_BOTH     (WATCH_NODOM | WATCH_DOM)
+
+static void fire_special_watches(const char *name, unsigned int domid,
+                                unsigned int watchdom_flag)
 {
        void *ctx = talloc_new(NULL);
        const struct node *node;
@@ -626,9 +631,19 @@ static void fire_special_watches(const char *name)
 
        node = read_node_const(NULL, ctx, name);
 
-       if (node)
-               fire_watches(NULL, ctx, name, node, true, NULL);
-       else
+       if (node) {
+               if (watchdom_flag & WATCH_NODOM)
+                       fire_watches(NULL, ctx, name, node, MATCH_NODEPTH,
+                                    NULL);
+               if (watchdom_flag & WATCH_DOM) {
+                       char name_dom[24]; /* max. "@introduceDomain/domid" */
+
+                       snprintf(name_dom, sizeof(name_dom),
+                                "%s/%u", name, domid);
+                       fire_watches(NULL, ctx, name_dom, node, MATCH_DEPTH,
+                                    NULL);
+               }
+       } else
                log("special node %s not found\n", name);
 
        talloc_free(ctx);
@@ -653,7 +668,7 @@ static int destroy_domain(void *_domain)
        if (domain->interface)
                unmap_interface(domain->domid, domain->interface);
 
-       fire_special_watches("@releaseDomain");
+       fire_special_watches("@releaseDomain", domain->domid, WATCH_BOTH);
 
        wrl_domain_destroy(domain);
 
@@ -681,6 +696,8 @@ static int do_check_domain(struct domain *domain, bool 
*notify,
                if ((state & XENMANAGE_GETDOMSTATE_STATE_SHUTDOWN)
                    && !domain->shutdown) {
                        domain->shutdown = true;
+                       fire_special_watches("@releaseDomain", domain->domid,
+                                            WATCH_DOM);
                        *notify = true;
                }
                if (!(state & XENMANAGE_GETDOMSTATE_STATE_DEAD))
@@ -723,7 +740,7 @@ void check_domains(void)
                ;
 
        if (notify)
-               fire_special_watches("@releaseDomain");
+               fire_special_watches("@releaseDomain", 0, WATCH_NODOM);
 }
 
 static struct domain *find_domain_struct(unsigned int domid)
@@ -747,7 +764,7 @@ static void do_check_domains(void)
        }
 
        if (notify)
-               fire_special_watches("@releaseDomain");
+               fire_special_watches("@releaseDomain", 0, WATCH_NODOM);
 }
 
 /* We scan all domains rather than use the information given here. */
@@ -1112,7 +1129,8 @@ static struct domain *introduce_domain(const void *ctx,
                talloc_steal(domain->conn, domain);
 
                if (!is_priv_domain && !restore)
-                       fire_special_watches("@introduceDomain");
+                       fire_special_watches("@introduceDomain", domid,
+                                            WATCH_BOTH);
        } else {
                /* Use XS_INTRODUCE for recreating the xenbus event-channel. */
                if (domain->port)
-- 
2.53.0




 


Rackspace

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