From d2e49aad7259af943b72be761ee5c18e14acd71a Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 30 Mar 2017 19:43:10 +0200 Subject: char: Fix socket with "type": "vsock" address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Watch this: $ qemu-system-x86_64 -nodefaults -S -display none -qmp stdio {"QMP": {"version": {"qemu": {"micro": 91, "minor": 8, "major": 2}, "package": " (v2.8.0-1195-gf84141e-dirty)"}, "capabilities": []}} { "execute": "qmp_capabilities" } {"return": {}} { "execute": "chardev-add", "arguments": { "id": "chr0", "backend": { "type": "socket", "data": { "addr": { "type": "vsock", "data": { "cid": "CID", "port": "P" }}}}}} Aborted (core dumped) Crashes because SocketAddress_to_str() is blissfully unaware of SOCKET_ADDRESS_KIND_VSOCK. Fix that. Pick the output format to match socket_parse(), just like the existing formats. Cc: Stefan Hajnoczi Cc: Paolo Bonzini Cc: Marc-André Lureau Signed-off-by: Markus Armbruster Reviewed-by: Marc-André Lureau Reviewed-by: Max Reitz Message-id: 1490895797-29094-3-git-send-email-armbru@redhat.com Reviewed-by: Stefan Hajnoczi Signed-off-by: Max Reitz --- chardev/char-socket.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 6344b07..36ab0d6 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -357,6 +357,10 @@ static char *SocketAddress_to_str(const char *prefix, SocketAddress *addr, return g_strdup_printf("%sfd:%s%s", prefix, addr->u.fd.data->str, is_listen ? ",server" : ""); break; + case SOCKET_ADDRESS_KIND_VSOCK: + return g_strdup_printf("%svsock:%s:%s", prefix, + addr->u.vsock.data->cid, + addr->u.vsock.data->port); default: abort(); } -- cgit v1.1