[PATCH] tools/xenstored: Propagate correctly the error message from lu_start()

Julien Grall posted 1 patch 2 years, 8 months ago
Test gitlab-ci failed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20210729110602.24815-1-julien@xen.org
tools/xenstore/xenstored_control.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
[PATCH] tools/xenstored: Propagate correctly the error message from lu_start()
Posted by Julien Grall 2 years, 8 months ago
From: Julien Grall <jgrall@amazon.com>

lu_start() will only set errno when it returns NULL. For all the
other cases, the value is unknown.

This means that when lu_start() returns an error message, it may not
be propagated to the client.

The check that errno is a non-zero value is now dropped and instead
the value is returned when no error message is provided. This
relies on errno to always be set when ret == NULL.

Fixes: af216a99fb ("tools/xenstore: add the basic framework for doing the live update")
Signed-off-by: Julien Grall <jgrall@amazon.com>
---
 tools/xenstore/xenstored_control.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/xenstore/xenstored_control.c b/tools/xenstore/xenstored_control.c
index ff9863c17fa4..6b68b79faac7 100644
--- a/tools/xenstore/xenstored_control.c
+++ b/tools/xenstore/xenstored_control.c
@@ -795,10 +795,8 @@ static int do_control_lu(void *ctx, struct connection *conn,
 				return EINVAL;
 		}
 		ret = lu_start(ctx, conn, force, to);
-		if (errno)
-			return errno;
 		if (!ret)
-			return 0;
+			return errno;
 	} else {
 		errno = 0;
 		ret = lu_arch(ctx, conn, vec, num);
-- 
2.17.1


Re: [PATCH] tools/xenstored: Propagate correctly the error message from lu_start()
Posted by Juergen Gross 2 years, 8 months ago
On 29.07.21 13:06, Julien Grall wrote:
> From: Julien Grall <jgrall@amazon.com>
> 
> lu_start() will only set errno when it returns NULL. For all the
> other cases, the value is unknown.
> 
> This means that when lu_start() returns an error message, it may not
> be propagated to the client.
> 
> The check that errno is a non-zero value is now dropped and instead
> the value is returned when no error message is provided. This
> relies on errno to always be set when ret == NULL.
> 
> Fixes: af216a99fb ("tools/xenstore: add the basic framework for doing the live update")
> Signed-off-by: Julien Grall <jgrall@amazon.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen