We were forgetting to set the ipv4 and ipv6 QemuOpts properties, so socket_dgram was always trying _both_ ipv4 and ipv6. Forward the properties correctly.
Signed-off-by: Paolo Bonzini <[email protected]> --- util/qemu-sockets.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 7a9065b..7391aee 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -958,15 +958,22 @@ int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp) opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); switch (remote->kind) { - case SOCKET_ADDRESS_KIND_INET: + case SOCKET_ADDRESS_KIND_INET: { + bool ipv4 = remote->inet->ipv4 || !remote->inet->has_ipv4; + bool ipv6 = remote->inet->ipv6 || !remote->inet->has_ipv6; qemu_opt_set(opts, "host", remote->inet->host); qemu_opt_set(opts, "port", remote->inet->port); if (local) { qemu_opt_set(opts, "localaddr", local->inet->host); qemu_opt_set(opts, "localport", local->inet->port); } + if (!ipv4 || !ipv6) { + qemu_opt_set_bool(opts, "ipv4", ipv4); + qemu_opt_set_bool(opts, "ipv6", ipv6); + } fd = inet_dgram_opts(opts, errp); break; + } default: error_setg(errp, "socket type unsupported for datagram"); -- 1.8.5.3
