* [PATCH v2] tools: init-dom0less: Replace err() with more informative messages
@ 2025-10-07 6:26 Michal Orzel
2025-10-07 9:11 ` Alejandro Vallejo
2025-10-07 12:20 ` Jason Andryuk
0 siblings, 2 replies; 3+ messages in thread
From: Michal Orzel @ 2025-10-07 6:26 UTC (permalink / raw)
To: xen-devel; +Cc: Michal Orzel, Anthony PERARD
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@amd.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] tools: init-dom0less: Replace err() with more informative messages
2025-10-07 6:26 [PATCH v2] tools: init-dom0less: Replace err() with more informative messages Michal Orzel
@ 2025-10-07 9:11 ` Alejandro Vallejo
2025-10-07 12:20 ` Jason Andryuk
1 sibling, 0 replies; 3+ messages in thread
From: Alejandro Vallejo @ 2025-10-07 9:11 UTC (permalink / raw)
To: Michal Orzel, xen-devel; +Cc: Anthony PERARD, Xen-devel
On Tue Oct 7, 2025 at 8:26 AM CEST, Michal Orzel wrote:
> 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@amd.com>
Reviewed-by: Alejandro Vallejo <alejandro.garciavallejo@amd.com>
Cheers,
Alejandro
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] tools: init-dom0less: Replace err() with more informative messages
2025-10-07 6:26 [PATCH v2] tools: init-dom0less: Replace err() with more informative messages Michal Orzel
2025-10-07 9:11 ` Alejandro Vallejo
@ 2025-10-07 12:20 ` Jason Andryuk
1 sibling, 0 replies; 3+ messages in thread
From: Jason Andryuk @ 2025-10-07 12:20 UTC (permalink / raw)
To: Michal Orzel, xen-devel; +Cc: Anthony PERARD
On 2025-10-07 02:26, Michal Orzel wrote:
> 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@amd.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
Thanks,
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-07 12:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-07 6:26 [PATCH v2] tools: init-dom0less: Replace err() with more informative messages Michal Orzel
2025-10-07 9:11 ` Alejandro Vallejo
2025-10-07 12:20 ` Jason Andryuk
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.