qemu-block
[Top][All Lists]
Advanced

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

Re: [PATCH 4/5] qemu-nbd: properly report error if qemu_daemon() is fail


From: Eric Blake
Subject: Re: [PATCH 4/5] qemu-nbd: properly report error if qemu_daemon() is failed
Date: Tue, 18 Jul 2023 12:50:28 -0500
User-agent: NeoMutt/20230517

On Mon, Jul 17, 2023 at 04:55:43PM +0200, Denis V. Lunev wrote:
> errno has been overwritten by dup2() just below qemu_daemon() and thus
> improperly returned to the caller. Fix accordingly.
> 
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Eric Blake <eblake@redhat.com>
> CC: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>  qemu-nbd.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/qemu-nbd.c b/qemu-nbd.c
> index 4450cc826b..f27613cb57 100644
> --- a/qemu-nbd.c
> +++ b/qemu-nbd.c
> @@ -932,9 +932,12 @@ int main(int argc, char **argv)
>              error_report("Failed to fork: %s", strerror(errno));
>              exit(EXIT_FAILURE);
>          } else if (pid == 0) {
> +            int saved_errno;
> +
>              close(stderr_fd[0]);
>  
>              ret = qemu_daemon(1, 0);
> +            saved_errno = errno;    /* dup2 will overwrite error below */

I would have written 'may', not 'will'; but that's a triviality not
worth changing.


-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]