Skip to content

Commit

Permalink
qemu-sockets: update socket_uri() and socket_parse() to be consistent
Browse files Browse the repository at this point in the history
To be consistent with socket_uri(), add 'tcp:' prefix for inet type in
socket_parse(), by default socket_parse() use tcp when no prefix is
provided (format is host:port).

In socket_uri(), use 'vsock:' prefix for vsock type rather than 'tcp:'
because it makes a vsock address look like an inet address with CID
misinterpreted as host.
Goes back to commit 9aca82b "migration: Create socket-address parameter"

Signed-off-by: Laurent Vivier <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Reviewed-by: David Gibson <[email protected]>
Acked-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
  • Loading branch information
vivier authored and jasowang committed Oct 28, 2022
1 parent 18bf1c9 commit 7651b32
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion util/qemu-sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ char *socket_uri(SocketAddress *addr)
case SOCKET_ADDRESS_TYPE_FD:
return g_strdup_printf("fd:%s", addr->u.fd.str);
case SOCKET_ADDRESS_TYPE_VSOCK:
return g_strdup_printf("tcp:%s:%s",
return g_strdup_printf("vsock:%s:%s",
addr->u.vsock.cid,
addr->u.vsock.port);
default:
Expand Down Expand Up @@ -1124,6 +1124,11 @@ SocketAddress *socket_parse(const char *str, Error **errp)
if (vsock_parse(&addr->u.vsock, str + strlen("vsock:"), errp)) {
goto fail;
}
} else if (strstart(str, "tcp:", NULL)) {
addr->type = SOCKET_ADDRESS_TYPE_INET;
if (inet_parse(&addr->u.inet, str + strlen("tcp:"), errp)) {
goto fail;
}
} else {
addr->type = SOCKET_ADDRESS_TYPE_INET;
if (inet_parse(&addr->u.inet, str, errp)) {
Expand Down

0 comments on commit 7651b32

Please sign in to comment.