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

[PATCH v4 09/12] tools/xenstored: Use priv_domid for manual nodes and permission


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Thu, 24 Jul 2025 22:28:09 -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=QlugRIedb5kUb20fgbK5OIj3tsxnkaC/u/n2bSU12Pc=; b=LZD+vz9Z1H+pwz/cQ2Nsecz1/77WhoDpb1odmfcbvfQnwvfUmWWsP6CeIed2ChhpEoGyiZPKpbnEeUsl7sjOH5jozrIbc3QLWuzy+RiesZwP5NfEEu7xrtURBDVuVc1d+0re5L2H1E5g7JUW6Qr124lAuqJ8HRQkLBP79L62gLYo3sBmFbiMWjSJjygl3wBX030A0XIhBSD0Cy51vFVbewiP6xrAgCbh2tPt/Sw4sDIV5HJtILqNDfxEA3W6c2QvVgjjgp3FOQOIg9jVNPGB/yH9Ys9GFlEM+ou13fa0v2xKvT9Bf+pPy2iS/lfPj3HFmwCcVWvQkYoHcWwkgqtZWw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PTH05AP4tQb74sN15EEE8/zVz0UKDB4tpZ5YE1fOA0A8XGgUqAVwZlvTDfqFUFmQc5GL5musBhXBIM98uN+D+7kE3SLm1Nv5taVXZN2cR4qt850ImfNrEQKFULGWPM7N5M2QPzs1+JwVk60pasWg/gU9uvsexyTiijJFIfoO3Ownu6cL8YKjJsvTd4TNE0bM1PlTFkFNG/uL2fG3k8H/3Lh2kXSvhrVLEWhsFDM4XUkB+YmN3Z7Ea8RLWyDZPkRe/N5lhRRgyPKR5jPx6AMg1RYFfRejb+U0mBN7eSz6V/+tS/qGrnjt635u8FYqaE84PpeQFRdVT/EOnKZ0A6YSkQ==
  • Cc: Jason Andryuk <jason.andryuk@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Fri, 25 Jul 2025 02:30:44 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Usually, priv_domid == dom0_domid == 0, and that is what is expected.
If we rename s/dom0_domid/store_domid/, it seems more likely we want to
actually have the priv_domid as the owner.

That leads to follow on changes to ensure that the priv_domid is created
first.

Signed-off-by: Jason Andryuk <jason.andryuk@xxxxxxx>
---
Will this blow up if priv_domid doesn't exist?

Maybe it would be better to just create these as store_domid.
---
 tools/xenstored/core.c   |  4 ++--
 tools/xenstored/domain.c | 15 ++++++++-------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c
index c2f8d20211..19edd75bc3 100644
--- a/tools/xenstored/core.c
+++ b/tools/xenstored/core.c
@@ -2266,7 +2266,7 @@ struct connection *get_connection_by_id(unsigned int 
conn_id)
 static void manual_node(const char *name, const char *child)
 {
        struct node *node;
-       struct xs_permissions perms = { .id = dom0_domid,
+       struct xs_permissions perms = { .id = priv_domid,
                                        .perms = XS_PERM_NONE };
 
        node = talloc_zero(NULL, struct node);
@@ -2317,7 +2317,7 @@ void setup_structure(bool live_update)
                manual_node("/tool/xenstored", NULL);
                manual_node("@releaseDomain", NULL);
                manual_node("@introduceDomain", NULL);
-               domain_nbentry_fix(dom0_domid, 5, true);
+               domain_nbentry_fix(priv_domid, 5, true);
        }
 }
 
diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index ac4ac72f99..dbeacaa93e 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -1009,7 +1009,7 @@ static struct domain *introduce_domain(const void *ctx,
        struct domain *domain;
        int rc;
        struct xenstore_domain_interface *interface;
-       bool is_master_domain = (domid == xenbus_master_domid());
+       bool is_priv_domain = (domid == priv_domid);
 
        domain = find_or_alloc_domain(ctx, domid);
        if (!domain)
@@ -1032,13 +1032,13 @@ static struct domain *introduce_domain(const void *ctx,
                }
                domain->interface = interface;
 
-               if (is_master_domain)
+               if (is_priv_domain)
                        setup_structure(restore);
 
                /* Now domain belongs to its connection. */
                talloc_steal(domain->conn, domain);
 
-               if (!is_master_domain && !restore)
+               if (!is_priv_domain && !restore)
                        fire_special_watches("@introduceDomain");
        } else {
                /* Use XS_INTRODUCE for recreating the xenbus event-channel. */
@@ -1295,17 +1295,18 @@ void init_domains(void)
                domids[nr_domids - 1] = domid;
 
                if (caps & XENMANAGE_GETDOMSTATE_CAP_XENSTORE) {
+                       dom0_domid = domid;
+               }
+
+               if (caps & XENMANAGE_GETDOMSTATE_CAP_CONTROL) {
                        memmove(&domids[1], domids, (nr_domids - 1) * 
sizeof(*domids));
                        /*
                         * Local domid must be first to setup structures for
                         * firing the special watches.
                         */
                        domids[0] = domid;
-                       dom0_domid = domid;
-               }
-
-               if (caps & XENMANAGE_GETDOMSTATE_CAP_CONTROL)
                        priv_domid = domid;
+               }
        }
 
        for (unsigned int i = 0; i < nr_domids; i++) {
-- 
2.50.1




 


Rackspace

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