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);