mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-26 20:03:54 -06:00
net: introduce qemu_set_info_str() function
Embed the setting of info_str in a function. Signed-off-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Acked-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
parent
f3eedcddba
commit
53b85d9574
11 changed files with 41 additions and 47 deletions
33
net/socket.c
33
net/socket.c
|
@ -179,7 +179,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;
|
||||
memset(s->nc.info_str, 0, sizeof(s->nc.info_str));
|
||||
qemu_set_info_str(&s->nc, "");
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -387,16 +387,15 @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer,
|
|||
/* mcast: save bound address as dst */
|
||||
if (is_connected && mcast != NULL) {
|
||||
s->dgram_dst = saddr;
|
||||
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));
|
||||
qemu_set_info_str(nc, "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;
|
||||
}
|
||||
|
||||
snprintf(nc->info_str, sizeof(nc->info_str),
|
||||
"socket: fd=%d %s", fd, SocketAddressType_str(sa_type));
|
||||
qemu_set_info_str(nc, "socket: fd=%d %s", fd,
|
||||
SocketAddressType_str(sa_type));
|
||||
}
|
||||
|
||||
return s;
|
||||
|
@ -430,7 +429,7 @@ static NetSocketState *net_socket_fd_init_stream(NetClientState *peer,
|
|||
|
||||
nc = qemu_new_net_client(&net_socket_info, peer, model, name);
|
||||
|
||||
snprintf(nc->info_str, sizeof(nc->info_str), "socket: fd=%d", fd);
|
||||
qemu_set_info_str(nc, "socket: fd=%d", fd);
|
||||
|
||||
s = DO_UPCAST(NetSocketState, nc, nc);
|
||||
|
||||
|
@ -497,9 +496,8 @@ static void net_socket_accept(void *opaque)
|
|||
s->fd = fd;
|
||||
s->nc.link_down = false;
|
||||
net_socket_connect(s);
|
||||
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
|
||||
"socket: connection from %s:%d",
|
||||
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
|
||||
qemu_set_info_str(&s->nc, "socket: connection from %s:%d",
|
||||
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
|
||||
}
|
||||
|
||||
static int net_socket_listen_init(NetClientState *peer,
|
||||
|
@ -597,9 +595,8 @@ static int net_socket_connect_init(NetClientState *peer,
|
|||
return -1;
|
||||
}
|
||||
|
||||
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
|
||||
"socket: connect to %s:%d",
|
||||
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
|
||||
qemu_set_info_str(&s->nc, "socket: connect to %s:%d",
|
||||
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -642,9 +639,8 @@ static int net_socket_mcast_init(NetClientState *peer,
|
|||
|
||||
s->dgram_dst = saddr;
|
||||
|
||||
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
|
||||
"socket: mcast=%s:%d",
|
||||
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
|
||||
qemu_set_info_str(&s->nc, "socket: mcast=%s:%d",
|
||||
inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
@ -697,9 +693,8 @@ static int net_socket_udp_init(NetClientState *peer,
|
|||
|
||||
s->dgram_dst = raddr;
|
||||
|
||||
snprintf(s->nc.info_str, sizeof(s->nc.info_str),
|
||||
"socket: udp=%s:%d",
|
||||
inet_ntoa(raddr.sin_addr), ntohs(raddr.sin_port));
|
||||
qemu_set_info_str(&s->nc, "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