From: Peter Maydell <peter.maydell@linaro.org>
To: "Sair, Umair" <Umair_Sair@mentor.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
QEMU Developers <qemu-devel@nongnu.org>,
"qemu-discuss@nongnu.org" <qemu-discuss@nongnu.org>
Subject: Re: [Qemu-devel] [Qemu-discuss] TCP options ipv4 and ipv6 have no effect
Date: Fri, 2 Oct 2015 18:56:39 +0100 [thread overview]
Message-ID: <CAFEAcA8CY2T0-gOMPphDYqHGqasH62EFSyxHvbd+Z5oG0gzAFA@mail.gmail.com> (raw)
In-Reply-To: <9B0F7F7B0E031F4A99FC8A50E22E3AA360FC1AFD@EU-MBX-01.mgc.mentorg.com>
(looping in qemu-devel and Paolo)
On 2 October 2015 at 17:54, Sair, Umair <Umair_Sair@mentor.com> 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
next parent reply other threads:[~2015-10-02 17:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <9B0F7F7B0E031F4A99FC8A50E22E3AA360FC1AFD@EU-MBX-01.mgc.mentorg.com>
2015-10-02 17:56 ` Peter Maydell [this message]
2015-10-02 18:20 ` [Qemu-devel] [Qemu-discuss] TCP options ipv4 and ipv6 have no effect Sair, Umair
2015-10-02 22:36 ` Peter Maydell
2015-10-04 10:47 ` Paolo Bonzini
2015-10-05 18:03 ` Sair, Umair
2015-10-05 19:22 ` Paolo Bonzini
2015-10-05 19:27 ` Paolo Bonzini
2015-10-12 13:06 ` Sair, Umair
2015-10-12 13:25 ` Paolo Bonzini
2015-10-03 8:38 ` Liviu Ionescu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFEAcA8CY2T0-gOMPphDYqHGqasH62EFSyxHvbd+Z5oG0gzAFA@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=Umair_Sair@mentor.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-discuss@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).