All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>
Cc: qemu-devel@nongnu.org, "Eric Blake" <eblake@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>
Subject: Re: [PATCH v5 11/12] qemu-sockets: introduce socket_uri()
Date: Thu, 30 Jun 2022 10:35:39 +0100	[thread overview]
Message-ID: <Yr1uayTXpxVASlk7@work-vm> (raw)
In-Reply-To: <20220627154749.871943-12-lvivier@redhat.com>

* Laurent Vivier (lvivier@redhat.com) wrote:
> Format a string URI from a SocketAddress.
> 
> Original code from hmp-cmds.c:SocketAddress_to_str()
> 
> Replace 'tcp:' by 'inet:' (because 'inet' can be also 'udp').

I think that's OK, it'll look a little odd in migration where
the syntax for a migration URI is tcp: (and is a tcp stream)
and then when you 'info migrate', which is where this is origianlly
used, it turns into inet.

> Replace 'tcp:' by 'vsock:' with vsock socket type.

> Signed-off-by: Laurent Vivier <lvivier@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  include/qemu/sockets.h |  2 +-
>  monitor/hmp-cmds.c     | 23 +----------------------
>  util/qemu-sockets.c    | 20 ++++++++++++++++++++
>  3 files changed, 22 insertions(+), 23 deletions(-)
> 
> diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h
> index 47194b9732f8..3e2ae7e21705 100644
> --- a/include/qemu/sockets.h
> +++ b/include/qemu/sockets.h
> @@ -41,6 +41,7 @@ int unix_listen(const char *path, Error **errp);
>  int unix_connect(const char *path, Error **errp);
>  
>  SocketAddress *socket_parse(const char *str, Error **errp);
> +char *socket_uri(SocketAddress *addr);
>  int socket_connect(SocketAddress *addr, Error **errp);
>  int socket_listen(SocketAddress *addr, int num, Error **errp);
>  void socket_listen_cleanup(int fd, Error **errp);
> @@ -123,5 +124,4 @@ SocketAddress *socket_address_flatten(SocketAddressLegacy *addr);
>   * Return 0 on success.
>   */
>  int socket_address_parse_named_fd(SocketAddress *addr, Error **errp);
> -
>  #endif /* QEMU_SOCKETS_H */
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index ca98df04952b..8ebb437d1b6a 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -197,27 +197,6 @@ void hmp_info_mice(Monitor *mon, const QDict *qdict)
>      qapi_free_MouseInfoList(mice_list);
>  }
>  
> -static char *SocketAddress_to_str(SocketAddress *addr)
> -{
> -    switch (addr->type) {
> -    case SOCKET_ADDRESS_TYPE_INET:
> -        return g_strdup_printf("tcp:%s:%s",
> -                               addr->u.inet.host,
> -                               addr->u.inet.port);
> -    case SOCKET_ADDRESS_TYPE_UNIX:
> -        return g_strdup_printf("unix:%s",
> -                               addr->u.q_unix.path);
> -    case SOCKET_ADDRESS_TYPE_FD:
> -        return g_strdup_printf("fd:%s", addr->u.fd.str);
> -    case SOCKET_ADDRESS_TYPE_VSOCK:
> -        return g_strdup_printf("tcp:%s:%s",
> -                               addr->u.vsock.cid,
> -                               addr->u.vsock.port);
> -    default:
> -        return g_strdup("unknown address type");
> -    }
> -}
> -
>  void hmp_info_migrate(Monitor *mon, const QDict *qdict)
>  {
>      MigrationInfo *info;
> @@ -375,7 +354,7 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
>          monitor_printf(mon, "socket address: [\n");
>  
>          for (addr = info->socket_address; addr; addr = addr->next) {
> -            char *s = SocketAddress_to_str(addr->value);
> +            char *s = socket_uri(addr->value);
>              monitor_printf(mon, "\t%s\n", s);
>              g_free(s);
>          }
> diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
> index 13b5b197f9ea..4efc2ce8b074 100644
> --- a/util/qemu-sockets.c
> +++ b/util/qemu-sockets.c
> @@ -1098,6 +1098,26 @@ int unix_connect(const char *path, Error **errp)
>      return sock;
>  }
>  
> +char *socket_uri(SocketAddress *addr)
> +{
> +    switch (addr->type) {
> +    case SOCKET_ADDRESS_TYPE_INET:
> +        return g_strdup_printf("inet:%s:%s",
> +                               addr->u.inet.host,
> +                               addr->u.inet.port);
> +    case SOCKET_ADDRESS_TYPE_UNIX:
> +        return g_strdup_printf("unix:%s",
> +                               addr->u.q_unix.path);
> +    case SOCKET_ADDRESS_TYPE_FD:
> +        return g_strdup_printf("fd:%s", addr->u.fd.str);
> +    case SOCKET_ADDRESS_TYPE_VSOCK:
> +        return g_strdup_printf("vsock:%s:%s",
> +                               addr->u.vsock.cid,
> +                               addr->u.vsock.port);
> +    default:
> +        return g_strdup("unknown address type");
> +    }
> +}
>  
>  SocketAddress *socket_parse(const char *str, Error **errp)
>  {
> -- 
> 2.36.1
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



  reply	other threads:[~2022-06-30  9:38 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-27 15:47 [PATCH v5 00/12] qapi: net: add unix socket type support to netdev backend Laurent Vivier
2022-06-27 15:47 ` [PATCH v5 01/12] net: introduce convert_host_port() Laurent Vivier
2022-06-27 15:47 ` [PATCH v5 02/12] net: remove the @errp argument of net_client_inits() Laurent Vivier
2022-06-27 15:47 ` [PATCH v5 03/12] net: simplify net_client_parse() error management Laurent Vivier
2022-06-29 10:50   ` Markus Armbruster
2022-06-27 15:47 ` [PATCH v5 04/12] qapi: net: introduce a way to bypass qemu_opts_parse_noisily() Laurent Vivier
2022-06-29 13:21   ` Markus Armbruster
2022-06-27 15:47 ` [PATCH v5 05/12] qapi: net: add stream and dgram netdevs Laurent Vivier
2022-06-29 11:20   ` Markus Armbruster
2022-06-30 15:09     ` Laurent Vivier
2022-06-29 13:49   ` Markus Armbruster
2022-06-27 15:47 ` [PATCH v5 06/12] net: stream: Don't ignore EINVAL on netdev socket connection Laurent Vivier
2022-06-27 15:47 ` [PATCH v5 07/12] net: stream: add unix socket Laurent Vivier
2022-06-30  9:28   ` Dr. David Alan Gilbert
2022-07-01  9:20     ` Laurent Vivier
2022-07-04  5:12       ` Markus Armbruster
2022-06-27 15:47 ` [PATCH v5 08/12] net: dgram: make dgram_dst generic Laurent Vivier
2022-06-27 15:47 ` [PATCH v5 09/12] net: dgram: move mcast specific code from net_socket_fd_init_dgram() Laurent Vivier
2022-06-27 15:47 ` [PATCH v5 10/12] net: dgram: add unix socket Laurent Vivier
2022-06-27 15:47 ` [PATCH v5 11/12] qemu-sockets: introduce socket_uri() Laurent Vivier
2022-06-30  9:35   ` Dr. David Alan Gilbert [this message]
2022-06-27 15:47 ` [PATCH v5 12/12] net: stream: move to QIO Laurent Vivier

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=Yr1uayTXpxVASlk7@work-vm \
    --to=dgilbert@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.