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

[PATCH v3 2/8] tools/init-dom0less: Factor out xenstore setup


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Tue, 26 Aug 2025 17:08:41 -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=Zh8RyeKz1ZM0/lFRJbJVe9Xi6LtsKXP+OxMCeZpnpeU=; b=Hwhf+/NaN+gyGEdIUowDyaAY0VF53uTpeB8IJzDLvGeSkz9NGQqUN93dUyNgY3xrbJgfcZ7C7CVihNF5Lh44Gf9mK+YOpiLGQTtB5lNiypruFWQYKlfaE7WqraaiC093FBsXnIslVFBFpnD2mf2WeIQ/SPjCwc6mfCx5efoZRE+uFmU0v2jKGpJBvGvft3ACCRAqp0RXQgBsrkx0ImWI4xH0aGBP21ELZRJuSCcvIyEoEa6MpPm8noy+id54CzPXJ1pn03qJip1E4t6qZ3iz6d7ShsfGmOVWx8e1qqvhfddiPPbOcdGJGTrG70hOHJNnLNDHh5xnSHdfBHPj1Mo9SQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vkyTdFAn7KprzTPkuvHbOTpnEZhoznnBGyVwyAin0D8h8iQ6AiKrmNbdmbN/8kUDkGS5pgBTbYf+r/3paVfxjCRTG5ekbelHPsMrkOzhpM+6FPDw3C7NpoRJZbBhMyMojy10Pc1LhM86BAhW9XTvgBKHw0fn3RnWpIVMy0G79SxjYQzUmK98KCGr2u/jdAxyWJ3BvDTFGXBTj5YMkjv+xcx6CQe+c7Az59z9uM25gvVW7jwhJ7DEFJxPx21LpN4grduD5ayR8Q+1XUJhshUMAojFutgc7t6Lpdapudr8UeBdDbKl5OBMBCIxYRCGAIRsRn/p04zcK7doTOZh85moGw==
  • Cc: Jason Andryuk <jason.andryuk@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Tue, 26 Aug 2025 21:09:16 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Factor out the xenstore setup code into configure_xenstore().  This is
in preparation for handling already-introduced domains.

Signed-off-by: Jason Andryuk <jason.andryuk@xxxxxxx>
---
v3:
Remove handle passing
---
 tools/helpers/init-dom0less.c | 39 +++++++++++++++++++++++++----------
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/tools/helpers/init-dom0less.c b/tools/helpers/init-dom0less.c
index 0b0be08449..8de8e44ad3 100644
--- a/tools/helpers/init-dom0less.c
+++ b/tools/helpers/init-dom0less.c
@@ -237,40 +237,40 @@ err:
     return rc;
 }
 
-static int init_domain(libxl_dominfo *info)
+static int configure_xenstore(libxl_dominfo *info,
+                              uint64_t *xenstore_evtchn,
+                              uint64_t *xenstore_pfn)
 {
-    libxl_uuid uuid;
-    uint64_t xenstore_evtchn, xenstore_pfn;
     int rc;
 
     printf("Init dom0less domain: %u\n", info->domid);
 
     rc = xc_hvm_param_get(xch, info->domid, HVM_PARAM_STORE_EVTCHN,
-                          &xenstore_evtchn);
+                          xenstore_evtchn);
     if (rc != 0) {
         printf("Failed to get HVM_PARAM_STORE_EVTCHN\n");
         return 1;
     }
 
     /* no xen,enhanced; nothing to do */
-    if (!xenstore_evtchn)
+    if (!*xenstore_evtchn)
         return 0;
 
     /* Get xenstore page */
-    if (get_xs_page(info, &xenstore_pfn) != 0)
+    if (get_xs_page(info, xenstore_pfn) != 0)
         return 1;
 
-    if (xenstore_pfn == ~0ULL) {
+    if (*xenstore_pfn == ~0ULL) {
         struct xenstore_domain_interface *intf;
 
-        rc = alloc_xs_page(info, &xenstore_pfn);
+        rc = alloc_xs_page(info, xenstore_pfn);
         if (rc != 0) {
             printf("Error on getting xenstore page\n");
             return 1;
         }
 
         intf = xenforeignmemory_map(xfh, info->domid, PROT_READ | PROT_WRITE, 
1,
-                                    &xenstore_pfn, NULL);
+                                    xenstore_pfn, NULL);
         if (!intf) {
             printf("Error mapping xenstore page\n");
             return 1;
@@ -281,16 +281,33 @@ static int init_domain(libxl_dominfo *info)
 
         /* Now everything is ready: set HVM_PARAM_STORE_PFN */
         rc = xc_hvm_param_set(xch, info->domid, HVM_PARAM_STORE_PFN,
-                xenstore_pfn);
+                              *xenstore_pfn);
         if (rc < 0)
             return rc;
 
         rc = xc_dom_gnttab_seed(xch, info->domid, true,
-                                (xen_pfn_t)-1, xenstore_pfn, 0, 0);
+                                (xen_pfn_t)-1, *xenstore_pfn, 0, 0);
         if (rc)
                err(1, "xc_dom_gnttab_seed");
     }
 
+    return 0;
+}
+
+static int init_domain(libxl_dominfo *info)
+{
+    uint64_t xenstore_evtchn, xenstore_pfn = 0;
+    libxl_uuid uuid;
+    int rc;
+
+    rc = configure_xenstore(info, &xenstore_evtchn, &xenstore_pfn);
+    if (rc)
+        return rc;
+
+    if (xenstore_evtchn == 0) {
+        return 0;
+    }
+
     libxl_uuid_generate(&uuid);
     xc_domain_sethandle(xch, info->domid, libxl_uuid_bytearray(&uuid));
 
-- 
2.50.1




 


Rackspace

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