[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-discuss] TCP options ipv4 and ipv6 have no effect
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-discuss] TCP options ipv4 and ipv6 have no effect |
Date: |
Sun, 4 Oct 2015 12:47:59 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
On 03/10/2015 00:36, Peter Maydell wrote:
>
> I agree about the (!ipv4 || !ipv6) condition though.
> The three states I listed above ought to correspond
> to "qemu_opt not set", "qemu_opt set to false" and
> "qemu_opt set to true",
The problem is that the underlying QemuOpts-based code treats "qemu_opt not
set" and "qemu_opt set to false" the same way:
ipv4 ipv6
Y Y PF_INET6
Y N PF_INET
N Y PF_INET6
N N PF_UNSPEC
We want:
ipv4 ipv6
Y Y PF_INET6
Y N PF_INET
Y - PF_INET (ipv6 = N)
N Y PF_INET6
N N PF_UNSPEC
N - PF_INET6 (ipv6 = Y)
- Y PF_INET6 (ipv4 = N)
- N PF_INET (ipv4 = Y)
- - PF_UNSPEC
I think this patch gets the desired semantics:
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 2add83a..fdcf3fa 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -586,12 +586,15 @@ fail:
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;
+ bool ipv4 = addr->has_ipv4 && addr->ipv4;
+ bool ipv6 = addr->has_ipv6 && addr->ipv6;
- if (!ipv4 || !ipv6) {
+ if (ipv4 || ipv6) {
qemu_opt_set_bool(opts, "ipv4", ipv4, &error_abort);
qemu_opt_set_bool(opts, "ipv6", ipv6, &error_abort);
+ } else if (addr->has_ipv4 || addr->has_ipv6) {
+ qemu_opt_set_bool(opts, "ipv4", !addr->has_ipv4, &error_abort);
+ qemu_opt_set_bool(opts, "ipv6", !addr->has_ipv6, &error_abort);
}
if (addr->has_to) {
qemu_opt_set_number(opts, "to", addr->to, &error_abort);
The first if handles the "default to N" case, the second handles
"default to Y", the (absent) else case handles "default to
PF_UNSPEC".
Paolo
- [Qemu-discuss] TCP options ipv4 and ipv6 have no effect, Sair, Umair, 2015/10/08
- Re: [Qemu-discuss] TCP options ipv4 and ipv6 have no effect, Peter Maydell, 2015/10/08
- Re: [Qemu-discuss] TCP options ipv4 and ipv6 have no effect, Sair, Umair, 2015/10/08
- Re: [Qemu-discuss] TCP options ipv4 and ipv6 have no effect, Peter Maydell, 2015/10/08
- Re: [Qemu-discuss] TCP options ipv4 and ipv6 have no effect,
Paolo Bonzini <=
- Re: [Qemu-discuss] TCP options ipv4 and ipv6 have no effect, Sair, Umair, 2015/10/08
- Re: [Qemu-discuss] TCP options ipv4 and ipv6 have no effect, Paolo Bonzini, 2015/10/08
- Re: [Qemu-discuss] TCP options ipv4 and ipv6 have no effect, Paolo Bonzini, 2015/10/08
- Re: [Qemu-discuss] TCP options ipv4 and ipv6 have no effect, Sair, Umair, 2015/10/15
- Re: [Qemu-discuss] TCP options ipv4 and ipv6 have no effect, Paolo Bonzini, 2015/10/12
- Re: [Qemu-discuss] [Qemu-devel] TCP options ipv4 and ipv6 have no effect, Liviu Ionescu, 2015/10/08