[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v8 4/4] net/socket: Improve -net socket error re
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH v8 4/4] net/socket: Improve -net socket error reporting |
Date: |
Thu, 06 Jul 2017 09:24:34 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) |
Mao Zhongyi <address@hidden> writes:
> When -net socket fails, it first reports a specific error, then
> a generic one, like this:
>
> $ qemu-system-x86_64 -net socket,
> qemu-system-x86_64: -net socket: exactly one of fd=, listen=, connect=,
> mcast= or udp= is required
> qemu-system-x86_64: -net socket: Device 'socket' could not be initialized
>
> Convert net_socket_*_init() to Error to get rid of the superfluous second
> error message. After the patch, the effect like this:
>
> $ qemu-system-x86_64 -net socket,
> qemu-system-x86_64: -net socket: exactly one of fd=, listen=, connect=,
> mcast= or udp= is required
>
> At the same time, add many explicit error handling message when it fails.
Suggest "This also fixes a few silent failures to report an error."
Perhaps Jason can touch this up for you.
> Cc: address@hidden
> Cc: address@hidden
> Cc: address@hidden
> Signed-off-by: Mao Zhongyi <address@hidden>
> ---
> net/socket.c | 92
> +++++++++++++++++++++++++++++-------------------------------
> 1 file changed, 44 insertions(+), 48 deletions(-)
>
> diff --git a/net/socket.c b/net/socket.c
> index 1d4c515..ca1878f 100644
> --- a/net/socket.c
> +++ b/net/socket.c
[...]
> @@ -746,7 +742,7 @@ int net_init_socket(const Netdev *netdev, const char
> *name,
> /* if sock->localaddr is missing, it has been initialized to "all
> bits
> * zero" */
> if (net_socket_mcast_init(peer, "socket", name, sock->mcast,
> - sock->localaddr) == -1) {
> + sock->localaddr, errp) < 0) {
Indent like this:
sock->localaddr, errp) < 0) {
Perhaps Jason can touch this up for you.
> return -1;
> }
> return 0;
> @@ -754,11 +750,11 @@ int net_init_socket(const Netdev *netdev, const char
> *name,
>
> assert(sock->has_udp);
> if (!sock->has_localaddr) {
> - error_report("localaddr= is mandatory with udp=");
> + error_setg(errp, "localaddr= is mandatory with udp=");
> return -1;
> }
> - if (net_socket_udp_init(peer, "socket", name, sock->udp,
> sock->localaddr) ==
> - -1) {
> + if (net_socket_udp_init(peer, "socket", name, sock->udp, sock->localaddr,
> + errp) < 0) {
Likewise.
> return -1;
> }
> return 0;
With the indentation fixed:
Reviewed-by: Markus Armbruster <address@hidden>