mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
chardev: use remoteAddr if the chardev is client
If the chardev is client, the socket file path in localAddr may be NULL. This is because the socket path comes from getsockname(), according to man page, getsockname() returns the current address bound by the socket sockfd. If the chardev is client, it's socket is unbound sockfd. Therefore, when computing the client chardev socket file path, using remoteAddr is more appropriate. Signed-off-by: Haoqian He <haoqian.he@smartx.com> Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20250225104526.2924175-1-haoqian.he@smartx.com>
This commit is contained in:
parent
a97ef36244
commit
46f83c898a
1 changed files with 7 additions and 3 deletions
|
@ -571,9 +571,13 @@ static char *qemu_chr_compute_filename(SocketChardev *s)
|
|||
|
||||
switch (ss->ss_family) {
|
||||
case AF_UNIX:
|
||||
return g_strdup_printf("unix:%s%s",
|
||||
((struct sockaddr_un *)(ss))->sun_path,
|
||||
s->is_listen ? ",server=on" : "");
|
||||
if (s->is_listen) {
|
||||
return g_strdup_printf("unix:%s,server=on",
|
||||
((struct sockaddr_un *)(ss))->sun_path);
|
||||
} else {
|
||||
return g_strdup_printf("unix:%s",
|
||||
((struct sockaddr_un *)(ps))->sun_path);
|
||||
}
|
||||
case AF_INET6:
|
||||
left = "[";
|
||||
right = "]";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue