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

[PATCH v2 13/17] tools/xenstored: Delay firing special watches


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Wed, 16 Jul 2025 17:15:00 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=97KUf7mPxnlBQ7FNs7Dg1VDm2iUHMnZSy61+ihwrWT4=; b=I6yx2TUMorJq8FTGnuBMyEGrCAZy56Bm0aENtsk9FQnWMq5xivrHLH61Sd57xvGS5Lcp21Qho0BiHTCo0B57V6ndymeLLz6DfnaV9nmcscBRNE+U0isVz/K0THA8jdXp0botvXtFWLoeA1w+59H403CfqDlpLOHG+7sGCovat+5jOpY0bJqxNIly+ZwuGS7MBE4nZTbFM6pm8I/hT7V3HlELu+gCVInvg53oxHEXmU3s9qPOW50QdKn7pmoxpEvMJeN+rFBQr6CRtn+YF6wEPKXyQwVZzQS16ijEvi5G1/O9f4472nHD7UlqgUyc9/GtusRUi0pW2jW/zJQWBSC3qQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZLQ1BshmjSsrbPEJYkFFZDyajgi2LWH0vrVlFu+IT0bttlin8Encycsw4bhMT/v8LSApaPmPQ9ul5EC1Jq/l4gIYW+VpaAaSRcpdCnWMLHy1UHjEbEYqCxVXA9wuwpUYb10PHjkVrYSOpEkE1y0TRD8ZR7JUCcb5+2p1Q2gOgWpa5CmWIb5ADRs1yQM/JMRJ7iU0rwDfOtSDOTyRPNaoygjP/Zax8mRoa76sWWm3RKqYOcODFn/ymW79FToMXsuffYrygrUt4ESLEf3eYMOWMY4UePT+u8i7E6cr6vuMIzb505AwLcXBH9N2RvcuKGmguxiNH2whdJyV+GYJDF8HdQ==
  • Cc: Jason Andryuk <jason.andryuk@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Wed, 16 Jul 2025 21:22:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

fire_special_watches() can only be called after setup_structure() has
been called.  If it is called before setup_structure(), the hashtable
search will segfault as the nodes hashtable has not been allocated.

Normally, dom0 is setup up first and setup_structure() runs before any
other domain.

If we iterate xenmanage_poll_changed_domain() to discover domains, there
is no guarantee the local domain running xenstored will be created
first.  Suppress firing special watches until the hashtable has been
allocated.

Signed-off-by: Jason Andryuk <jason.andryuk@xxxxxxx>
---
With a known domid, xenstored could construct that first and the iterate
skipping itself.
---
 tools/xenstored/core.c   | 5 +++++
 tools/xenstored/core.h   | 1 +
 tools/xenstored/domain.c | 6 +++++-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c
index 37e4dd5a5b..550e879a00 100644
--- a/tools/xenstored/core.c
+++ b/tools/xenstored/core.c
@@ -2321,6 +2321,11 @@ void setup_structure(bool live_update)
        }
 }
 
+bool setup_structure_complete(void)
+{
+       return nodes != NULL;
+}
+
 int remember_string(struct hashtable *hash, const char *str)
 {
        char *k = talloc_strdup(NULL, str);
diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h
index 632886cecf..3fe80f7c66 100644
--- a/tools/xenstored/core.h
+++ b/tools/xenstored/core.h
@@ -301,6 +301,7 @@ const struct node *read_node_const(struct connection *conn, 
const void *ctx,
 int rm_node(struct connection *conn, const void *ctx, const char *name);
 
 void setup_structure(bool live_update);
+bool setup_structure_complete(void);
 struct connection *new_connection(const struct interface_funcs *funcs);
 struct connection *add_socket_connection(int fd);
 struct connection *get_connection_by_id(unsigned int conn_id);
diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index d2b6fffa62..5443b4e608 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -579,9 +579,13 @@ static void domain_tree_remove(struct domain *domain)
 
 static void fire_special_watches(const char *name)
 {
-       void *ctx = talloc_new(NULL);
+       void *ctx;
        const struct node *node;
 
+       if (!setup_structure_complete())
+               return;
+
+       ctx = talloc_new(NULL);
        if (!ctx)
                return;
 
-- 
2.50.0




 


Rackspace

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