public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] pasta: include errno in error message
@ 2023-06-23 10:23 Paul Holzinger
  2023-06-24  1:57 ` David Gibson
  2023-06-26  7:22 ` Stefano Brivio
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Holzinger @ 2023-06-23 10:23 UTC (permalink / raw)
  To: passt-dev; +Cc: Paul Holzinger

When the open() or setns() calls fails pasta exits early and prints an
error. However it did not include the errno so it was impossible to know
why the syscall failed.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
---
 pasta.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pasta.c b/pasta.c
index 13ab18b..27809d2 100644
--- a/pasta.c
+++ b/pasta.c
@@ -136,14 +136,14 @@ void pasta_open_ns(struct ctx *c, const char *netns)
 
 	nfd = open(netns, O_RDONLY | O_CLOEXEC);
 	if (nfd < 0)
-		die("Couldn't open network namespace %s", netns);
+		die("Couldn't open network namespace %s: %s", netns, strerror(errno));
 
 	c->pasta_netns_fd = nfd;
 
 	NS_CALL(ns_check, c);
 
 	if (c->pasta_netns_fd < 0)
-		die("Couldn't switch to pasta namespaces");
+		die("Couldn't switch to pasta namespaces: %s", strerror(errno));
 
 	if (!c->no_netns_quit) {
 		char buf[PATH_MAX] = { 0 };
@@ -261,7 +261,7 @@ void pasta_start_ns(struct ctx *c, uid_t uid, gid_t gid,
 
 	NS_CALL(pasta_wait_for_ns, c);
 	if (c->pasta_netns_fd < 0)
-		die("Failed to join network namespace");
+		die("Failed to join network namespace: %s", strerror(errno));
 }
 
 /**
-- 
@@ -136,14 +136,14 @@ void pasta_open_ns(struct ctx *c, const char *netns)
 
 	nfd = open(netns, O_RDONLY | O_CLOEXEC);
 	if (nfd < 0)
-		die("Couldn't open network namespace %s", netns);
+		die("Couldn't open network namespace %s: %s", netns, strerror(errno));
 
 	c->pasta_netns_fd = nfd;
 
 	NS_CALL(ns_check, c);
 
 	if (c->pasta_netns_fd < 0)
-		die("Couldn't switch to pasta namespaces");
+		die("Couldn't switch to pasta namespaces: %s", strerror(errno));
 
 	if (!c->no_netns_quit) {
 		char buf[PATH_MAX] = { 0 };
@@ -261,7 +261,7 @@ void pasta_start_ns(struct ctx *c, uid_t uid, gid_t gid,
 
 	NS_CALL(pasta_wait_for_ns, c);
 	if (c->pasta_netns_fd < 0)
-		die("Failed to join network namespace");
+		die("Failed to join network namespace: %s", strerror(errno));
 }
 
 /**
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] pasta: include errno in error message
  2023-06-23 10:23 [PATCH] pasta: include errno in error message Paul Holzinger
@ 2023-06-24  1:57 ` David Gibson
  2023-06-26  7:22 ` Stefano Brivio
  1 sibling, 0 replies; 3+ messages in thread
From: David Gibson @ 2023-06-24  1:57 UTC (permalink / raw)
  To: Paul Holzinger; +Cc: passt-dev

[-- Attachment #1: Type: text/plain, Size: 1606 bytes --]

On Fri, Jun 23, 2023 at 12:23:50PM +0200, Paul Holzinger wrote:
> When the open() or setns() calls fails pasta exits early and prints an
> error. However it did not include the errno so it was impossible to know
> why the syscall failed.
> 
> Signed-off-by: Paul Holzinger <pholzing@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  pasta.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/pasta.c b/pasta.c
> index 13ab18b..27809d2 100644
> --- a/pasta.c
> +++ b/pasta.c
> @@ -136,14 +136,14 @@ void pasta_open_ns(struct ctx *c, const char *netns)
>  
>  	nfd = open(netns, O_RDONLY | O_CLOEXEC);
>  	if (nfd < 0)
> -		die("Couldn't open network namespace %s", netns);
> +		die("Couldn't open network namespace %s: %s", netns, strerror(errno));
>  
>  	c->pasta_netns_fd = nfd;
>  
>  	NS_CALL(ns_check, c);
>  
>  	if (c->pasta_netns_fd < 0)
> -		die("Couldn't switch to pasta namespaces");
> +		die("Couldn't switch to pasta namespaces: %s", strerror(errno));
>  
>  	if (!c->no_netns_quit) {
>  		char buf[PATH_MAX] = { 0 };
> @@ -261,7 +261,7 @@ void pasta_start_ns(struct ctx *c, uid_t uid, gid_t gid,
>  
>  	NS_CALL(pasta_wait_for_ns, c);
>  	if (c->pasta_netns_fd < 0)
> -		die("Failed to join network namespace");
> +		die("Failed to join network namespace: %s", strerror(errno));
>  }
>  
>  /**

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] pasta: include errno in error message
  2023-06-23 10:23 [PATCH] pasta: include errno in error message Paul Holzinger
  2023-06-24  1:57 ` David Gibson
@ 2023-06-26  7:22 ` Stefano Brivio
  1 sibling, 0 replies; 3+ messages in thread
From: Stefano Brivio @ 2023-06-26  7:22 UTC (permalink / raw)
  To: Paul Holzinger; +Cc: passt-dev

On Fri, 23 Jun 2023 12:23:50 +0200
Paul Holzinger <pholzing@redhat.com> wrote:

> When the open() or setns() calls fails pasta exits early and prints an
> error. However it did not include the errno so it was impossible to know
> why the syscall failed.
> 
> Signed-off-by: Paul Holzinger <pholzing@redhat.com>

Applied.

-- 
Stefano


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-26  7:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-23 10:23 [PATCH] pasta: include errno in error message Paul Holzinger
2023-06-24  1:57 ` David Gibson
2023-06-26  7:22 ` Stefano Brivio

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).