qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [v2 3/5] block/ssh: Use inet_connect_saddr() to establi


From: Max Reitz
Subject: Re: [Qemu-devel] [v2 3/5] block/ssh: Use inet_connect_saddr() to establish socket connection
Date: Sun, 16 Oct 2016 00:34:03 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

On 15.10.2016 11:04, Ashijeet Acharya wrote:
> Make inet_connect_saddr() in util/qemu-socktets.c public and use it

*util/qemu-sockets.c

> instead of inet_connect() because this directly takes the
> InetSocketAddress to establish a socket connection for the SSH
> block driver.
> 
> Signed-off-by: Ashijeet Acharya <address@hidden>
> ---
>  block/ssh.c            | 5 +----
>  include/qemu/sockets.h | 2 ++
>  util/qemu-sockets.c    | 2 +-
>  3 files changed, 4 insertions(+), 5 deletions(-)

As I said for patch 3, I'd split this one and pull the part of it that
is making inet_connect_saddr() public in front of patch 2 and squash the
rest into patch 2.

> 
> diff --git a/block/ssh.c b/block/ssh.c
> index 3b18907..6420359 100644
> --- a/block/ssh.c
> +++ b/block/ssh.c
> @@ -666,13 +666,10 @@ static int connect_to_ssh(BDRVSSHState *s, QDict 
> *options,
>          goto err;
>      }
>  
> -    /* Construct the host:port name for inet_connect. */
> -    g_free(s->hostport);
>      port = atoi(s->inet->port);
> -    s->hostport = g_strdup_printf("%s:%d", s->inet->host, port);
>  
>      /* Open the socket and connect. */
> -    s->sock = inet_connect(s->hostport, errp);
> +    s->sock = inet_connect_saddr(s->inet, errp, NULL, NULL);
>      if (s->sock < 0) {
>          ret = -EIO;
>          goto err;
> diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h
> index 9eb2470..5589e68 100644
> --- a/include/qemu/sockets.h
> +++ b/include/qemu/sockets.h
> @@ -34,6 +34,8 @@ typedef void NonBlockingConnectHandler(int fd, Error *err, 
> void *opaque);
>  
>  InetSocketAddress *inet_parse(const char *str, Error **errp);
>  int inet_connect(const char *str, Error **errp);
> +int inet_connect_saddr(InetSocketAddress *saddr, Error **errp,
> +                       NonBlockingConnectHandler *callback, void *opaque);
>  
>  NetworkAddressFamily inet_netfamily(int family);
>  
> diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
> index 4cef549..3411888 100644
> --- a/util/qemu-sockets.c
> +++ b/util/qemu-sockets.c
> @@ -412,7 +412,7 @@ static struct addrinfo 
> *inet_parse_connect_saddr(InetSocketAddress *saddr,
>   * function succeeds, callback will be called when the connection
>   * completes, with the file descriptor on success, or -1 on error.
>   */
> -static int inet_connect_saddr(InetSocketAddress *saddr, Error **errp,
> +int inet_connect_saddr(InetSocketAddress *saddr, Error **errp,
>                                NonBlockingConnectHandler *callback, void 
> *opaque)

You should keep the second line aligned to the opening parenthesis.

Max

>  {
>      Error *local_err = NULL;
> 


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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