[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
- [PATCH 3/5] qemu-nbd: properly report error on error in dup2() after qemu_daemon(), (continued)
- [PATCH 3/5] qemu-nbd: properly report error on error in dup2() after qemu_daemon(), Denis V. Lunev, 2023/07/17
- [PATCH 2/5] qemu-nbd: fix regression with qemu-nbd --fork run over ssh, Denis V. Lunev, 2023/07/17
- [PATCH 5/5] qemu-nbd: handle dup2() error when qemu-nbd finished setup process, Denis V. Lunev, 2023/07/17
- [PATCH 1/5] qemu-nbd: pass structure into nbd_client_thread instead of plain char*, Denis V. Lunev, 2023/07/17
- [PATCH 4/5] qemu-nbd: properly report error if qemu_daemon() is failed, Denis V. Lunev, 2023/07/17
- Re: [PATCH 4/5] qemu-nbd: properly report error if qemu_daemon() is failed,
Eric Blake <=
- [PATCH 6/5] qemu-nbd: make verbose bool and local variable in main(), Denis V. Lunev, 2023/07/17