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

[PATCH v2 5/9] tools/xenstored: add depth handling to XS_WATCH


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Juergen Gross <jgross@xxxxxxxx>
  • Date: Tue, 21 Apr 2026 09:42:07 +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-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b="KIp/c1/F"
  • 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:44 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

In case XENSTORE_SERVER_FEATURE_WATCHDEPTH is set, allow XS_WATCH to
have "depth" as 3rd parameter.

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
Reviewed-by: Jason Andryuk <jason.andryuk@xxxxxxx>
---
 tools/xenstored/domain.c |  8 ++++++++
 tools/xenstored/domain.h |  2 ++
 tools/xenstored/watch.c  | 11 +++++++++--
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index b0b339f569..7f2fa16cf2 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -390,6 +390,14 @@ void wrl_apply_debit_trans_commit(struct connection *conn)
        wrl_apply_debit_actual(conn->domain);
 }
 
+bool feature_available(const struct connection *conn, unsigned int feature)
+{
+       if (!conn->domain)
+               return XENSTORE_FEATURES & feature;
+
+       return conn->domain->features & feature;
+}
+
 static unsigned int domain_get_soft_quota(struct domain *d, enum accitem what)
 {
        if (d && d->acc[what].val[Q_IDX_SOFT] != Q_VAL_DISABLED)
diff --git a/tools/xenstored/domain.h b/tools/xenstored/domain.h
index ca38b5e0ea..b1cfb5cd82 100644
--- a/tools/xenstored/domain.h
+++ b/tools/xenstored/domain.h
@@ -188,4 +188,6 @@ struct hashtable *domain_check_acc_init(void);
 void domain_check_acc_add(const struct node *node, struct hashtable *domains);
 void domain_check_acc(struct hashtable *domains);
 
+bool feature_available(const struct connection *conn, unsigned int feature);
+
 #endif /* _XENSTORED_DOMAIN_H */
diff --git a/tools/xenstored/watch.c b/tools/xenstored/watch.c
index 42e24d3201..860c219f29 100644
--- a/tools/xenstored/watch.c
+++ b/tools/xenstored/watch.c
@@ -213,11 +213,18 @@ static struct watch *add_watch(struct connection *conn, 
const char *path,
 int do_watch(const void *ctx, struct connection *conn, struct buffered_data 
*in)
 {
        struct watch *watch;
-       const char *vec[2];
+       const char *vec[3];
+       unsigned int n_pars;
        int depth = -1;
        bool relative;
 
-       if (get_strings(in, vec, ARRAY_SIZE(vec)) != ARRAY_SIZE(vec))
+       n_pars = get_strings(in, vec, ARRAY_SIZE(vec));
+       if (n_pars == 3 &&
+           feature_available(conn, XENSTORE_SERVER_FEATURE_WATCHDEPTH)) {
+               depth = atoi(vec[2]);
+               if (depth < 0)
+                       return EINVAL;
+       } else if (n_pars != 2)
                return EINVAL;
 
        errno = check_watch_path(conn, ctx, &(vec[0]), &relative);
-- 
2.53.0




 


Rackspace

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