qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [Qemu-discuss] TCP options ipv4 and ipv6 have no effect


From: Peter Maydell
Subject: Re: [Qemu-devel] [Qemu-discuss] TCP options ipv4 and ipv6 have no effect
Date: Fri, 2 Oct 2015 18:56:39 +0100

(looping in qemu-devel and Paolo)

On 2 October 2015 at 17:54, Sair, Umair <address@hidden> wrote:
> I am working with qemu-2.4.0. I built it using mingw on Windows. I am having
> a problem while connecting it to gdb. I figured out that qemu gdb server is
> running on IPv6 whereas gdb tries to connect on IPv4. This problem is
> already reported here: https://bugs.launchpad.net/qemu/+bug/562107.
>
> gdd server runs on IPv6 even if I provide ipv4 tcp option (-S -gdb
> tcp::10000,ipv4). In other words, providing ipv4 or ipv6 option have no
> effect on both windows and linux. On linux it always runs on IPv4 and on
> Windows, it always runs on IPv6. Can you please help me out in resolving
> this problem?
>
> I debugged qemu a bit and it seems to me that the problem is in
> ‘inet_addr_to_opts()’ function of ‘qemu-sockets.c’. Following is the excerpt
> from this function:
>
> static void inet_addr_to_opts(QemuOpts *opts, const InetSocketAddress *addr)
> {
>
>     bool ipv4 = addr->ipv4 || !addr->has_ipv4;
>     bool ipv6 = addr->ipv6 || !addr->has_ipv6;
>
>     if (!ipv4 || !ipv6) {
>         qemu_opt_set_bool(opts, "ipv4", ipv4);
>         qemu_opt_set_bool(opts, "ipv6", ipv6);
>     }
>
> The ipv4 and ipv6 variables of this function are always true (because we set
> addr->ipv4 = addr->has_ipv4 and addr->ipv6 = addr->has_ipv6), hence ipv4 and
> ipv6 option is never set in the if condition. The consequence is that the
> socket is created with PF_UNSPEC and then for windows IPv6 and for linux
> IPv4 socket is created (see inet_listen_opts() in qemu-sockets.c). Is there
> a particular reason for the logic of inet_addr_to_opts()?

I'm not sure, but something definitely seems weird here; either
inet_parse or inet_addr_to_opts is wrong, I think.

Paolo, you wrote this code I think; any idea?

My guess is that inet_parse should be setting addr->has_ipv6
to true (leaving addr->ipv6 false) if it decides it should be
using IPv4 (and vice-versa for IPv6).

inet_addr_to_opts I think is correct where it does:
    bool ipv4 = addr->ipv4 || !addr->has_ipv4;
because this is saying "try ipv4 if specifically asked, or if
the caller didn't specify either way".

I don't know why we have the "if (!ipv4 || !ipv6)" condition on
the setting of the opts, though.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]