qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Ashijeet Acharya <ashijeetacharya@gmail.com>
Cc: kraxel@redhat.com, pbonzini@redhat.com, jasowang@redhat.com,
	stefanha@gmail.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] Change net/socket.c to use socket_*() functions
Date: Thu, 23 Jun 2016 10:27:13 +0100	[thread overview]
Message-ID: <20160623092713.GH17868@redhat.com> (raw)
In-Reply-To: <1466236442-11513-1-git-send-email-ashijeetacharya@gmail.com>

On Sat, Jun 18, 2016 at 01:24:02PM +0530, Ashijeet Acharya wrote:
> Use socket_*() functions from include/qemu/sockets.h instead of listen()/bind()/  connect()/parse_host_port(). socket_*() fucntions are QAPI based and this patch   performs this api conversion since everything will be using QAPI based sockets in the future. Also add a helper function socket_address_to_string() in              util/qemu-sockets.c which returns the string representation of socket address. Thetask was listed on http://wiki.qemu.org/BiteSizedTasks page.
> 
> Signed-off-by: Ashijeet Acharya <ashijeetacharya@gmail.com>
> ---
>  include/qemu/sockets.h | 16 ++++++++++++++-
>  net/socket.c           | 55 +++++++++++++++++++++++++-------------------------
>  util/qemu-sockets.c    | 36 +++++++++++++++++++++++++++++++++
>  3 files changed, 78 insertions(+), 29 deletions(-)
> 


> diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
> index 0d6cd1f..771b7db 100644
> --- a/util/qemu-sockets.c
> +++ b/util/qemu-sockets.c
> @@ -1151,3 +1151,39 @@ void qapi_copy_SocketAddress(SocketAddress **p_dest,
>      qmp_input_visitor_cleanup(qiv);
>      qobject_decref(obj);
>  }
> +
> +char *socket_address_to_string(struct SocketAddress *addr, Error **errp)
> +{
> +    char *buf;
> +    InetSocketAddress *inet;
> +    char host_port[INET6_ADDRSTRLEN + 5 + 4];
> +
> +    switch (addr->type) {
> +    case SOCKET_ADDRESS_KIND_INET:
> +        inet = addr->u.inet.data;
> +        if (strchr(inet->host, ':') == NULL) {
> +            snprintf(host_port, sizeof(host_port), "%s:%s", inet->host,
> +                    inet->port);
> +            buf = g_strdup(host_port);
> +        } else {
> +            snprintf(host_port, sizeof(host_port), "[%s]:%s", inet->host,
> +                    inet->port);
> +            buf = g_strdup(host_port);

I see the patch is already queued, but really this should be changed to
not use a preallocated buffer. It should instead use g_strdup_printf()

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

  parent reply	other threads:[~2016-06-23  9:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-12 17:03 [Qemu-devel] [PATCH] Modify net/socket.c to use socket_* functions from include/qemu/sockets.h Ashijeet Acharya
2016-05-16 16:41 ` Stefan Hajnoczi
2016-05-31  9:27   ` Ashijeet Acharya
2016-05-31 15:01     ` Paolo Bonzini
2016-06-05 18:06       ` Ashijeet Acharya
2016-06-06  8:07         ` Paolo Bonzini
2016-06-16 10:20     ` [Qemu-devel] [PATCH] Change net/socket.c to use socket_*() functions Ashijeet Acharya
2016-06-17 12:38       ` Paolo Bonzini
2016-06-18  7:54       ` [Qemu-devel] [PATCH v2] " Ashijeet Acharya
2016-06-20 14:55         ` Paolo Bonzini
2016-06-20 15:09           ` Peter Maydell
2016-06-21  1:49             ` Jason Wang
2016-06-21  7:06               ` Ashijeet Acharya
2016-06-23  9:27         ` Daniel P. Berrange [this message]
2016-05-31  9:57   ` [Qemu-devel] [PATCH] Modify net/socket.c to use socket_* functions from include/qemu/sockets.h Ashi
2016-06-09 12:19     ` Stefan Hajnoczi

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=20160623092713.GH17868@redhat.com \
    --to=berrange@redhat.com \
    --cc=ashijeetacharya@gmail.com \
    --cc=jasowang@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /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).