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

[PATCH v4 06/12] tools/xenstored: Add get_domain_evtchn() to find evtchn


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Thu, 24 Jul 2025 22:28:06 -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=sGYc+CzgLIdlHzSBks2AkycShqESzRnLK23aeY0dc18=; b=Edhb32DHO9GhCtYRNNtirvLJJEJSBrvsj7pn2zaAv2fqHXDc6qRVLHR41aubBZxp2v2K2XHKGtjTzwjD3cgkBjHxZaWEyzxfCZGlu+27LLXrDBOEBsSzgRKHOb8kGKP2duSavZd7OIejiRqWPktVx4qiF4LAkj/EwMcsVjO/UggUZU4QwBdPN0NGzo83kOXxCtuCutArU9AfGarY4YxN7K+iv3tbNiMF+6w03d+8r5mhLerMFUm/5nBnFiilxbIveZ2pfLNRAsRDvwU0epUHomwEM4scQ1YYKnLpws+dW0XQgogWdLwLDCCUAtaqL/ExrA/6CCydk5eYRt9QjBvgdw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JcqYwpQ+nQt4RD56CJeq0KPcaPrtOUUkWMEBd+BDt+imRpcBuQijHfKgbuDt/c2rMwqKotR3IVfLueoDgcmS8RuPYk+4Fwq51HBS12KZ3NvtVEOXXTBVcd2grNzlgzWeq1c+Pug/GePvyPotLN/UyLfyxtJozMSn8bDRDMuBY4zJrTNKbZi2axIxLl+LPWI3LlgLhdiLKT2eAuv005igJZXaXJMIkmjGBGMRdAOZzBJdKnyeRo/HIdxwMkMC5jsEMa9/FGVx28d8yJmP/UDYQ+eEAf0TwoLUbSk/nKSqEDkE2Hvoc1Aa+nM+WQ1S8BKVO9LT6a121b3bKZRh15DR6g==
  • 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:28:41 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Add a helper to lookup the event channel for a domid.  This hides some
of the differences between dom0 and stubdom xenstored.

It highlights the different meanings between get_xenbus_evtchn() in a
stubdom, where it looks up dom0's event channel, and dom0, where it
looks up the local event channel.

The default return 0 will be fine as any other auto-introduced domain
will needs the event channel populated in the grant.

Signed-off-by: Jason Andryuk <jason.andryuk@xxxxxxx>
---
 tools/xenstored/domain.c | 38 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index 1241f8c73e..1c52254ba8 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -1251,12 +1251,41 @@ const char *get_implicit_path(const struct connection 
*conn)
        return conn->domain->path;
 }
 
+/*
+ * dom0 xenstored (posix.c) uses get_xenbus_evtchn() to lookup with
+ * XENSTORED_PORT_DEV.
+ *
+ * minios stubdom uses get_xenbus_evtchn() to look up dom0's event channel
+ * from the command line (--event).  The stubdom's own event channel is
+ * returned directly.
+ *
+ * Any other existing domains from dom0less/Hyperlaunch will have
+ * the event channel in the xenstore page, so lookup here isn't necessary.
+ * --event would not be set, so it would default to 0.
+ */
+evtchn_port_t get_domain_evtchn(domid_t domid)
+{
+#ifdef __MINIOS__
+       if (domid == stub_domid) {
+               return xenbus_evtchn;
+       } else if (domid == priv_domid) {
+               return get_xenbus_evtchn();
+       }
+#else
+       if (domid == xenbus_master_domid()) {
+               return get_xenbus_evtchn();
+       }
+#endif
+
+       return 0;
+}
+
 void dom0_init(void)
 {
        evtchn_port_t port;
        struct domain *dom0;
 
-       port = get_xenbus_evtchn();
+       port = get_domain_evtchn(xenbus_master_domid());
        if (port == -1)
                barf_perror("Failed to initialize dom0 port");
 
@@ -1271,11 +1300,16 @@ void stubdom_init(void)
 {
 #ifdef __MINIOS__
        struct domain *stubdom;
+       evtchn_port_t port;
 
        if (stub_domid < 0)
                return;
 
-       stubdom = introduce_domain(NULL, stub_domid, xenbus_evtchn, false);
+       port = get_domain_evtchn(stub_domid);
+       if (port == -1)
+               barf_perror("Failed to initialize dom0 port");
+
+       stubdom = introduce_domain(NULL, stub_domid, port, false);
        if (!stubdom)
                barf_perror("Failed to initialize stubdom");
 
-- 
2.50.1




 


Rackspace

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