tools/xenstored: Propagate correctly the error message from lu_start()
authorJulien Grall <jgrall@amazon.com>
Thu, 29 Jul 2021 11:06:02 +0000 (12:06 +0100)
committerIan Jackson <iwj@xenproject.org>
Fri, 30 Jul 2021 10:02:46 +0000 (11:02 +0100)
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>
tools/xenstore/xenstored_control.c

index ff9863c17fa46a107b86e955d9df654ae0581858..6b68b79faac7e15ec2ce71bcd3d10c61012be554 100644 (file)
@@ -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);