mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-26 20:03:54 -06:00
Revert "net: Move NetClientState.info_str to dynamic allocations"
Several issues has been reported for query-netdev info
series. Consider it's late in the rc, this reverts commit
commit 59b5437eb7
.
Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
parent
603f2f7c6c
commit
56e6f594bf
11 changed files with 49 additions and 47 deletions
43
net/socket.c
43
net/socket.c
|
@ -180,8 +180,7 @@ static void net_socket_send(void *opaque)
|
|||
s->fd = -1;
|
||||
net_socket_rs_init(&s->rs, net_socket_rs_finalize, false);
|
||||
s->nc.link_down = true;
|
||||
g_free(s->nc.info_str);
|
||||
s->nc.info_str = g_new0(char, 1);
|
||||
memset(s->nc.info_str, 0, sizeof(s->nc.info_str));
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -401,16 +400,16 @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
|
|||
stored->mcast = g_strdup(mcast);
|
||||
|
||||
s->dgram_dst = saddr;
|
||||
nc->info_str = g_strdup_printf("socket: fd=%d (cloned mcast=%s:%d)",
|
||||
fd, inet_ntoa(saddr.sin_addr),
|
||||
ntohs(saddr.sin_port));
|
||||
snprintf(nc->info_str, sizeof(nc->info_str),
|
||||
"socket: fd=%d (cloned mcast=%s:%d)",
|
||||
fd, inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
|
||||
} else {
|
||||
if (sa_type == SOCKET_ADDRESS_TYPE_UNIX) {
|
||||
s->dgram_dst.sin_family = AF_UNIX;
|
||||
}
|
||||
|
||||
nc->info_str = g_strdup_printf("socket: fd=%d %s",
|
||||
fd, SocketAddressType_str(sa_type));
|
||||
snprintf(nc->info_str, sizeof(nc->info_str),
|
||||
"socket: fd=%d %s", fd, SocketAddressType_str(sa_type));
|
||||
}
|
||||
|
||||
return s;
|
||||
|
@ -445,7 +444,7 @@ static NetSocketState *net_socket_fd_init_stream(NetClientState *peer,
|
|||
|
||||
nc = qemu_new_net_client(&net_socket_info, peer, model, name);
|
||||
|
||||
nc->info_str = g_strdup_printf("socket: fd=%d", fd);
|
||||
snprintf(nc->info_str, sizeof(nc->info_str), "socket: fd=%d", fd);
|
||||
|
||||
s = DO_UPCAST(NetSocketState, nc, nc);
|
||||
|
||||
|
@ -529,10 +528,9 @@ static void net_socket_accept(void *opaque)
|
|||
stored->has_fd = true;
|
||||
stored->fd = g_strdup_printf("%d", fd);
|
||||
|
||||
g_free(s->nc.info_str);
|
||||
s->nc.info_str = g_strdup_printf("socket: connection from %s:%d",
|
||||
inet_ntoa(saddr.sin_addr),
|
||||
ntohs(saddr.sin_port));
|
||||
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
|
||||
"socket: connection from %s:%d",
|
||||
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
|
||||
}
|
||||
|
||||
static int net_socket_listen_init(NetClientState *peer,
|
||||
|
@ -647,10 +645,9 @@ static int net_socket_connect_init(NetClientState *peer,
|
|||
stored->has_connect = true;
|
||||
stored->connect = g_strdup(host_str);
|
||||
|
||||
g_free(s->nc.info_str);
|
||||
s->nc.info_str = g_strdup_printf("socket: connect to %s:%d",
|
||||
inet_ntoa(saddr.sin_addr),
|
||||
ntohs(saddr.sin_port));
|
||||
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
|
||||
"socket: connect to %s:%d",
|
||||
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -707,10 +704,9 @@ static int net_socket_mcast_init(NetClientState *peer,
|
|||
stored->localaddr = g_strdup(localaddr_str);
|
||||
}
|
||||
|
||||
g_free(s->nc.info_str);
|
||||
s->nc.info_str = g_strdup_printf("socket: mcast=%s:%d",
|
||||
inet_ntoa(saddr.sin_addr),
|
||||
ntohs(saddr.sin_port));
|
||||
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
|
||||
"socket: mcast=%s:%d",
|
||||
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
@ -773,10 +769,9 @@ static int net_socket_udp_init(NetClientState *peer,
|
|||
stored->has_udp = true;
|
||||
stored->udp = g_strdup(rhost);
|
||||
|
||||
g_free(s->nc.info_str);
|
||||
s->nc.info_str = g_strdup_printf("socket: udp=%s:%d",
|
||||
inet_ntoa(raddr.sin_addr),
|
||||
ntohs(raddr.sin_port));
|
||||
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
|
||||
"socket: udp=%s:%d",
|
||||
inet_ntoa(raddr.sin_addr), ntohs(raddr.sin_port));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue