qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
Cc: qemu-devel@nongnu.org, jasowang@redhat.com, armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH v6 1/4] net/socket: Don't treat odd socket type as SOCK_STREAM
Date: Wed, 28 Jun 2017 14:18:52 +0100	[thread overview]
Message-ID: <20170628131852.GH29134@redhat.com> (raw)
In-Reply-To: <d9660b46628b52aa8c63c21fe20618b5bc33bb4c.1498654240.git.maozy.fnst@cn.fujitsu.com>

On Wed, Jun 28, 2017 at 09:08:47PM +0800, Mao Zhongyi wrote:
> In net_socket_fd_init(), the 'default' case is odd: it warns,
> then continues as if the socket type was SOCK_STREAM. The
> comment explains "this could be a eg. a pty", but that makes
> no sense. If @fd really was a pty, getsockopt() would fail
> with ENOTSOCK. If @fd was a socket, but neither SOCK_DGRAM nor
> SOCK_STREAM. It should not be treated as if it was SOCK_STREAM.
> 
> Turn this case into an Error. If there is a genuine reason to
> support something like SOCK_RAW, it should be explicitly
> handled.
> 
> Cc: jasowang@redhat.com
> Cc: armbru@redhat.com
> Cc: berrange@redhat.com
> Cc: armbru@redhat.com
> Suggested-by: Markus Armbruster <armbru@redhat.com>
> Suggested-by: Daniel P. Berrange <berrange@redhat.com>
> Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> ---
>  net/socket.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/net/socket.c b/net/socket.c
> index dcae1ae..53765bd 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -449,9 +449,9 @@ static NetSocketState *net_socket_fd_init(NetClientState *peer,
>      case SOCK_STREAM:
>          return net_socket_fd_init_stream(peer, model, name, fd, is_connected);
>      default:
> -        /* who knows ... this could be a eg. a pty, do warn and continue as stream */
> -        fprintf(stderr, "qemu: warning: socket type=%d for fd=%d is not SOCK_DGRAM or SOCK_STREAM\n", so_type, fd);
> -        return net_socket_fd_init_stream(peer, model, name, fd, is_connected);
> +        error_report("qemu: error: socket type=%d for fd=%d is not"
> +                " SOCK_DGRAM or SOCK_STREAM", so_type, fd);

Please drop the 'qemu: error: ' prefix on the message

Also, rather than 'is not' I suggest 'must be either'


> +        closesocket(fd);
>      }
>      return NULL;
>  }


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

  reply	other threads:[~2017-06-28 13:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-28 13:08 [Qemu-devel] [PATCH v6 0/4] Improve error reporting Mao Zhongyi
2017-06-28 13:08 ` [Qemu-devel] [PATCH v6 1/4] net/socket: Don't treat odd socket type as SOCK_STREAM Mao Zhongyi
2017-06-28 13:18   ` Daniel P. Berrange [this message]
2017-06-28 14:23     ` Eric Blake
2017-06-29  3:24       ` Mao Zhongyi
2017-06-28 13:08 ` [Qemu-devel] [PATCH v6 2/4] net/socket: Convert several helper functions to Error Mao Zhongyi
2017-06-28 13:21   ` Daniel P. Berrange
2017-06-28 13:08 ` [Qemu-devel] [PATCH v6 3/4] net/net: Convert parse_host_port() " Mao Zhongyi
2017-06-28 13:23   ` Daniel P. Berrange
2017-06-28 14:24     ` Eric Blake
2017-06-28 14:28       ` Daniel P. Berrange
2017-06-29  7:29         ` Markus Armbruster
2017-06-29  3:01     ` Mao Zhongyi
2017-06-28 13:08 ` [Qemu-devel] [PATCH v6 4/4] net/socket: Improve -net socket error reporting Mao Zhongyi
2017-06-28 13:27   ` Daniel P. Berrange
2017-06-29  3:08     ` Mao Zhongyi
2017-06-29  7:31       ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170628131852.GH29134@redhat.com \
    --to=berrange@redhat.com \
    --cc=armbru@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=maozy.fnst@cn.fujitsu.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).