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

[PATCH v2] tools: init-dom0less: Replace err() with more informative messages


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Tue, 7 Oct 2025 08:26:55 +0200
  • 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=U4AaFdG4/kMukRfASgsxXz6Ikhpktcw485E5ohsxIVk=; b=yC7ho9sjOSrb1HCEnhBWk4NZ3bG+kYN07X9vq459+BVXkPf1IVGrAROCC6Gs2+Ski4gCntYvOldRE00wbKRT1MQjD5P5bwOAHE/gbTbDg29RHggkI0Z/QZ1aM1Z40pMyQx4zZQYQu7fg3Gev9Dk0mjwVJieqq3O9K90J4swCy0reXqSZMttXaWGn2/r6LGyzCXko/NutWjWNvi2xbQT9Qz1bo9TMPiagDwM9CPtsJFLY+KlEQ5IKNCTdPyK1JAgwx16ZuHmHx1AEZQsoYnkCZHaD+RBCWMmlwehj9MjrdVSEQ/6wFP5VG8I8b/TfLo3mqJE4PuZkmCfyAlY9/cCjBg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EZ1jf76uurDDt8tFckextIuwavlfEHaNlurhO1yHq4V1NCLYJEvTgdUxWfJ7Rbhv7WVa6kt238gmmepVkTnlYepbFNO3YvsMyc5Rlls96840zAdF9o3XmBsphGsPoDr9cITLigxCYnZSLl40vt9lSCaeysc4C+yE5h+woIY8RxST1SHqkMohB+MCCd4Nd2u4+zgZmpIJQhPZfRQolpsKP1fN3/0eyTChDiOJ0zatQIeEtUMCoWd4st6+07marwTYkaTbcdNLpGE/HvAKzqJscua5Qj70B0h5wWMt5przHnSmam6MaM3yVNgWTeUr4Zx7wX2OsZAVVGJO3VKvOwRPog==
  • Cc: Michal Orzel <michal.orzel@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Tue, 07 Oct 2025 06:27:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Current use of err() has the following issues:
- without setting errno, on error it results in printing e.g.:
 "init-dom0less: writing to xenstore: Success"
 This is very misleading and difficult to deduct that there was a
 failure.
- does not propagate error codes to the caller.
- skips "init_domain failed" message by exiting early.
- early exit prevents setting up any remaining domains.

Replace err() with more informative messages propagating rc when
possible.

Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
---
Changes in v2:
 - return -errno instead of 1 for xs_introduce_domain
 - add another bullet point in commit msg
---
 tools/helpers/init-dom0less.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/tools/helpers/init-dom0less.c b/tools/helpers/init-dom0less.c
index a182dce56353..851bbfff15aa 100644
--- a/tools/helpers/init-dom0less.c
+++ b/tools/helpers/init-dom0less.c
@@ -288,24 +288,33 @@ static int init_domain(struct xs_handle *xsh,
 
         rc = xc_dom_gnttab_seed(xch, info->domid, true,
                                 (xen_pfn_t)-1, xenstore_pfn, 0, 0);
-        if (rc)
-               err(1, "xc_dom_gnttab_seed");
+        if (rc) {
+            printf("Failed to seed gnttab entries\n");
+            return rc;
+        }
     }
 
     libxl_uuid_generate(&uuid);
     xc_domain_sethandle(xch, info->domid, libxl_uuid_bytearray(&uuid));
 
     rc = gen_stub_json_config(info->domid, &uuid);
-    if (rc)
-        err(1, "gen_stub_json_config");
+    if (rc) {
+        printf("Failed to create stub json config\n");
+        return rc;
+    }
 
     rc = create_xenstore(xsh, info, uuid, xenstore_pfn, xenstore_evtchn);
-    if (rc)
-        err(1, "writing to xenstore");
+    if (rc) {
+        printf("Failed to write to xenstore\n");
+        return rc;
+    }
 
     rc = xs_introduce_domain(xsh, info->domid, xenstore_pfn, xenstore_evtchn);
-    if (!rc)
-        err(1, "xs_introduce_domain");
+    if (!rc) {
+        printf("Failed to introduce a domain\n");
+        return -errno;
+    }
+
     return 0;
 }
 
-- 
2.43.0




 


Rackspace

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