From: Orit Wasserman <owasserm@redhat.com>
To: mrhines@linux.vnet.ibm.com
Cc: yamahata@private.email.ne.jp, aliguori@us.ibm.com,
quintela@redhat.com, qemu-devel@nongnu.org, mrhines@us.ibm.com,
pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH v3 For-1.6 1/7] rdma: bugfix: make IPv6 support work
Date: Wed, 07 Aug 2013 11:39:29 +0300 [thread overview]
Message-ID: <520207C1.6030304@redhat.com> (raw)
In-Reply-To: <1375584894-9917-2-git-send-email-mrhines@linux.vnet.ibm.com>
On 08/04/2013 05:54 AM, mrhines@linux.vnet.ibm.com wrote:
> From: "Michael R. Hines" <mrhines@us.ibm.com>
>
> RDMA does not use sockets, so we cannot use many of the socket
> helper functions, but we *do* use inet_parse() which gives
> RDMA all the necessary details of the connection parameters.
>
> However, when testing with libvirt, a simple IPv6 migration test failed
> because we were not using getaddrinfo() properly.
>
> This makes IPv6 migration over RDMA work.
>
> Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
> ---
> migration-rdma.c | 33 +++++++++++++++++++++------------
> 1 file changed, 21 insertions(+), 12 deletions(-)
>
> diff --git a/migration-rdma.c b/migration-rdma.c
> index d044830..9cf73e3 100644
> --- a/migration-rdma.c
> +++ b/migration-rdma.c
> @@ -392,6 +392,7 @@ typedef struct RDMAContext {
> uint64_t unregistrations[RDMA_SIGNALED_SEND_MAX];
>
> GHashTable *blockmap;
> + bool ipv6;
> } RDMAContext;
>
> /*
> @@ -744,6 +745,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
> char port_str[16];
> struct rdma_cm_event *cm_event;
> char ip[40] = "unknown";
> + int af = rdma->ipv6 ? PF_INET6 : PF_INET;
>
> if (rdma->host == NULL || !strcmp(rdma->host, "")) {
> ERROR(errp, "RDMA hostname has not been set\n");
> @@ -773,7 +775,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp)
> goto err_resolve_get_addr;
> }
>
> - inet_ntop(AF_INET, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
> + inet_ntop(af, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
> ip, sizeof ip);
> DPRINTF("%s => %s\n", rdma->host, ip);
>
> @@ -2236,9 +2238,12 @@ err_rdma_source_connect:
> static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
> {
> int ret = -EINVAL, idx;
> + int af = rdma->ipv6 ? PF_INET6 : PF_INET;
> struct sockaddr_in sin;
> struct rdma_cm_id *listen_id;
> char ip[40] = "unknown";
> + struct addrinfo *res;
> + char port_str[16];
>
> for (idx = 0; idx <= RDMA_WRID_MAX; idx++) {
> rdma->wr_data[idx].control_len = 0;
> @@ -2266,27 +2271,30 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
> }
>
> memset(&sin, 0, sizeof(sin));
> - sin.sin_family = AF_INET;
> + sin.sin_family = af;
> sin.sin_port = htons(rdma->port);
> + snprintf(port_str, 16, "%d", rdma->port);
> + port_str[15] = '\0';
>
> if (rdma->host && strcmp("", rdma->host)) {
> - struct hostent *dest_addr;
> - dest_addr = gethostbyname(rdma->host);
> - if (!dest_addr) {
> - ERROR(errp, "migration could not gethostbyname!\n");
> - ret = -EINVAL;
> + ret = getaddrinfo(rdma->host, port_str, NULL, &res);
Hi Michael,
getaddrinfo can return a list of addresses, you need to handle it.
Look at qemu-sockets.c for example.
Regards,
Orit
> + if (ret < 0) {
> + ERROR(errp, "could not getaddrinfo address %s\n", rdma->host);
> goto err_dest_init_bind_addr;
> }
> - memcpy(&sin.sin_addr.s_addr, dest_addr->h_addr,
> - dest_addr->h_length);
> - inet_ntop(AF_INET, dest_addr->h_addr, ip, sizeof ip);
> +
> +
> + inet_ntop(af, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
> + ip, sizeof ip);
> } else {
> - sin.sin_addr.s_addr = INADDR_ANY;
> + ERROR(errp, "migration host and port not specified!\n");
> + ret = -EINVAL;
> + goto err_dest_init_bind_addr;
> }
>
> DPRINTF("%s => %s\n", rdma->host, ip);
>
> - ret = rdma_bind_addr(listen_id, (struct sockaddr *)&sin);
> + ret = rdma_bind_addr(listen_id, res->ai_addr);
> if (ret) {
> ERROR(errp, "Error: could not rdma_bind_addr!\n");
> goto err_dest_init_bind_addr;
> @@ -2321,6 +2329,7 @@ static void *qemu_rdma_data_init(const char *host_port, Error **errp)
> if (addr != NULL) {
> rdma->port = atoi(addr->port);
> rdma->host = g_strdup(addr->host);
> + rdma->ipv6 = addr->ipv6;
> } else {
> ERROR(errp, "bad RDMA migration address '%s'", host_port);
> g_free(rdma);
>
next prev parent reply other threads:[~2013-08-07 8:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-04 2:54 [Qemu-devel] [PATCH v3 For-1.6 0/7] rdma: bugfixes, cleanups, IPv6 support mrhines
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 1/7] rdma: bugfix: make IPv6 support work mrhines
2013-08-07 8:39 ` Orit Wasserman [this message]
2013-08-07 14:53 ` Michael R. Hines
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 2/7] rdma: forgot to turn off the debugging flag mrhines
2013-08-07 8:39 ` Orit Wasserman
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 3/7] rdma: correct newlines in error statements mrhines
2013-08-07 8:45 ` Orit Wasserman
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 4/7] rdma: don't use negative index to array mrhines
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 5/7] rdma: qemu_rdma_post_send_control uses wrongly RDMA_WRID_MAX mrhines
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 6/7] rdma: use RDMA_WRID_READY mrhines
2013-08-04 2:54 ` [Qemu-devel] [PATCH v3 For-1.6 7/7] rdma: memory leak RDMAContext::host mrhines
2013-08-14 16:27 ` [Qemu-devel] [PATCH v3 For-1.6 0/7] rdma: bugfixes, cleanups, IPv6 support Anthony Liguori
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=520207C1.6030304@redhat.com \
--to=owasserm@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=mrhines@linux.vnet.ibm.com \
--cc=mrhines@us.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=yamahata@private.email.ne.jp \
/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).