[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 21/49] qemu-sockets: fix conversion of ipv4/ipv6 JSON
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 21/49] qemu-sockets: fix conversion of ipv4/ipv6 JSON to QemuOpts |
Date: |
Fri, 16 Oct 2015 10:49:43 +0200 |
The QemuOpts-based code treats "option not set" and "option set
to false" the same way for the ipv4 and ipv6 options, because it
is meant to handle only the ",ipv4" and ",ipv6" substrings in
hand-crafted option parsers.
When converting InetSocketAddress to QemuOpts, however, it is
necessary to handle all three cases (not set, set to true, set
to false). Currently we are not handling all cases correctly.
The rules are:
* if none or both options are absent, leave things as is
* if the single present option is Y, the other should be N.
This can be implemented by leaving things as is, or by setting
the other option to N as done in this patch.
* if the single present option is N, the other should be Y.
This is handled by the "else if" branch of this patch.
This ensures that the ipv4 option has an effect on Windows,
where creating the socket with PF_UNSPEC makes an ipv6
socket. With this patch, ",ipv4" will result in a PF_INET
socket instead.
Reported-by: Sair, Umair <address@hidden>
Tested-by: Sair, Umair <address@hidden>
Reviewed-by: Daniel P. Berrange <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
util/qemu-sockets.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 2add83a..0a041a9 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);
--
2.5.0
- [Qemu-devel] [PULL 08/49] checkpatch: allow open braces on typedef lines, (continued)
- [Qemu-devel] [PULL 08/49] checkpatch: allow open braces on typedef lines, Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 10/49] target-i386/kvm: Hyper-V HV_X64_MSR_RESET support, Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 11/49] target-i386/kvm: set Hyper-V features cpuid bit HV_X64_MSR_VP_INDEX_AVAILABLE, Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 13/49] exec: remove non-TCG stuff from exec-all.h header., Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 12/49] target-i386/kvm: Hyper-V HV_X64_MSR_VP_RUNTIME support, Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 14/49] kvm-all: Align to qemu_real_host_page_size in kvm_set_phys_mem, Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 15/49] checkpatch: port fix from kernel "## is not a valid modifier", Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 16/49] MAINTAINERS: add two devices to the e500 section, Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 18/49] MAINTAINERS: Add more pxa2xx files and boards, Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 19/49] MAINTAINERS: Add maintainer for ARM PrimeCell and integrated devices, Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 21/49] qemu-sockets: fix conversion of ipv4/ipv6 JSON to QemuOpts,
Paolo Bonzini <=
- [Qemu-devel] [PULL 20/49] MAINTAINERS: Add more devices to realview board, Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 26/49] qemu-char: convert file backend to data-driven creation, Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 25/49] qemu-char: add create to register_char_driver, Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 23/49] qemu-char: cleanup qmp_chardev_add, Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 24/49] qemu-char: cleanup HAVE_CHARDEV_*, Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 22/49] README: fill out some useful quickstart information, Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 29/49] qemu-char: convert pipe backend to data-driven creation, Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 30/49] qemu-char: convert socket backend to data-driven creation, Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 28/49] qemu-char: convert parallel backend to data-driven creation, Paolo Bonzini, 2015/10/16
- [Qemu-devel] [PULL 32/49] qemu-char: convert pty backend to data-driven creation, Paolo Bonzini, 2015/10/16