From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2uHF-00029M-7I for qemu-devel@nongnu.org; Fri, 26 Jul 2013 22:30:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V2uHD-0005Rz-3T for qemu-devel@nongnu.org; Fri, 26 Jul 2013 22:30:36 -0400 Received: from cantor2.suse.de ([195.135.220.15]:52424 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2uHC-0005Rj-Cz for qemu-devel@nongnu.org; Fri, 26 Jul 2013 22:30:34 -0400 Message-ID: <51F330C4.3040606@suse.de> Date: Sat, 27 Jul 2013 04:30:28 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1374891788-17567-1-git-send-email-mrhines@linux.vnet.ibm.com> In-Reply-To: <1374891788-17567-1-git-send-email-mrhines@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] rdma: bugfix: make IPv6 support work List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: mrhines@linux.vnet.ibm.com Cc: aliguori@us.ibm.com, quintela@redhat.com, qemu-devel@nongnu.org, owasserm@redhat.com, mrhines@us.ibm.com, pbonzini@redhat.com Am 27.07.2013 04:23, schrieb mrhines@linux.vnet.ibm.com: > From: "Michael R. Hines" >=20 > When testing with libvirt, a simple IPv6 migration test failed > because we were not using getaddrinfo() properly. > This makes IPv6 migration over RDMA work. >=20 > Also, we forgot to turn the DPRINTF flag off =3D). >=20 > Signed-off-by: Michael R. Hines > --- > migration-rdma.c | 35 ++++++++++++++++++++++------------- > 1 file changed, 22 insertions(+), 13 deletions(-) >=20 > diff --git a/migration-rdma.c b/migration-rdma.c > index d044830..3256c9b 100644 > --- a/migration-rdma.c > +++ b/migration-rdma.c > @@ -27,7 +27,7 @@ > #include > #include > =20 > -#define DEBUG_RDMA > +//#define DEBUG_RDMA > //#define DEBUG_RDMA_VERBOSE > //#define DEBUG_RDMA_REALLY_VERBOSE > =20 > @@ -392,6 +392,7 @@ typedef struct RDMAContext { > uint64_t unregistrations[RDMA_SIGNALED_SEND_MAX]; > =20 > GHashTable *blockmap; > + bool ipv6; > } RDMAContext; > =20 > /* > @@ -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] =3D "unknown"; > + int af =3D rdma->ipv6 ? PF_INET6 : PF_INET; > =20 > if (rdma->host =3D=3D 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; > } > =20 > - inet_ntop(AF_INET, &((struct sockaddr_in *) res->ai_addr)->sin_add= r, > + inet_ntop(af, &((struct sockaddr_in *) res->ai_addr)->sin_addr, > ip, sizeof ip); > DPRINTF("%s =3D> %s\n", rdma->host, ip); > =20 > @@ -2236,9 +2238,12 @@ err_rdma_source_connect: > static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp) > { > int ret =3D -EINVAL, idx; > + int af =3D rdma->ipv6 ? PF_INET6 : PF_INET; > struct sockaddr_in sin; > struct rdma_cm_id *listen_id; > char ip[40] =3D "unknown"; > + struct addrinfo *res; > + char port_str[16]; > =20 > for (idx =3D 0; idx <=3D RDMA_WRID_MAX; idx++) { > rdma->wr_data[idx].control_len =3D 0; > @@ -2266,27 +2271,30 @@ static int qemu_rdma_dest_init(RDMAContext *rdm= a, Error **errp) > } > =20 > memset(&sin, 0, sizeof(sin)); > - sin.sin_family =3D AF_INET; > + sin.sin_family =3D af;=20 > sin.sin_port =3D htons(rdma->port); > + snprintf(port_str, 16, "%d", rdma->port); > + port_str[15] =3D '\0'; > =20 > if (rdma->host && strcmp("", rdma->host)) { > - struct hostent *dest_addr; > - dest_addr =3D gethostbyname(rdma->host); > - if (!dest_addr) { > - ERROR(errp, "migration could not gethostbyname!\n"); > - ret =3D -EINVAL; > + ret =3D getaddrinfo(rdma->host, port_str, NULL, &res); > + if (ret < 0) { > + ERROR(errp, "could not getaddrinfo address %s\n", rdma->ho= st); > 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 =3D INADDR_ANY; > + ERROR(errp, "migration host and port not specified!\n"); Since ERROR() appears to be operating on errp, none of them should be adding a \n. Andreas > + ret =3D -EINVAL; > + goto err_dest_init_bind_addr; > } > =20 > DPRINTF("%s =3D> %s\n", rdma->host, ip); > =20 > - ret =3D rdma_bind_addr(listen_id, (struct sockaddr *)&sin); > + ret =3D 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 !=3D NULL) { > rdma->port =3D atoi(addr->port); > rdma->host =3D g_strdup(addr->host); > + rdma->ipv6 =3D addr->ipv6; > } else { > ERROR(errp, "bad RDMA migration address '%s'", host_port); > g_free(rdma); >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg