qemu-devel
[Top][All Lists]
Advanced

[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: Mao Zhongyi
Subject: Re: [Qemu-devel] [PATCH v8 4/4] net/socket: Improve -net socket error reporting
Date: Thu, 6 Jul 2017 16:07:02 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

Hi, Markus

On 07/06/2017 03:24 PM, Markus Armbruster wrote:
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:

Thanks for your review :)
I will fix and resend it as soon as possible.

Thanks,
Mao

Reviewed-by: Markus Armbruster <address@hidden>








reply via email to

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