Revision b58c8552 migration-rdma.c

b/migration-rdma.c
392 392
    uint64_t unregistrations[RDMA_SIGNALED_SEND_MAX];
393 393

  
394 394
    GHashTable *blockmap;
395
    bool ipv6;
395 396
} RDMAContext;
396 397

  
397 398
/*
......
744 745
    char port_str[16];
745 746
    struct rdma_cm_event *cm_event;
746 747
    char ip[40] = "unknown";
748
    int af = rdma->ipv6 ? PF_INET6 : PF_INET;
747 749

  
748 750
    if (rdma->host == NULL || !strcmp(rdma->host, "")) {
749 751
        ERROR(errp, "RDMA hostname has not been set\n");
......
773 775
        goto err_resolve_get_addr;
774 776
    }
775 777

  
776
    inet_ntop(AF_INET, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
778
    inet_ntop(af, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
777 779
                                ip, sizeof ip);
778 780
    DPRINTF("%s => %s\n", rdma->host, ip);
779 781

  
......
2236 2238
static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp)
2237 2239
{
2238 2240
    int ret = -EINVAL, idx;
2241
    int af = rdma->ipv6 ? PF_INET6 : PF_INET;
2239 2242
    struct sockaddr_in sin;
2240 2243
    struct rdma_cm_id *listen_id;
2241 2244
    char ip[40] = "unknown";
2245
    struct addrinfo *res;
2246
    char port_str[16];
2242 2247

  
2243 2248
    for (idx = 0; idx <= RDMA_WRID_MAX; idx++) {
2244 2249
        rdma->wr_data[idx].control_len = 0;
......
2266 2271
    }
2267 2272

  
2268 2273
    memset(&sin, 0, sizeof(sin));
2269
    sin.sin_family = AF_INET;
2274
    sin.sin_family = af;
2270 2275
    sin.sin_port = htons(rdma->port);
2276
    snprintf(port_str, 16, "%d", rdma->port);
2277
    port_str[15] = '\0';
2271 2278

  
2272 2279
    if (rdma->host && strcmp("", rdma->host)) {
2273
        struct hostent *dest_addr;
2274
        dest_addr = gethostbyname(rdma->host);
2275
        if (!dest_addr) {
2276
            ERROR(errp, "migration could not gethostbyname!\n");
2277
            ret = -EINVAL;
2280
        ret = getaddrinfo(rdma->host, port_str, NULL, &res);
2281
        if (ret < 0) {
2282
            ERROR(errp, "could not getaddrinfo address %s\n", rdma->host);
2278 2283
            goto err_dest_init_bind_addr;
2279 2284
        }
2280
        memcpy(&sin.sin_addr.s_addr, dest_addr->h_addr,
2281
                dest_addr->h_length);
2282
        inet_ntop(AF_INET, dest_addr->h_addr, ip, sizeof ip);
2285

  
2286

  
2287
        inet_ntop(af, &((struct sockaddr_in *) res->ai_addr)->sin_addr,
2288
                                    ip, sizeof ip);
2283 2289
    } else {
2284
        sin.sin_addr.s_addr = INADDR_ANY;
2290
        ERROR(errp, "migration host and port not specified!\n");
2291
        ret = -EINVAL;
2292
        goto err_dest_init_bind_addr;
2285 2293
    }
2286 2294

  
2287 2295
    DPRINTF("%s => %s\n", rdma->host, ip);
2288 2296

  
2289
    ret = rdma_bind_addr(listen_id, (struct sockaddr *)&sin);
2297
    ret = rdma_bind_addr(listen_id, res->ai_addr);
2290 2298
    if (ret) {
2291 2299
        ERROR(errp, "Error: could not rdma_bind_addr!\n");
2292 2300
        goto err_dest_init_bind_addr;
......
2321 2329
        if (addr != NULL) {
2322 2330
            rdma->port = atoi(addr->port);
2323 2331
            rdma->host = g_strdup(addr->host);
2332
            rdma->ipv6 = addr->ipv6;
2324 2333
        } else {
2325 2334
            ERROR(errp, "bad RDMA migration address '%s'", host_port);
2326 2335
            g_free(rdma);

Also available in: Unified diff