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

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


  • To: Jürgen Groß <jgross@xxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Fri, 25 Jul 2025 11:36:59 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com 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=j4xbNpy8wB7RT9jebbL8ji5ymdlE+KHsdiPHpiYa0SU=; b=nB4gmOAHvJDBDLsTs6VX8U2DP2ALr2mKn32YtgOhd+iWOQG/1Fv5Mi4SkY8znVS8wuclB8SC1haHD+ueTrbgcMvXD7CkyO5UmSlhSjSFSdCEYrO+R3uitbmEbWNZJJMCvYrWSqDbGohJUVIIKIXoLmbOX3xk0CUpb9mfv6mo/hCXrJSs9MfAE8j8vpSZVZdB0EqrMkEzxUo6h1nRfBLsMQgXob79zshDJ0UapgBKyHHYoBEqRz+CvKlIU5C6WwBEoXsBelLkeAagYZ4442/HxlNPJgF2Mz2mB2IoCysrLq4BAHipT5KYQc+SovYAcrXtlRROWWjrbv3VNYdqpgT7Gg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=g6mJ6YSGi63hEP/4dgCuDqqVrYvwsD32FymFYJEjb8gNKcglSlnedAqQ3xv+a4eLuP59qRiA77a6MrEovEHyTAyxSvlz7BKd2SUDnauZFkNyYorDUBEm2LmJvc1u3R88ZCqAc2tLc2EP9iG85mskX8St6F6WQ6yNGKDGmPMrACpUO+jctHF7f0wB15TUzL6c8yXhhmHg/BPr9vNntBBwvbrWUGBhl+gBR54v/yjwb/lAu4ICiWgpDGoMorhtZLAUGopT8rxEZojk8lllBvjr4sGBlAK1oJ2q82GgKv8nliO2znK18bWy6j/f9lH9sNRpwTj1ZUzJiF7IZdTTj+OoeQ==
  • Cc: Julien Grall <julien@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Fri, 25 Jul 2025 15:37:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2025-07-25 02:41, Jürgen Groß wrote:
On 25.07.25 04:28, Jason Andryuk wrote:
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;
+}
+

I'd prefer to have 2 get_domain_evtchn() variants, one in posix.c and
one in minios.c. This way you can avoid the #ifdef.

Sounds good.

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

s/dom0/stubdom/

Thanks,
Jason



 


Rackspace

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