Changeset
blockdev-nbd.c             |  50 +--
chardev/char-socket.c      |  70 ++--
include/io/net-listener.h  | 174 +++++++++
io/Makefile.objs           |   1 +
io/net-listener.c          | 315 ++++++++++++++++
migration/socket.c         |  44 +--
qemu-nbd.c                 |  50 +--
tests/.gitignore           |   1 +
tests/Makefile.include     |   3 +
tests/test-sockets-proto.c | 906 +++++++++++++++++++++++++++++++++++++++++++++
ui/vnc.c                   | 194 +++-------
ui/vnc.h                   |   9 +-
util/qemu-sockets.c        |  36 +-
13 files changed, 1563 insertions(+), 290 deletions(-)
create mode 100644 include/io/net-listener.h
create mode 100644 io/net-listener.c
create mode 100644 tests/test-sockets-proto.c
Git apply log
Switched to a new branch '20170810160451.32723-1-berrange@redhat.com'
Applying: tests: add functional test validating ipv4/ipv6 address flag handling
Applying: io: introduce a network socket listener API
Applying: blockdev: convert internal NBD server to QIONetListener
Applying: blockdev: convert qemu-nbd server to QIONetListener
Applying: migration: convert socket server to QIONetListener
Applying: chardev: convert the socket server to QIONetListener
Applying: ui: convert VNC server to QIONetListener
Applying: sockets: fix parsing of ipv4/ipv6 opts in parse_socket_addr
To https://github.com/patchew-project/qemu
 + 4c1f7221be...0c81f13def patchew/20170810160451.32723-1-berrange@redhat.com -> patchew/20170810160451.32723-1-berrange@redhat.com (forced update)
Test passed: FreeBSD

loading

Test failed: docker

loading

Test passed: s390x

loading

Test failed: checkpatch

loading

[Qemu-devel] [PATCH 0/8] Enable full IPv4/IPv6 dual stack support
Posted by Daniel P. Berrange, 1 week ago
Currently all the network listeners in QEMU, except the VNC server,
are restricted to listening on a single socket. This makes it
impossible to fully support IPv4/IPv6 dual stack. We're restricted
to using IPV6_V6ONLY=0 to listen on both protocols from a single
socket, but this doesn't work at all on OpenBSD, and even where
supported it is quite crude (only really works for localhost and
wildcard addresses).

This patch series introduces a new object QIONetListener, which
encapsulates multiple QIOChannelSocket listeners. This makes it
trivial to support multiple listening sockets in any part of
QEMU.

Daniel P. Berrange (8):
  tests: add functional test validating ipv4/ipv6 address flag handling
  io: introduce a network socket listener API
  blockdev: convert internal NBD server to QIONetListener
  blockdev: convert qemu-nbd server to QIONetListener
  migration: convert socket server to QIONetListener
  chardev: convert the socket server to QIONetListener
  ui: convert VNC server to QIONetListener
  sockets: fix parsing of ipv4/ipv6 opts in parse_socket_addr

 blockdev-nbd.c             |  50 +--
 chardev/char-socket.c      |  70 ++--
 include/io/net-listener.h  | 174 +++++++++
 io/Makefile.objs           |   1 +
 io/net-listener.c          | 315 ++++++++++++++++
 migration/socket.c         |  44 +--
 qemu-nbd.c                 |  50 +--
 tests/.gitignore           |   1 +
 tests/Makefile.include     |   3 +
 tests/test-sockets-proto.c | 906 +++++++++++++++++++++++++++++++++++++++++++++
 ui/vnc.c                   | 194 +++-------
 ui/vnc.h                   |   9 +-
 util/qemu-sockets.c        |  36 +-
 13 files changed, 1563 insertions(+), 290 deletions(-)
 create mode 100644 include/io/net-listener.h
 create mode 100644 io/net-listener.c
 create mode 100644 tests/test-sockets-proto.c

-- 
2.13.3


Re: [Qemu-devel] [PATCH 0/8] Enable full IPv4/IPv6 dual stack support
Posted by no-reply@patchew.org, 1 week ago
Hi,

This series seems to have some coding style problems. See output below for
more information:

Message-id: 20170810160451.32723-1-berrange@redhat.com
Subject: [Qemu-devel] [PATCH 0/8] Enable full IPv4/IPv6 dual stack support
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
c80d4b3d99 sockets: fix parsing of ipv4/ipv6 opts in parse_socket_addr
85193a29c1 ui: convert VNC server to QIONetListener
59dd1813c8 chardev: convert the socket server to QIONetListener
2304ec200f migration: convert socket server to QIONetListener
4f4c339d2c blockdev: convert qemu-nbd server to QIONetListener
9837cc0ccd blockdev: convert internal NBD server to QIONetListener
f3aa1d82c5 io: introduce a network socket listener API
81584cdc6f tests: add functional test validating ipv4/ipv6 address flag handling

=== OUTPUT BEGIN ===
Checking PATCH 1/8: tests: add functional test validating ipv4/ipv6 address flag handling...
Checking PATCH 2/8: io: introduce a network socket listener API...
Checking PATCH 3/8: blockdev: convert internal NBD server to QIONetListener...
Checking PATCH 4/8: blockdev: convert qemu-nbd server to QIONetListener...
WARNING: line over 80 characters
#41: FILE: qemu-nbd.c:348:
+static void nbd_accept(QIONetListener *listener, QIOChannelSocket *cioc, gpointer opaque)

total: 0 errors, 1 warnings, 99 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 5/8: migration: convert socket server to QIONetListener...
ERROR: line over 90 characters
#89: FILE: migration/socket.c:163:
+    qio_net_listener_set_client_func(listener, socket_accept_incoming_migration, NULL, NULL);

total: 1 errors, 0 warnings, 82 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 6/8: chardev: convert the socket server to QIONetListener...
WARNING: line over 80 characters
#57: FILE: chardev/char-socket.c:408:
+        qio_net_listener_set_client_func(s->listener, tcp_chr_accept, chr, NULL);

WARNING: line over 80 characters
#165: FILE: chardev/char-socket.c:946:
+                qio_net_listener_set_client_func(s->listener, tcp_chr_accept, chr, NULL);

total: 0 errors, 2 warnings, 168 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 7/8: ui: convert VNC server to QIONetListener...
WARNING: line over 80 characters
#51: FILE: ui/vnc.c:390:
+        addr = qio_channel_socket_get_local_address(vd->listener->sioc[0], errp);

total: 0 errors, 1 warnings, 292 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 8/8: sockets: fix parsing of ipv4/ipv6 opts in parse_socket_addr...
=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
Re: [Qemu-devel] [PATCH 0/8] Enable full IPv4/IPv6 dual stack support
Posted by no-reply@patchew.org, 1 week ago
Hi,

This series failed automatic build test. Please find the testing commands and
their output below. If you have docker installed, you can probably reproduce it
locally.

Message-id: 20170810160451.32723-1-berrange@redhat.com
Subject: [Qemu-devel] [PATCH 0/8] Enable full IPv4/IPv6 dual stack support
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info
export SHOW_ENV=1
export J=8
time make docker-test-quick@centos6
time make docker-test-build@min-glib
time make docker-test-mingw@fedora
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]               patchew/20170810160451.32723-1-berrange@redhat.com -> patchew/20170810160451.32723-1-berrange@redhat.com
Switched to a new branch 'test'
c80d4b3d99 sockets: fix parsing of ipv4/ipv6 opts in parse_socket_addr
85193a29c1 ui: convert VNC server to QIONetListener
59dd1813c8 chardev: convert the socket server to QIONetListener
2304ec200f migration: convert socket server to QIONetListener
4f4c339d2c blockdev: convert qemu-nbd server to QIONetListener
9837cc0ccd blockdev: convert internal NBD server to QIONetListener
f3aa1d82c5 io: introduce a network socket listener API
81584cdc6f tests: add functional test validating ipv4/ipv6 address flag handling

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-7o1dgdzo/src/dtc'...
Submodule path 'dtc': checked out '558cd81bdd432769b59bff01240c44f82cfb1a9d'
  BUILD   centos6
make[1]: Entering directory '/var/tmp/patchew-tester-tmp-7o1dgdzo/src'
  ARCHIVE qemu.tgz
  ARCHIVE dtc.tgz
  COPY    RUNNER
    RUN test-quick in qemu:centos6 
Packages installed:
SDL-devel-1.2.14-7.el6_7.1.x86_64
bison-2.4.1-5.el6.x86_64
ccache-3.1.6-2.el6.x86_64
epel-release-6-8.noarch
flex-2.5.35-9.el6.x86_64
gcc-4.4.7-18.el6.x86_64
git-1.7.1-8.el6.x86_64
glib2-devel-2.28.8-9.el6.x86_64
libfdt-devel-1.4.0-1.el6.x86_64
make-3.81-23.el6.x86_64
package g++ is not installed
pixman-devel-0.32.8-1.el6.x86_64
tar-1.23-15.el6_8.x86_64
zlib-devel-1.2.3-29.el6.x86_64

Environment variables:
PACKAGES=libfdt-devel ccache     tar git make gcc g++ flex bison     zlib-devel glib2-devel SDL-devel pixman-devel     epel-release
HOSTNAME=638a1a17597e
TERM=xterm
MAKEFLAGS= -j8
HISTSIZE=1000
J=8
USER=root
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
CCACHE_DIR=/var/tmp/ccache
EXTRA_CONFIGURE_OPTS=
V=
SHOW_ENV=1
MAIL=/var/spool/mail/root
PATH=/usr/lib/ccache:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
LANG=en_US.UTF-8
TARGET_LIST=
HISTCONTROL=ignoredups
SHLVL=1
HOME=/root
TEST_DIR=/tmp/qemu-test
LOGNAME=root
LESSOPEN=||/usr/bin/lesspipe.sh %s
FEATURES= dtc
DEBUG=
G_BROKEN_FILENAMES=1
CCACHE_HASHDIR=
_=/usr/bin/env

Configure options:
--enable-werror --target-list=x86_64-softmmu,aarch64-softmmu --prefix=/var/tmp/qemu-build/install
No C++ compiler available; disabling C++ specific optional code
Install prefix    /var/tmp/qemu-build/install
BIOS directory    /var/tmp/qemu-build/install/share/qemu
binary directory  /var/tmp/qemu-build/install/bin
library directory /var/tmp/qemu-build/install/lib
module directory  /var/tmp/qemu-build/install/lib/qemu
libexec directory /var/tmp/qemu-build/install/libexec
include directory /var/tmp/qemu-build/install/include
config directory  /var/tmp/qemu-build/install/etc
local state directory   /var/tmp/qemu-build/install/var
Manual directory  /var/tmp/qemu-build/install/share/man
ELF interp prefix /usr/gnemul/qemu-%M
Source path       /tmp/qemu-test/src
C compiler        cc
Host C compiler   cc
C++ compiler      
Objective-C compiler cc
ARFLAGS           rv
CFLAGS            -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g 
QEMU_CFLAGS       -I/usr/include/pixman-1   -I$(SRC_PATH)/dtc/libfdt -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -fPIE -DPIE -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv  -Wendif-labels -Wno-missing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-all
LDFLAGS           -Wl,--warn-common -Wl,-z,relro -Wl,-z,now -pie -m64 -g 
make              make
install           install
python            python -B
smbd              /usr/sbin/smbd
module support    no
host CPU          x86_64
host big endian   no
target list       x86_64-softmmu aarch64-softmmu
gprof enabled     no
sparse enabled    no
strip binaries    yes
profiler          no
static build      no
pixman            system
SDL support       yes (1.2.14)
GTK support       no 
GTK GL support    no
VTE support       no 
TLS priority      NORMAL
GNUTLS support    no
GNUTLS rnd        no
libgcrypt         no
libgcrypt kdf     no
nettle            no 
nettle kdf        no
libtasn1          no
curses support    no
virgl support     no
curl support      no
mingw32 support   no
Audio drivers     oss
Block whitelist (rw) 
Block whitelist (ro) 
VirtFS support    no
VNC support       yes
VNC SASL support  no
VNC JPEG support  no
VNC PNG support   no
xen support       no
brlapi support    no
bluez  support    no
Documentation     no
PIE               yes
vde support       no
netmap support    no
Linux AIO support no
ATTR/XATTR support yes
Install blobs     yes
KVM support       yes
HAX support       no
TCG support       yes
TCG debug enabled no
TCG interpreter   no
RDMA support      no
fdt support       yes
preadv support    yes
fdatasync         yes
madvise           yes
posix_madvise     yes
libcap-ng support no
vhost-net support yes
vhost-scsi support yes
vhost-vsock support yes
vhost-user support yes
Trace backends    log
spice support     no 
rbd support       no
xfsctl support    no
smartcard support no
libusb            no
usb net redir     no
OpenGL support    no
OpenGL dmabufs    no
libiscsi support  no
libnfs support    no
build guest agent yes
QGA VSS support   no
QGA w32 disk info no
QGA MSI support   no
seccomp support   no
coroutine backend ucontext
coroutine pool    yes
debug stack usage no
crypto afalg      no
GlusterFS support no
gcov              gcov
gcov enabled      no
TPM support       yes
libssh2 support   no
TPM passthrough   yes
QOM debugging     yes
Live block migration yes
lzo support       no
snappy support    no
bzip2 support     no
NUMA host support no
tcmalloc support  no
jemalloc support  no
avx2 optimization no
replication support yes
VxHS block device no
mkdir -p dtc/libfdt
mkdir -p dtc/tests
  GEN     x86_64-softmmu/config-devices.mak.tmp
  GEN     aarch64-softmmu/config-devices.mak.tmp
  GEN     config-host.h
  GEN     qemu-options.def
  GEN     qmp-commands.h
  GEN     qapi-visit.h
  GEN     qapi-types.h
  GEN     qapi-event.h
  GEN     x86_64-softmmu/config-devices.mak
  GEN     aarch64-softmmu/config-devices.mak
  GEN     qmp-marshal.c
  GEN     qapi-types.c
  GEN     qapi-visit.c
  GEN     qapi-event.c
  GEN     qmp-introspect.h
  GEN     qmp-introspect.c
  GEN     trace/generated-tcg-tracers.h
  GEN     trace/generated-helpers-wrappers.h
  GEN     trace/generated-helpers.h
  GEN     trace/generated-helpers.c
  GEN     module_block.h
  GEN     tests/test-qapi-visit.h
  GEN     tests/test-qapi-types.h
  GEN     tests/test-qmp-commands.h
  GEN     tests/test-qapi-event.h
  GEN     tests/test-qmp-introspect.h
  GEN     trace-root.h
  GEN     util/trace.h
  GEN     crypto/trace.h
  GEN     io/trace.h
  GEN     migration/trace.h
  GEN     block/trace.h
  GEN     chardev/trace.h
  GEN     hw/block/trace.h
  GEN     hw/block/dataplane/trace.h
  GEN     hw/char/trace.h
  GEN     hw/intc/trace.h
  GEN     hw/net/trace.h
  GEN     hw/virtio/trace.h
  GEN     hw/audio/trace.h
  GEN     hw/misc/trace.h
  GEN     hw/usb/trace.h
  GEN     hw/scsi/trace.h
  GEN     hw/nvram/trace.h
  GEN     hw/display/trace.h
  GEN     hw/input/trace.h
  GEN     hw/timer/trace.h
  GEN     hw/dma/trace.h
  GEN     hw/sparc/trace.h
  GEN     hw/sd/trace.h
  GEN     hw/isa/trace.h
  GEN     hw/mem/trace.h
  GEN     hw/i386/trace.h
  GEN     hw/i386/xen/trace.h
  GEN     hw/9pfs/trace.h
  GEN     hw/ppc/trace.h
  GEN     hw/pci/trace.h
  GEN     hw/s390x/trace.h
  GEN     hw/vfio/trace.h
  GEN     hw/acpi/trace.h
  GEN     hw/arm/trace.h
  GEN     hw/alpha/trace.h
  GEN     hw/xen/trace.h
  GEN     ui/trace.h
  GEN     audio/trace.h
  GEN     net/trace.h
  GEN     target/arm/trace.h
  GEN     target/i386/trace.h
  GEN     target/mips/trace.h
  GEN     target/sparc/trace.h
  GEN     target/s390x/trace.h
  GEN     target/ppc/trace.h
  GEN     qom/trace.h
  GEN     linux-user/trace.h
  GEN     qapi/trace.h
  GEN     accel/tcg/trace.h
  GEN     accel/kvm/trace.h
  GEN     nbd/trace.h
  GEN     trace-root.c
  GEN     util/trace.c
  GEN     crypto/trace.c
  GEN     io/trace.c
  GEN     migration/trace.c
  GEN     block/trace.c
  GEN     chardev/trace.c
  GEN     hw/block/trace.c
  GEN     hw/block/dataplane/trace.c
  GEN     hw/char/trace.c
  GEN     hw/intc/trace.c
  GEN     hw/net/trace.c
  GEN     hw/virtio/trace.c
  GEN     hw/audio/trace.c
  GEN     hw/misc/trace.c
  GEN     hw/usb/trace.c
  GEN     hw/scsi/trace.c
  GEN     hw/nvram/trace.c
  GEN     hw/display/trace.c
  GEN     hw/input/trace.c
  GEN     hw/timer/trace.c
  GEN     hw/dma/trace.c
  GEN     hw/sparc/trace.c
  GEN     hw/sd/trace.c
  GEN     hw/isa/trace.c
  GEN     hw/mem/trace.c
  GEN     hw/i386/trace.c
  GEN     hw/i386/xen/trace.c
  GEN     hw/9pfs/trace.c
  GEN     hw/ppc/trace.c
  GEN     hw/pci/trace.c
  GEN     hw/s390x/trace.c
  GEN     hw/vfio/trace.c
  GEN     hw/acpi/trace.c
  GEN     hw/arm/trace.c
  GEN     hw/alpha/trace.c
  GEN     hw/xen/trace.c
  GEN     ui/trace.c
  GEN     audio/trace.c
  GEN     net/trace.c
  GEN     target/arm/trace.c
  GEN     target/i386/trace.c
  GEN     target/mips/trace.c
  GEN     target/sparc/trace.c
  GEN     target/s390x/trace.c
  GEN     target/ppc/trace.c
  GEN     qom/trace.c
  GEN     linux-user/trace.c
  GEN     qapi/trace.c
  GEN     accel/tcg/trace.c
  GEN     accel/kvm/trace.c
  GEN     nbd/trace.c
  GEN     config-all-devices.mak
	 DEP /tmp/qemu-test/src/dtc/tests/dumptrees.c
	 DEP /tmp/qemu-test/src/dtc/tests/trees.S
	 DEP /tmp/qemu-test/src/dtc/tests/testutils.c
	 DEP /tmp/qemu-test/src/dtc/tests/value-labels.c
	 DEP /tmp/qemu-test/src/dtc/tests/asm_tree_dump.c
	 DEP /tmp/qemu-test/src/dtc/tests/truncated_property.c
	 DEP /tmp/qemu-test/src/dtc/tests/check_path.c
	 DEP /tmp/qemu-test/src/dtc/tests/overlay_bad_fixup.c
	 DEP /tmp/qemu-test/src/dtc/tests/overlay.c
	 DEP /tmp/qemu-test/src/dtc/tests/subnode_iterate.c
	 DEP /tmp/qemu-test/src/dtc/tests/property_iterate.c
	 DEP /tmp/qemu-test/src/dtc/tests/integer-expressions.c
	 DEP /tmp/qemu-test/src/dtc/tests/utilfdt_test.c
	 DEP /tmp/qemu-test/src/dtc/tests/path_offset_aliases.c
	 DEP /tmp/qemu-test/src/dtc/tests/add_subnode_with_nops.c
	 DEP /tmp/qemu-test/src/dtc/tests/dtbs_equal_unordered.c
	 DEP /tmp/qemu-test/src/dtc/tests/dtb_reverse.c
	 DEP /tmp/qemu-test/src/dtc/tests/dtbs_equal_ordered.c
	 DEP /tmp/qemu-test/src/dtc/tests/extra-terminating-null.c
	 DEP /tmp/qemu-test/src/dtc/tests/incbin.c
	 DEP /tmp/qemu-test/src/dtc/tests/boot-cpuid.c
	 DEP /tmp/qemu-test/src/dtc/tests/phandle_format.c
	 DEP /tmp/qemu-test/src/dtc/tests/path-references.c
	 DEP /tmp/qemu-test/src/dtc/tests/references.c
	 DEP /tmp/qemu-test/src/dtc/tests/string_escapes.c
	 DEP /tmp/qemu-test/src/dtc/tests/propname_escapes.c
	 DEP /tmp/qemu-test/src/dtc/tests/appendprop2.c
	 DEP /tmp/qemu-test/src/dtc/tests/appendprop1.c
	 DEP /tmp/qemu-test/src/dtc/tests/del_property.c
	 DEP /tmp/qemu-test/src/dtc/tests/del_node.c
	 DEP /tmp/qemu-test/src/dtc/tests/setprop.c
	 DEP /tmp/qemu-test/src/dtc/tests/set_name.c
	 DEP /tmp/qemu-test/src/dtc/tests/rw_tree1.c
	 DEP /tmp/qemu-test/src/dtc/tests/open_pack.c
	 DEP /tmp/qemu-test/src/dtc/tests/nopulate.c
	 DEP /tmp/qemu-test/src/dtc/tests/mangle-layout.c
	 DEP /tmp/qemu-test/src/dtc/tests/move_and_save.c
	 DEP /tmp/qemu-test/src/dtc/tests/sw_tree1.c
	 DEP /tmp/qemu-test/src/dtc/tests/nop_node.c
	 DEP /tmp/qemu-test/src/dtc/tests/nop_property.c
	 DEP /tmp/qemu-test/src/dtc/tests/setprop_inplace.c
	 DEP /tmp/qemu-test/src/dtc/tests/stringlist.c
	 DEP /tmp/qemu-test/src/dtc/tests/addr_size_cells.c
	 DEP /tmp/qemu-test/src/dtc/tests/notfound.c
	 DEP /tmp/qemu-test/src/dtc/tests/sized_cells.c
	 DEP /tmp/qemu-test/src/dtc/tests/char_literal.c
	 DEP /tmp/qemu-test/src/dtc/tests/get_alias.c
	 DEP /tmp/qemu-test/src/dtc/tests/node_offset_by_compatible.c
	 DEP /tmp/qemu-test/src/dtc/tests/node_check_compatible.c
	 DEP /tmp/qemu-test/src/dtc/tests/node_offset_by_phandle.c
	 DEP /tmp/qemu-test/src/dtc/tests/node_offset_by_prop_value.c
	 DEP /tmp/qemu-test/src/dtc/tests/parent_offset.c
	 DEP /tmp/qemu-test/src/dtc/tests/supernode_atdepth_offset.c
	 DEP /tmp/qemu-test/src/dtc/tests/get_path.c
	 DEP /tmp/qemu-test/src/dtc/tests/get_phandle.c
	 DEP /tmp/qemu-test/src/dtc/tests/getprop.c
	 DEP /tmp/qemu-test/src/dtc/tests/get_name.c
	 DEP /tmp/qemu-test/src/dtc/tests/path_offset.c
	 DEP /tmp/qemu-test/src/dtc/tests/find_property.c
	 DEP /tmp/qemu-test/src/dtc/tests/subnode_offset.c
	 DEP /tmp/qemu-test/src/dtc/tests/root_node.c
	 DEP /tmp/qemu-test/src/dtc/tests/get_mem_rsv.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_overlay.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_addresses.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_empty_tree.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_strerror.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_rw.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_sw.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_wip.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt_ro.c
	 DEP /tmp/qemu-test/src/dtc/libfdt/fdt.c
	 DEP /tmp/qemu-test/src/dtc/util.c
	 DEP /tmp/qemu-test/src/dtc/fdtget.c
	 DEP /tmp/qemu-test/src/dtc/fdtput.c
	 DEP /tmp/qemu-test/src/dtc/fdtdump.c
	 LEX convert-dtsv0-lexer.lex.c
	 DEP /tmp/qemu-test/src/dtc/srcpos.c
	 BISON dtc-parser.tab.c
	 LEX dtc-lexer.lex.c
	 DEP /tmp/qemu-test/src/dtc/fstree.c
	 DEP /tmp/qemu-test/src/dtc/treesource.c
	 DEP /tmp/qemu-test/src/dtc/livetree.c
	 DEP /tmp/qemu-test/src/dtc/flattree.c
	 DEP /tmp/qemu-test/src/dtc/dtc.c
	 DEP /tmp/qemu-test/src/dtc/data.c
	 DEP /tmp/qemu-test/src/dtc/checks.c
	 DEP convert-dtsv0-lexer.lex.c
	 DEP dtc-parser.tab.c
	 DEP dtc-lexer.lex.c
	CHK version_gen.h
	UPD version_gen.h
	 DEP /tmp/qemu-test/src/dtc/util.c
	 CC libfdt/fdt.o
	 CC libfdt/fdt_ro.o
	 CC libfdt/fdt_wip.o
	 CC libfdt/fdt_rw.o
	 CC libfdt/fdt_sw.o
	 CC libfdt/fdt_strerror.o
	 CC libfdt/fdt_empty_tree.o
	 CC libfdt/fdt_addresses.o
	 CC libfdt/fdt_overlay.o
	 AR libfdt/libfdt.a
ar: creating libfdt/libfdt.a
a - libfdt/fdt.o
a - libfdt/fdt_ro.o
a - libfdt/fdt_wip.o
a - libfdt/fdt_sw.o
a - libfdt/fdt_rw.o
a - libfdt/fdt_strerror.o
a - libfdt/fdt_empty_tree.o
a - libfdt/fdt_addresses.o
a - libfdt/fdt_overlay.o
  CC      tests/qemu-iotests/socket_scm_helper.o
  GEN     qga/qapi-generated/qga-qapi-types.c
  GEN     qga/qapi-generated/qga-qapi-types.h
  GEN     qga/qapi-generated/qga-qapi-visit.h
  GEN     qga/qapi-generated/qga-qmp-commands.h
  GEN     qga/qapi-generated/qga-qmp-marshal.c
  GEN     qga/qapi-generated/qga-qapi-visit.c
  CC      qmp-introspect.o
  CC      qapi-types.o
  CC      qapi-visit.o
  CC      qapi-event.o
  CC      qapi/qapi-visit-core.o
  CC      qapi/qapi-dealloc-visitor.o
  CC      qapi/qobject-input-visitor.o
  CC      qapi/qobject-output-visitor.o
  CC      qapi/qmp-registry.o
  CC      qapi/qmp-dispatch.o
  CC      qapi/string-input-visitor.o
  CC      qapi/string-output-visitor.o
  CC      qapi/opts-visitor.o
  CC      qapi/qapi-clone-visitor.o
  CC      qapi/qmp-event.o
  CC      qapi/qapi-util.o
  CC      qobject/qnull.o
  CC      qobject/qnum.o
  CC      qobject/qdict.o
  CC      qobject/qstring.o
  CC      qobject/qlist.o
  CC      qobject/qbool.o
  CC      qobject/qjson.o
  CC      qobject/qobject.o
  CC      qobject/json-lexer.o
  CC      qobject/json-parser.o
  CC      qobject/json-streamer.o
  CC      trace/control.o
  CC      trace/qmp.o
  CC      util/cutils.o
  CC      util/osdep.o
  CC      util/unicode.o
  CC      util/qemu-timer-common.o
  CC      util/bufferiszero.o
  CC      util/lockcnt.o
  CC      util/aiocb.o
  CC      util/thread-pool.o
  CC      util/async.o
  CC      util/qemu-timer.o
  CC      util/main-loop.o
  CC      util/iohandler.o
  CC      util/aio-posix.o
  CC      util/compatfd.o
  CC      util/event_notifier-posix.o
  CC      util/mmap-alloc.o
  CC      util/oslib-posix.o
  CC      util/qemu-openpty.o
  CC      util/qemu-thread-posix.o
  CC      util/memfd.o
  CC      util/envlist.o
  CC      util/path.o
  CC      util/module.o
  CC      util/host-utils.o
  CC      util/bitmap.o
  CC      util/bitops.o
  CC      util/hbitmap.o
  CC      util/fifo8.o
  CC      util/acl.o
  CC      util/cacheinfo.o
  CC      util/error.o
  CC      util/qemu-error.o
  CC      util/id.o
  CC      util/iov.o
  CC      util/qemu-config.o
  CC      util/qemu-sockets.o
  CC      util/uri.o
  CC      util/notify.o
  CC      util/qemu-option.o
  CC      util/qemu-progress.o
  CC      util/keyval.o
  CC      util/hexdump.o
  CC      util/crc32c.o
  CC      util/uuid.o
  CC      util/throttle.o
  CC      util/getauxval.o
  CC      util/readline.o
  CC      util/rcu.o
  CC      util/qemu-coroutine.o
  CC      util/qemu-coroutine-lock.o
  CC      util/qemu-coroutine-io.o
  CC      util/qemu-coroutine-sleep.o
  CC      util/coroutine-ucontext.o
  CC      util/buffer.o
  CC      util/timed-average.o
  CC      util/base64.o
  CC      util/log.o
  CC      util/qht.o
  CC      util/qdist.o
  CC      util/range.o
  CC      util/stats64.o
  CC      trace-root.o
  CC      util/systemd.o
  CC      util/trace.o
  CC      crypto/trace.o
  CC      io/trace.o
  CC      migration/trace.o
  CC      block/trace.o
  CC      chardev/trace.o
  CC      hw/block/trace.o
  CC      hw/char/trace.o
  CC      hw/block/dataplane/trace.o
  CC      hw/net/trace.o
  CC      hw/intc/trace.o
  CC      hw/virtio/trace.o
  CC      hw/audio/trace.o
  CC      hw/misc/trace.o
  CC      hw/usb/trace.o
  CC      hw/scsi/trace.o
  CC      hw/nvram/trace.o
  CC      hw/display/trace.o
  CC      hw/input/trace.o
  CC      hw/timer/trace.o
  CC      hw/dma/trace.o
  CC      hw/sparc/trace.o
  CC      hw/sd/trace.o
  CC      hw/isa/trace.o
  CC      hw/mem/trace.o
  CC      hw/i386/trace.o
  CC      hw/i386/xen/trace.o
  CC      hw/9pfs/trace.o
  CC      hw/ppc/trace.o
  CC      hw/pci/trace.o
  CC      hw/s390x/trace.o
  CC      hw/vfio/trace.o
  CC      hw/acpi/trace.o
  CC      hw/arm/trace.o
  CC      hw/alpha/trace.o
  CC      hw/xen/trace.o
  CC      ui/trace.o
  CC      audio/trace.o
  CC      net/trace.o
  CC      target/arm/trace.o
  CC      target/i386/trace.o
  CC      target/mips/trace.o
  CC      target/sparc/trace.o
  CC      target/s390x/trace.o
  CC      target/ppc/trace.o
  CC      qom/trace.o
  CC      linux-user/trace.o
  CC      qapi/trace.o
  CC      accel/tcg/trace.o
  CC      accel/kvm/trace.o
  CC      nbd/trace.o
  CC      crypto/pbkdf-stub.o
  CC      stubs/arch-query-cpu-def.o
  CC      stubs/arch-query-cpu-model-expansion.o
  CC      stubs/arch-query-cpu-model-comparison.o
  CC      stubs/arch-query-cpu-model-baseline.o
  CC      stubs/bdrv-next-monitor-owned.o
  CC      stubs/blk-commit-all.o
  CC      stubs/blockdev-close-all-bdrv-states.o
  CC      stubs/cpu-get-clock.o
  CC      stubs/clock-warp.o
  CC      stubs/cpu-get-icount.o
  CC      stubs/dump.o
  CC      stubs/fdset.o
  CC      stubs/gdbstub.o
  CC      stubs/error-printf.o
  CC      stubs/get-vm-name.o
  CC      stubs/iothread.o
  CC      stubs/iothread-lock.o
  CC      stubs/is-daemonized.o
  CC      stubs/machine-init-done.o
  CC      stubs/migr-blocker.o
  CC      stubs/monitor.o
  CC      stubs/replay.o
  CC      stubs/notify-event.o
  CC      stubs/qtest.o
  CC      stubs/runstate-check.o
  CC      stubs/set-fd-handler.o
  CC      stubs/slirp.o
  CC      stubs/sysbus.o
  CC      stubs/trace-control.o
  CC      stubs/uuid.o
  CC      stubs/vmstate.o
  CC      stubs/vm-stop.o
  CC      stubs/qmp_pc_dimm_device_list.o
  CC      stubs/target-monitor-defs.o
  CC      stubs/target-get-monitor-def.o
  CC      stubs/pc_madt_cpu_entry.o
  CC      stubs/vmgenid.o
  CC      stubs/xen-common.o
  CC      stubs/xen-hvm.o
  CC      contrib/ivshmem-client/ivshmem-client.o
  CC      contrib/ivshmem-client/main.o
  CC      contrib/ivshmem-server/main.o
  CC      contrib/ivshmem-server/ivshmem-server.o
  CC      block.o
  CC      blockjob.o
  CC      qemu-nbd.o
  CC      qemu-io-cmds.o
  CC      replication.o
  CC      block/raw-format.o
  CC      block/qcow.o
  CC      block/vdi.o
  CC      block/vmdk.o
  CC      block/cloop.o
  CC      block/bochs.o
  CC      block/vpc.o
  CC      block/vvfat.o
  CC      block/dmg.o
  CC      block/qcow2.o
  CC      block/qcow2-refcount.o
  CC      block/qcow2-cluster.o
  CC      block/qcow2-snapshot.o
  CC      block/qcow2-cache.o
  CC      block/qcow2-bitmap.o
  CC      block/qed.o
  CC      block/qed-l2-cache.o
  CC      block/qed-table.o
  CC      block/qed-cluster.o
  CC      block/qed-check.o
  CC      block/vhdx.o
  CC      block/vhdx-endian.o
  CC      block/vhdx-log.o
  CC      block/quorum.o
  CC      block/parallels.o
  CC      block/blkdebug.o
  CC      block/blkverify.o
  CC      block/blkreplay.o
  CC      block/block-backend.o
  CC      block/snapshot.o
  CC      block/qapi.o
  CC      block/file-posix.o
  CC      block/mirror.o
  CC      block/null.o
  CC      block/commit.o
  CC      block/io.o
  CC      block/throttle-groups.o
  CC      block/nbd.o
  CC      block/nbd-client.o
  CC      block/sheepdog.o
  CC      block/accounting.o
  CC      block/dirty-bitmap.o
  CC      block/write-threshold.o
  CC      block/backup.o
  CC      block/replication.o
  CC      block/crypto.o
  CC      nbd/server.o
  CC      nbd/client.o
  CC      nbd/common.o
  CC      crypto/init.o
  CC      crypto/hash.o
  CC      crypto/hash-glib.o
  CC      crypto/hmac.o
  CC      crypto/hmac-glib.o
  CC      crypto/aes.o
  CC      crypto/desrfb.o
  CC      crypto/cipher.o
  CC      crypto/tlscreds.o
  CC      crypto/tlscredsanon.o
  CC      crypto/tlscredsx509.o
  CC      crypto/tlssession.o
  CC      crypto/secret.o
  CC      crypto/random-platform.o
  CC      crypto/pbkdf.o
  CC      crypto/ivgen.o
  CC      crypto/ivgen-essiv.o
  CC      crypto/ivgen-plain.o
  CC      crypto/ivgen-plain64.o
  CC      crypto/afsplit.o
  CC      crypto/xts.o
  CC      crypto/block.o
  CC      crypto/block-qcow.o
  CC      crypto/block-luks.o
  CC      io/channel.o
  CC      io/channel-command.o
  CC      io/channel-buffer.o
  CC      io/channel-file.o
  CC      io/channel-socket.o
  CC      io/channel-watch.o
  CC      io/channel-tls.o
  CC      io/channel-websock.o
  CC      io/channel-util.o
  CC      io/dns-resolver.o
  CC      qom/object.o
  CC      io/net-listener.o
  CC      io/task.o
  CC      qom/qom-qobject.o
  CC      qom/object_interfaces.o
  CC      qom/container.o
  GEN     qemu-img-cmds.h
  CC      qemu-io.o
  CC      qemu-bridge-helper.o
  CC      blockdev.o
  CC      blockdev-nbd.o
  CC      bootdevice.o
  CC      iothread.o
  CC      device-hotplug.o
  CC      qdev-monitor.o
  CC      os-posix.o
  CC      bt-host.o
  CC      bt-vhci.o
  CC      dma-helpers.o
  CC      vl.o
  CC      tpm.o
  CC      device_tree.o
  CC      qmp-marshal.o
  CC      qmp.o
  CC      cpus-common.o
  CC      hmp.o
  CC      audio/audio.o
  CC      audio/noaudio.o
  CC      audio/wavaudio.o
  CC      audio/mixeng.o
  CC      audio/sdlaudio.o
  CC      audio/ossaudio.o
  CC      audio/wavcapture.o
  CC      backends/rng.o
  CC      backends/rng-egd.o
  CC      backends/rng-random.o
  CC      backends/tpm.o
  CC      backends/hostmem.o
  CC      backends/hostmem-ram.o
  CC      backends/hostmem-file.o
  CC      backends/cryptodev.o
  CC      backends/cryptodev-builtin.o
  CC      chardev/msmouse.o
  CC      block/stream.o
  CC      chardev/wctablet.o
  CC      chardev/testdev.o
  CC      disas/arm.o
  CC      fsdev/qemu-fsdev-dummy.o
  CC      disas/i386.o
  CC      fsdev/qemu-fsdev-opts.o
  CC      fsdev/qemu-fsdev-throttle.o
  CC      hw/acpi/core.o
  CC      hw/acpi/piix4.o
  CC      hw/acpi/pcihp.o
  CC      hw/acpi/ich9.o
  CC      hw/acpi/tco.o
  CC      hw/acpi/cpu_hotplug.o
  CC      hw/acpi/memory_hotplug.o
  CC      hw/acpi/cpu.o
  CC      hw/acpi/nvdimm.o
  CC      hw/acpi/vmgenid.o
  CC      hw/acpi/acpi_interface.o
  CC      hw/acpi/bios-linker-loader.o
  CC      hw/acpi/aml-build.o
  CC      hw/acpi/ipmi.o
  CC      hw/acpi/acpi-stub.o
  CC      hw/acpi/ipmi-stub.o
  CC      hw/audio/es1370.o
  CC      hw/audio/sb16.o
  CC      hw/audio/fmopl.o
  CC      hw/audio/ac97.o
  CC      hw/audio/adlib.o
  CC      hw/audio/gus.o
  CC      hw/audio/gusemu_hal.o
  CC      hw/audio/gusemu_mixer.o
  CC      hw/audio/cs4231a.o
  CC      hw/audio/intel-hda.o
  CC      hw/audio/hda-codec.o
  CC      hw/audio/pcspk.o
  CC      hw/audio/wm8750.o
  CC      hw/audio/pl041.o
  CC      hw/audio/lm4549.o
  CC      hw/audio/marvell_88w8618.o
  CC      hw/audio/soundhw.o
  CC      hw/block/block.o
  CC      hw/block/cdrom.o
  CC      hw/block/hd-geometry.o
  CC      hw/block/fdc.o
  CC      hw/block/m25p80.o
  CC      hw/block/nand.o
  CC      hw/block/pflash_cfi01.o
  CC      hw/block/pflash_cfi02.o
  CC      hw/block/ecc.o
  CC      hw/block/onenand.o
  CC      hw/block/nvme.o
  CC      hw/bt/core.o
  CC      hw/bt/l2cap.o
  CC      hw/bt/sdp.o
  CC      hw/bt/hci.o
  CC      hw/bt/hid.o
  CC      hw/bt/hci-csr.o
  CC      hw/char/ipoctal232.o
  CC      hw/char/parallel.o
  CC      hw/char/serial.o
  CC      hw/char/serial-isa.o
  CC      hw/char/pl011.o
  CC      hw/char/serial-pci.o
  CC      hw/char/virtio-console.o
  CC      hw/char/cadence_uart.o
  CC      hw/char/cmsdk-apb-uart.o
  CC      hw/char/debugcon.o
  CC      hw/char/imx_serial.o
  CC      hw/core/qdev.o
  CC      hw/core/bus.o
  CC      hw/core/qdev-properties.o
  CC      hw/core/fw-path-provider.o
  CC      hw/core/reset.o
  CC      hw/core/irq.o
  CC      hw/core/hotplug.o
  CC      hw/core/nmi.o
  CC      hw/core/ptimer.o
  CC      hw/core/sysbus.o
  CC      hw/core/machine.o
  CC      hw/core/loader.o
  CC      hw/core/qdev-properties-system.o
  CC      hw/core/register.o
  CC      hw/core/or-irq.o
  CC      hw/core/platform-bus.o
  CC      hw/cpu/core.o
  CC      hw/display/ads7846.o
  CC      hw/display/cirrus_vga.o
  CC      hw/display/pl110.o
  CC      hw/display/ssd0303.o
  CC      hw/display/ssd0323.o
  CC      hw/display/vga-pci.o
  CC      hw/display/vga-isa.o
  CC      hw/display/vmware_vga.o
  CC      hw/display/blizzard.o
  CC      hw/display/exynos4210_fimd.o
  CC      hw/display/framebuffer.o
  CC      hw/display/tc6393xb.o
  CC      hw/dma/pl080.o
  CC      hw/dma/pl330.o
  CC      hw/dma/i8257.o
  CC      hw/dma/xlnx-zynq-devcfg.o
  CC      hw/gpio/max7310.o
  CC      hw/gpio/zaurus.o
  CC      hw/gpio/pl061.o
  CC      hw/gpio/gpio_key.o
  CC      hw/i2c/core.o
  CC      hw/i2c/smbus.o
  CC      hw/i2c/smbus_eeprom.o
  CC      hw/i2c/versatile_i2c.o
  CC      hw/i2c/i2c-ddc.o
  CC      hw/i2c/smbus_ich9.o
  CC      hw/i2c/pm_smbus.o
  CC      hw/i2c/bitbang_i2c.o
  CC      hw/i2c/exynos4210_i2c.o
  CC      hw/i2c/imx_i2c.o
  CC      hw/i2c/aspeed_i2c.o
  CC      hw/ide/core.o
  CC      hw/ide/qdev.o
  CC      hw/ide/atapi.o
  CC      hw/ide/pci.o
  CC      hw/ide/isa.o
  CC      hw/ide/piix.o
  CC      hw/ide/microdrive.o
  CC      hw/ide/ahci.o
  CC      hw/ide/ich.o
  CC      hw/input/hid.o
  CC      hw/input/pckbd.o
  CC      hw/input/lm832x.o
  CC      hw/input/ps2.o
  CC      hw/input/pl050.o
  CC      hw/input/stellaris_input.o
  CC      hw/input/tsc2005.o
  CC      hw/input/vmmouse.o
  CC      hw/input/virtio-input.o
  CC      hw/input/virtio-input-hid.o
  CC      hw/input/virtio-input-host.o
  CC      hw/intc/i8259_common.o
  CC      hw/intc/i8259.o
  CC      hw/intc/pl190.o
  CC      hw/intc/imx_avic.o
  CC      hw/intc/realview_gic.o
  CC      hw/intc/ioapic_common.o
  CC      hw/intc/arm_gic_common.o
  CC      hw/intc/arm_gic.o
  CC      hw/intc/arm_gicv2m.o
  CC      hw/intc/arm_gicv3_common.o
  CC      hw/intc/arm_gicv3.o
  CC      hw/intc/arm_gicv3_dist.o
  CC      hw/intc/arm_gicv3_redist.o
  CC      hw/intc/arm_gicv3_its_common.o
  CC      hw/intc/intc.o
  CC      hw/ipack/ipack.o
  CC      hw/ipack/tpci200.o
  CC      hw/ipmi/ipmi.o
  CC      hw/ipmi/ipmi_bmc_extern.o
  CC      hw/ipmi/ipmi_bmc_sim.o
  CC      hw/ipmi/isa_ipmi_bt.o
  CC      hw/ipmi/isa_ipmi_kcs.o
  CC      hw/isa/isa-bus.o
  CC      hw/isa/apm.o
  CC      hw/mem/pc-dimm.o
  CC      hw/mem/nvdimm.o
  CC      hw/misc/applesmc.o
  CC      hw/misc/max111x.o
  CC      hw/misc/tmp105.o
  CC      hw/misc/tmp421.o
  CC      hw/misc/debugexit.o
  CC      hw/misc/sga.o
  CC      hw/misc/pc-testdev.o
  CC      hw/misc/pci-testdev.o
  CC      hw/misc/edu.o
  CC      hw/misc/unimp.o
  CC      hw/misc/arm_l2x0.o
  CC      hw/misc/arm_integrator_debug.o
  CC      hw/misc/a9scu.o
  CC      hw/misc/arm11scu.o
  CC      hw/net/ne2000.o
  CC      hw/net/pcnet-pci.o
  CC      hw/net/eepro100.o
  CC      hw/net/pcnet.o
  CC      hw/net/e1000.o
  CC      hw/net/net_tx_pkt.o
  CC      hw/net/e1000x_common.o
  CC      hw/net/net_rx_pkt.o
  CC      hw/net/e1000e.o
  CC      hw/net/e1000e_core.o
  CC      hw/net/rtl8139.o
  CC      hw/net/vmxnet3.o
  CC      hw/net/smc91c111.o
  CC      hw/net/lan9118.o
  CC      hw/net/ne2000-isa.o
  CC      hw/net/xgmac.o
  CC      hw/net/allwinner_emac.o
  CC      hw/net/imx_fec.o
  CC      hw/net/cadence_gem.o
  CC      hw/net/stellaris_enet.o
  CC      hw/net/ftgmac100.o
  CC      hw/net/rocker/rocker.o
  CC      hw/net/rocker/rocker_fp.o
  CC      hw/net/rocker/rocker_desc.o
  CC      hw/net/rocker/rocker_world.o
  CC      hw/net/rocker/rocker_of_dpa.o
  CC      hw/nvram/fw_cfg.o
  CC      hw/nvram/eeprom93xx.o
  CC      hw/nvram/chrp_nvram.o
  CC      hw/pci-bridge/pci_bridge_dev.o
  CC      hw/pci-bridge/pcie_root_port.o
  CC      hw/pci-bridge/gen_pcie_root_port.o
  CC      hw/pci-bridge/pci_expander_bridge.o
  CC      hw/pci-bridge/xio3130_upstream.o
  CC      hw/pci-bridge/xio3130_downstream.o
  CC      hw/pci-bridge/ioh3420.o
  CC      hw/pci-bridge/i82801b11.o
  CC      hw/pci-host/pam.o
  CC      hw/pci-host/versatile.o
  CC      hw/pci-host/piix.o
  CC      hw/pci-host/gpex.o
  CC      hw/pci-host/q35.o
  CC      hw/pci/pci.o
  CC      hw/pci/pci_bridge.o
  CC      hw/pci/msix.o
  CC      hw/pci/msi.o
  CC      hw/pci/shpc.o
  CC      hw/pci/slotid_cap.o
  CC      hw/pci/pci_host.o
  CC      hw/pci/pcie_host.o
  CC      hw/pci/pcie_aer.o
  CC      hw/pci/pcie.o
  CC      hw/pci/pcie_port.o
  CC      hw/pci/pci-stub.o
  CC      hw/pcmcia/pcmcia.o
  CC      hw/scsi/scsi-disk.o
  CC      hw/scsi/scsi-generic.o
  CC      hw/scsi/scsi-bus.o
  CC      hw/scsi/lsi53c895a.o
  CC      hw/scsi/mptsas.o
  CC      hw/scsi/mptconfig.o
  CC      hw/scsi/mptendian.o
  CC      hw/scsi/megasas.o
  CC      hw/scsi/vmw_pvscsi.o
  CC      hw/sd/pl181.o
  CC      hw/scsi/esp-pci.o
  CC      hw/scsi/esp.o
  CC      hw/sd/ssi-sd.o
  CC      hw/sd/sd.o
  CC      hw/sd/core.o
  CC      hw/sd/sdhci.o
  CC      hw/smbios/smbios.o
  CC      hw/smbios/smbios-stub.o
  CC      hw/smbios/smbios_type_38.o
  CC      hw/smbios/smbios_type_38-stub.o
  CC      hw/ssi/pl022.o
  CC      hw/ssi/ssi.o
  CC      hw/ssi/aspeed_smc.o
  CC      hw/ssi/stm32f2xx_spi.o
  CC      hw/ssi/xilinx_spips.o
  CC      hw/timer/arm_timer.o
  CC      hw/timer/arm_mptimer.o
  CC      hw/timer/armv7m_systick.o
  CC      hw/timer/a9gtimer.o
  CC      hw/timer/cadence_ttc.o
  CC      hw/timer/hpet.o
  CC      hw/timer/ds1338.o
  CC      hw/timer/i8254.o
  CC      hw/timer/i8254_common.o
  CC      hw/timer/pl031.o
  CC      hw/timer/twl92230.o
  CC      hw/timer/imx_gpt.o
  CC      hw/timer/imx_epit.o
  CC      hw/timer/stm32f2xx_timer.o
  CC      hw/timer/aspeed_timer.o
  CC      hw/timer/cmsdk-apb-timer.o
  CC      hw/tpm/tpm_tis.o
  CC      hw/tpm/tpm_passthrough.o
  CC      hw/usb/core.o
  CC      hw/tpm/tpm_util.o
  CC      hw/usb/combined-packet.o
  CC      hw/usb/bus.o
  CC      hw/usb/libhw.o
  CC      hw/usb/desc.o
  CC      hw/usb/desc-msos.o
  CC      hw/usb/hcd-ohci.o
  CC      hw/usb/hcd-ehci.o
  CC      hw/usb/hcd-uhci.o
  CC      hw/usb/hcd-ehci-pci.o
  CC      hw/usb/hcd-ehci-sysbus.o
  CC      hw/usb/hcd-xhci.o
  CC      hw/usb/hcd-xhci-nec.o
  CC      hw/usb/hcd-musb.o
  CC      hw/usb/dev-hub.o
  CC      hw/usb/dev-hid.o
  CC      hw/usb/dev-wacom.o
  CC      hw/usb/dev-storage.o
  CC      hw/usb/dev-uas.o
  CC      hw/usb/dev-audio.o
  CC      hw/usb/dev-serial.o
  CC      hw/usb/dev-network.o
  CC      hw/usb/dev-bluetooth.o
  CC      hw/usb/dev-smartcard-reader.o
  CC      hw/usb/dev-mtp.o
  CC      hw/usb/host-stub.o
  CC      hw/virtio/virtio-rng.o
  CC      hw/virtio/virtio-pci.o
  CC      hw/virtio/virtio-bus.o
  CC      hw/virtio/virtio-mmio.o
  CC      hw/virtio/vhost-stub.o
  CC      hw/watchdog/watchdog.o
  CC      hw/watchdog/wdt_i6300esb.o
  CC      hw/watchdog/wdt_ib700.o
  CC      hw/watchdog/wdt_aspeed.o
  CC      migration/migration.o
  CC      migration/socket.o
  CC      migration/fd.o
  CC      migration/exec.o
  CC      migration/tls.o
  CC      migration/channel.o
  CC      migration/savevm.o
  CC      migration/colo-comm.o
  CC      migration/colo.o
  CC      migration/colo-failover.o
  CC      migration/vmstate.o
  CC      migration/vmstate-types.o
  CC      migration/page_cache.o
  CC      migration/qemu-file.o
  CC      migration/global_state.o
  CC      migration/qemu-file-channel.o
  CC      migration/postcopy-ram.o
  CC      migration/xbzrle.o
  CC      migration/qjson.o
  CC      migration/block.o
  CC      net/net.o
  CC      net/queue.o
  CC      net/checksum.o
  CC      net/util.o
  CC      net/hub.o
  CC      net/socket.o
  CC      net/dump.o
  CC      net/eth.o
  CC      net/l2tpv3.o
  CC      net/vhost-user.o
  CC      net/slirp.o
  CC      net/filter.o
  CC      net/filter-buffer.o
  CC      net/filter-mirror.o
  CC      net/colo-compare.o
  CC      net/colo.o
  CC      net/filter-replay.o
  CC      net/filter-rewriter.o
  CC      net/tap.o
  CC      net/tap-linux.o
  CC      qom/cpu.o
  CC      replay/replay.o
  CC      replay/replay-internal.o
  CC      replay/replay-events.o
  CC      replay/replay-time.o
  CC      replay/replay-char.o
  CC      replay/replay-input.o
  CC      replay/replay-snapshot.o
  CC      replay/replay-net.o
  CC      replay/replay-audio.o
/tmp/qemu-test/src/replay/replay-internal.c: In function ‘replay_put_array’:
/tmp/qemu-test/src/replay/replay-internal.c:65: warning: ignoring return value of ‘fwrite’, declared with attribute warn_unused_result
  CC      slirp/cksum.o
  CC      slirp/if.o
  CC      slirp/ip_icmp.o
  CC      slirp/ip6_icmp.o
  CC      slirp/ip6_input.o
  CC      slirp/ip6_output.o
  CC      slirp/ip_input.o
  CC      slirp/ip_output.o
  CC      slirp/dnssearch.o
  CC      slirp/dhcpv6.o
  CC      slirp/slirp.o
  CC      slirp/mbuf.o
  CC      slirp/misc.o
  CC      slirp/sbuf.o
  CC      slirp/socket.o
  CC      slirp/tcp_input.o
  CC      slirp/tcp_output.o
  CC      slirp/tcp_timer.o
  CC      slirp/tcp_subr.o
  CC      slirp/udp.o
/tmp/qemu-test/src/slirp/tcp_input.c: In function ‘tcp_input’:
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_p’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_len’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_tos’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_id’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_off’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_ttl’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_sum’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_src.s_addr’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:219: warning: ‘save_ip.ip_dst.s_addr’ may be used uninitialized in this function
/tmp/qemu-test/src/slirp/tcp_input.c:220: warning: ‘save_ip6.ip_nh’ may be used uninitialized in this function
  CC      slirp/bootp.o
  CC      slirp/udp6.o
  CC      slirp/tftp.o
  CC      slirp/arp_table.o
  CC      slirp/ndp_table.o
  CC      slirp/ncsi.o
  CC      ui/keymaps.o
  CC      ui/console.o
  CC      ui/cursor.o
  CC      ui/qemu-pixman.o
  CC      ui/input.o
  CC      ui/input-keymap.o
  CC      ui/input-legacy.o
  CC      ui/sdl.o
  CC      ui/input-linux.o
  CC      ui/sdl_zoom.o
  CC      ui/x_keymap.o
  CC      ui/vnc.o
  CC      ui/vnc-enc-zlib.o
  CC      ui/vnc-enc-hextile.o
  CC      ui/vnc-palette.o
  CC      ui/vnc-enc-tight.o
  CC      ui/vnc-enc-zrle.o
  CC      ui/vnc-auth-vencrypt.o
  CC      ui/vnc-ws.o
  CC      ui/vnc-jobs.o
  CC      chardev/char.o
  CC      chardev/char-fd.o
  CC      chardev/char-fe.o
  CC      chardev/char-file.o
  CC      chardev/char-io.o
  CC      chardev/char-mux.o
  CC      chardev/char-null.o
  CC      chardev/char-parallel.o
  CC      chardev/char-pipe.o
  CC      chardev/char-pty.o
  CC      chardev/char-ringbuf.o
  CC      chardev/char-serial.o
  CC      chardev/char-socket.o
  CC      chardev/char-stdio.o
  CC      chardev/char-udp.o
  LINK    tests/qemu-iotests/socket_scm_helper
  CC      qga/commands.o
  CC      qga/guest-agent-command-state.o
  CC      qga/main.o
  CC      qga/commands-posix.o
  CC      qga/channel-posix.o
  CC      qga/qapi-generated/qga-qapi-types.o
  CC      qga/qapi-generated/qga-qapi-visit.o
  CC      qga/qapi-generated/qga-qmp-marshal.o
  AR      libqemuutil.a
  AS      optionrom/multiboot.o
  AS      optionrom/linuxboot.o
  CC      optionrom/linuxboot_dma.o
cc: unrecognized option '-no-integrated-as'
cc: unrecognized option '-no-integrated-as'
  AS      optionrom/kvmvapic.o
  AR      libqemustub.a
  BUILD   optionrom/multiboot.img
  BUILD   optionrom/linuxboot.img
  BUILD   optionrom/linuxboot_dma.img
  CC      qemu-img.o
  BUILD   optionrom/multiboot.raw
  BUILD   optionrom/linuxboot.raw
  BUILD   optionrom/linuxboot_dma.raw
  BUILD   optionrom/kvmvapic.img
  SIGN    optionrom/multiboot.bin
  SIGN    optionrom/linuxboot.bin
  SIGN    optionrom/linuxboot_dma.bin
  BUILD   optionrom/kvmvapic.raw
  SIGN    optionrom/kvmvapic.bin
  LINK    qemu-ga
  LINK    ivshmem-client
  LINK    ivshmem-server
  LINK    qemu-nbd
  LINK    qemu-img
  LINK    qemu-io
  LINK    qemu-bridge-helper
  GEN     x86_64-softmmu/hmp-commands.h
  GEN     x86_64-softmmu/config-target.h
  GEN     x86_64-softmmu/hmp-commands-info.h
  GEN     aarch64-softmmu/hmp-commands.h
  GEN     aarch64-softmmu/hmp-commands-info.h
  GEN     aarch64-softmmu/config-target.h
  CC      aarch64-softmmu/tcg/tcg-op.o
  CC      aarch64-softmmu/exec.o
  CC      aarch64-softmmu/tcg/tcg.o
  CC      aarch64-softmmu/tcg/tcg-runtime.o
  CC      aarch64-softmmu/tcg/optimize.o
  CC      aarch64-softmmu/tcg/tcg-common.o
  CC      aarch64-softmmu/fpu/softfloat.o
  CC      x86_64-softmmu/exec.o
  CC      aarch64-softmmu/disas.o
  GEN     aarch64-softmmu/gdbstub-xml.c
  CC      aarch64-softmmu/hax-stub.o
  CC      x86_64-softmmu/tcg/tcg.o
  CC      aarch64-softmmu/arch_init.o
  CC      aarch64-softmmu/cpus.o
  CC      x86_64-softmmu/tcg/optimize.o
  CC      aarch64-softmmu/monitor.o
  CC      x86_64-softmmu/tcg/tcg-op.o
  CC      x86_64-softmmu/tcg/tcg-common.o
  CC      x86_64-softmmu/tcg/tcg-runtime.o
  CC      x86_64-softmmu/fpu/softfloat.o
  CC      aarch64-softmmu/gdbstub.o
  CC      x86_64-softmmu/disas.o
  GEN     x86_64-softmmu/gdbstub-xml.c
  CC      x86_64-softmmu/hax-stub.o
  CC      x86_64-softmmu/cpus.o
  CC      x86_64-softmmu/arch_init.o
  CC      x86_64-softmmu/monitor.o
  CC      aarch64-softmmu/balloon.o
  CC      x86_64-softmmu/gdbstub.o
  CC      x86_64-softmmu/balloon.o
  CC      x86_64-softmmu/ioport.o
  CC      x86_64-softmmu/numa.o
  CC      x86_64-softmmu/qtest.o
  CC      aarch64-softmmu/ioport.o
  CC      x86_64-softmmu/memory.o
  CC      x86_64-softmmu/dump.o
  CC      x86_64-softmmu/memory_mapping.o
  CC      x86_64-softmmu/migration/ram.o
  CC      x86_64-softmmu/accel/accel.o
  CC      x86_64-softmmu/accel/kvm/kvm-all.o
  CC      x86_64-softmmu/accel/tcg/cputlb.o
  CC      x86_64-softmmu/accel/tcg/tcg-all.o
  CC      aarch64-softmmu/numa.o
  CC      x86_64-softmmu/accel/tcg/cpu-exec.o
  CC      x86_64-softmmu/accel/tcg/cpu-exec-common.o
  CC      x86_64-softmmu/hw/block/virtio-blk.o
  CC      x86_64-softmmu/accel/tcg/translate-all.o
  CC      x86_64-softmmu/hw/block/dataplane/virtio-blk.o
  CC      x86_64-softmmu/hw/char/virtio-serial-bus.o
  CC      aarch64-softmmu/qtest.o
  CC      aarch64-softmmu/memory.o
  CC      aarch64-softmmu/memory_mapping.o
  CC      x86_64-softmmu/hw/core/generic-loader.o
  CC      x86_64-softmmu/hw/core/null-machine.o
  CC      x86_64-softmmu/hw/display/vga.o
  CC      aarch64-softmmu/dump.o
  CC      x86_64-softmmu/hw/display/virtio-gpu.o
  CC      x86_64-softmmu/hw/display/virtio-gpu-3d.o
  CC      aarch64-softmmu/migration/ram.o
  CC      aarch64-softmmu/accel/accel.o
  CC      aarch64-softmmu/accel/stubs/kvm-stub.o
  CC      x86_64-softmmu/hw/display/virtio-gpu-pci.o
  CC      aarch64-softmmu/accel/tcg/tcg-all.o
  CC      aarch64-softmmu/accel/tcg/cputlb.o
  CC      x86_64-softmmu/hw/display/virtio-vga.o
  CC      x86_64-softmmu/hw/intc/apic.o
  CC      aarch64-softmmu/accel/tcg/cpu-exec.o
  CC      x86_64-softmmu/hw/intc/apic_common.o
  CC      aarch64-softmmu/accel/tcg/cpu-exec-common.o
  CC      x86_64-softmmu/hw/intc/ioapic.o
  CC      aarch64-softmmu/accel/tcg/translate-all.o
  CC      x86_64-softmmu/hw/isa/lpc_ich9.o
  CC      x86_64-softmmu/hw/misc/vmport.o
  CC      x86_64-softmmu/hw/misc/ivshmem.o
  CC      aarch64-softmmu/hw/block/virtio-blk.o
  CC      aarch64-softmmu/hw/adc/stm32f2xx_adc.o
  CC      aarch64-softmmu/hw/block/dataplane/virtio-blk.o
  CC      aarch64-softmmu/hw/char/exynos4210_uart.o
  CC      x86_64-softmmu/hw/misc/pvpanic.o
  CC      aarch64-softmmu/hw/char/omap_uart.o
  CC      aarch64-softmmu/hw/char/digic-uart.o
  CC      x86_64-softmmu/hw/misc/hyperv_testdev.o
  CC      aarch64-softmmu/hw/char/stm32f2xx_usart.o
  CC      aarch64-softmmu/hw/char/bcm2835_aux.o
  CC      aarch64-softmmu/hw/char/virtio-serial-bus.o
  CC      aarch64-softmmu/hw/core/generic-loader.o
  CC      aarch64-softmmu/hw/core/null-machine.o
  CC      x86_64-softmmu/hw/misc/mmio_interface.o
  CC      x86_64-softmmu/hw/net/virtio-net.o
  CC      x86_64-softmmu/hw/scsi/virtio-scsi.o
  CC      x86_64-softmmu/hw/net/vhost_net.o
  CC      aarch64-softmmu/hw/cpu/arm11mpcore.o
  CC      x86_64-softmmu/hw/scsi/virtio-scsi-dataplane.o
  CC      x86_64-softmmu/hw/scsi/vhost-scsi-common.o
  CC      x86_64-softmmu/hw/scsi/vhost-scsi.o
  CC      x86_64-softmmu/hw/scsi/vhost-user-scsi.o
  CC      aarch64-softmmu/hw/cpu/realview_mpcore.o
  CC      x86_64-softmmu/hw/timer/mc146818rtc.o
  CC      x86_64-softmmu/hw/vfio/common.o
  CC      x86_64-softmmu/hw/vfio/pci.o
  CC      x86_64-softmmu/hw/vfio/pci-quirks.o
  CC      x86_64-softmmu/hw/vfio/platform.o
  CC      x86_64-softmmu/hw/vfio/spapr.o
  CC      x86_64-softmmu/hw/virtio/virtio.o
  CC      aarch64-softmmu/hw/cpu/a9mpcore.o
  CC      x86_64-softmmu/hw/virtio/virtio-balloon.o
  CC      x86_64-softmmu/hw/virtio/vhost.o
  CC      aarch64-softmmu/hw/cpu/a15mpcore.o
  CC      x86_64-softmmu/hw/virtio/vhost-backend.o
  CC      x86_64-softmmu/hw/virtio/vhost-vsock.o
  CC      x86_64-softmmu/hw/virtio/vhost-user.o
  CC      x86_64-softmmu/hw/virtio/virtio-crypto.o
  CC      x86_64-softmmu/hw/virtio/virtio-crypto-pci.o
  CC      aarch64-softmmu/hw/display/omap_dss.o
  CC      x86_64-softmmu/hw/i386/multiboot.o
  CC      x86_64-softmmu/hw/i386/pc_piix.o
  CC      x86_64-softmmu/hw/i386/pc.o
  CC      x86_64-softmmu/hw/i386/pc_q35.o
  CC      aarch64-softmmu/hw/display/omap_lcdc.o
  CC      aarch64-softmmu/hw/display/pxa2xx_lcd.o
  CC      x86_64-softmmu/hw/i386/pc_sysfw.o
  CC      x86_64-softmmu/hw/i386/x86-iommu.o
  CC      aarch64-softmmu/hw/display/bcm2835_fb.o
  CC      x86_64-softmmu/hw/i386/intel_iommu.o
  CC      x86_64-softmmu/hw/i386/amd_iommu.o
/tmp/qemu-test/src/hw/i386/pc_piix.c: In function ‘igd_passthrough_isa_bridge_create’:
/tmp/qemu-test/src/hw/i386/pc_piix.c:1065: warning: ‘pch_rev_id’ may be used uninitialized in this function
  CC      x86_64-softmmu/hw/i386/kvmvapic.o
  CC      x86_64-softmmu/hw/i386/acpi-build.o
  CC      x86_64-softmmu/hw/i386/pci-assign-load-rom.o
  CC      x86_64-softmmu/hw/i386/kvm/clock.o
  CC      aarch64-softmmu/hw/display/vga.o
  CC      x86_64-softmmu/hw/i386/kvm/apic.o
  CC      x86_64-softmmu/hw/i386/kvm/i8259.o
/tmp/qemu-test/src/hw/i386/acpi-build.c: In function ‘build_append_pci_bus_devices’:
/tmp/qemu-test/src/hw/i386/acpi-build.c:539: warning: ‘notify_method’ may be used uninitialized in this function
  CC      x86_64-softmmu/hw/i386/kvm/ioapic.o
  CC      x86_64-softmmu/hw/i386/kvm/i8254.o
  CC      x86_64-softmmu/hw/i386/kvm/pci-assign.o
  CC      x86_64-softmmu/target/i386/helper.o
  CC      x86_64-softmmu/target/i386/cpu.o
  CC      aarch64-softmmu/hw/display/virtio-gpu.o
  CC      x86_64-softmmu/target/i386/gdbstub.o
  CC      aarch64-softmmu/hw/display/virtio-gpu-3d.o
  CC      x86_64-softmmu/target/i386/xsave_helper.o
  CC      x86_64-softmmu/target/i386/translate.o
  CC      x86_64-softmmu/target/i386/bpt_helper.o
  CC      x86_64-softmmu/target/i386/cc_helper.o
  CC      x86_64-softmmu/target/i386/excp_helper.o
  CC      x86_64-softmmu/target/i386/fpu_helper.o
  CC      x86_64-softmmu/target/i386/int_helper.o
  CC      aarch64-softmmu/hw/display/virtio-gpu-pci.o
  CC      x86_64-softmmu/target/i386/mem_helper.o
  CC      x86_64-softmmu/target/i386/misc_helper.o
  CC      x86_64-softmmu/target/i386/mpx_helper.o
  CC      x86_64-softmmu/target/i386/seg_helper.o
  CC      aarch64-softmmu/hw/display/dpcd.o
  CC      x86_64-softmmu/target/i386/smm_helper.o
  CC      x86_64-softmmu/target/i386/svm_helper.o
  CC      x86_64-softmmu/target/i386/machine.o
  CC      x86_64-softmmu/target/i386/arch_memory_mapping.o
  CC      x86_64-softmmu/target/i386/arch_dump.o
  CC      x86_64-softmmu/target/i386/monitor.o
  CC      x86_64-softmmu/target/i386/kvm.o
  CC      aarch64-softmmu/hw/display/xlnx_dp.o
  CC      aarch64-softmmu/hw/dma/xlnx_dpdma.o
  CC      x86_64-softmmu/target/i386/hyperv.o
  CC      aarch64-softmmu/hw/dma/omap_dma.o
  CC      aarch64-softmmu/hw/dma/soc_dma.o
  CC      aarch64-softmmu/hw/dma/pxa2xx_dma.o
  CC      aarch64-softmmu/hw/dma/bcm2835_dma.o
  CC      aarch64-softmmu/hw/gpio/omap_gpio.o
  CC      aarch64-softmmu/hw/gpio/imx_gpio.o
  CC      x86_64-softmmu/trace/control-target.o
  GEN     trace/generated-helpers.c
  CC      aarch64-softmmu/hw/gpio/bcm2835_gpio.o
  CC      aarch64-softmmu/hw/i2c/omap_i2c.o
  CC      aarch64-softmmu/hw/input/pxa2xx_keypad.o
  CC      aarch64-softmmu/hw/input/tsc210x.o
  CC      aarch64-softmmu/hw/intc/exynos4210_gic.o
  CC      aarch64-softmmu/hw/intc/armv7m_nvic.o
  CC      aarch64-softmmu/hw/intc/exynos4210_combiner.o
  CC      aarch64-softmmu/hw/intc/omap_intc.o
  CC      aarch64-softmmu/hw/intc/bcm2835_ic.o
  CC      aarch64-softmmu/hw/intc/bcm2836_control.o
  CC      x86_64-softmmu/gdbstub-xml.o
  CC      aarch64-softmmu/hw/intc/allwinner-a10-pic.o
  CC      aarch64-softmmu/hw/intc/aspeed_vic.o
  CC      aarch64-softmmu/hw/intc/arm_gicv3_cpuif.o
  CC      aarch64-softmmu/hw/misc/ivshmem.o
  CC      aarch64-softmmu/hw/misc/arm_sysctl.o
  CC      aarch64-softmmu/hw/misc/exynos4210_pmu.o
  CC      x86_64-softmmu/trace/generated-helpers.o
  CC      aarch64-softmmu/hw/misc/cbus.o
  CC      aarch64-softmmu/hw/misc/exynos4210_clk.o
  CC      aarch64-softmmu/hw/misc/exynos4210_rng.o
  CC      aarch64-softmmu/hw/misc/imx_ccm.o
  CC      aarch64-softmmu/hw/misc/imx31_ccm.o
  CC      aarch64-softmmu/hw/misc/imx25_ccm.o
  CC      aarch64-softmmu/hw/misc/imx6_ccm.o
  CC      aarch64-softmmu/hw/misc/imx6_src.o
  CC      aarch64-softmmu/hw/misc/mst_fpga.o
  CC      aarch64-softmmu/hw/misc/omap_clk.o
  CC      aarch64-softmmu/hw/misc/omap_gpmc.o
  CC      aarch64-softmmu/hw/misc/omap_sdrc.o
  CC      aarch64-softmmu/hw/misc/omap_l4.o
  CC      aarch64-softmmu/hw/misc/omap_tap.o
  CC      aarch64-softmmu/hw/misc/bcm2835_mbox.o
  CC      aarch64-softmmu/hw/misc/bcm2835_property.o
  LINK    x86_64-softmmu/qemu-system-x86_64
  CC      aarch64-softmmu/hw/misc/bcm2835_rng.o
  CC      aarch64-softmmu/hw/misc/zynq_slcr.o
  CC      aarch64-softmmu/hw/misc/zynq-xadc.o
  CC      aarch64-softmmu/hw/misc/auxbus.o
  CC      aarch64-softmmu/hw/misc/mps2-scc.o
  CC      aarch64-softmmu/hw/misc/stm32f2xx_syscfg.o
  CC      aarch64-softmmu/hw/misc/aspeed_scu.o
  CC      aarch64-softmmu/hw/misc/aspeed_sdmc.o
  CC      aarch64-softmmu/hw/misc/mmio_interface.o
  CC      aarch64-softmmu/hw/net/virtio-net.o
  CC      aarch64-softmmu/hw/net/vhost_net.o
  CC      aarch64-softmmu/hw/pcmcia/pxa2xx.o
  CC      aarch64-softmmu/hw/scsi/virtio-scsi.o
  CC      aarch64-softmmu/hw/scsi/virtio-scsi-dataplane.o
  CC      aarch64-softmmu/hw/scsi/vhost-scsi-common.o
  CC      aarch64-softmmu/hw/scsi/vhost-scsi.o
  CC      aarch64-softmmu/hw/scsi/vhost-user-scsi.o
  CC      aarch64-softmmu/hw/sd/omap_mmc.o
  CC      aarch64-softmmu/hw/sd/pxa2xx_mmci.o
  CC      aarch64-softmmu/hw/sd/bcm2835_sdhost.o
  CC      aarch64-softmmu/hw/ssi/omap_spi.o
  CC      aarch64-softmmu/hw/ssi/imx_spi.o
  CC      aarch64-softmmu/hw/timer/exynos4210_mct.o
  CC      aarch64-softmmu/hw/timer/exynos4210_pwm.o
  CC      aarch64-softmmu/hw/timer/exynos4210_rtc.o
  CC      aarch64-softmmu/hw/timer/omap_gptimer.o
  CC      aarch64-softmmu/hw/timer/omap_synctimer.o
  CC      aarch64-softmmu/hw/timer/pxa2xx_timer.o
  CC      aarch64-softmmu/hw/timer/digic-timer.o
  CC      aarch64-softmmu/hw/timer/allwinner-a10-pit.o
  CC      aarch64-softmmu/hw/usb/tusb6010.o
  CC      aarch64-softmmu/hw/vfio/common.o
  CC      aarch64-softmmu/hw/vfio/pci.o
  CC      aarch64-softmmu/hw/vfio/pci-quirks.o
  CC      aarch64-softmmu/hw/vfio/platform.o
  CC      aarch64-softmmu/hw/vfio/spapr.o
  CC      aarch64-softmmu/hw/vfio/calxeda-xgmac.o
  CC      aarch64-softmmu/hw/virtio/virtio.o
  CC      aarch64-softmmu/hw/vfio/amd-xgbe.o
  CC      aarch64-softmmu/hw/virtio/virtio-balloon.o
  CC      aarch64-softmmu/hw/virtio/vhost.o
  CC      aarch64-softmmu/hw/virtio/vhost-backend.o
  CC      aarch64-softmmu/hw/virtio/vhost-user.o
  CC      aarch64-softmmu/hw/virtio/vhost-vsock.o
  CC      aarch64-softmmu/hw/virtio/virtio-crypto.o
  CC      aarch64-softmmu/hw/virtio/virtio-crypto-pci.o
  CC      aarch64-softmmu/hw/arm/boot.o
  CC      aarch64-softmmu/hw/arm/collie.o
  CC      aarch64-softmmu/hw/arm/exynos4_boards.o
  CC      aarch64-softmmu/hw/arm/gumstix.o
  CC      aarch64-softmmu/hw/arm/highbank.o
  CC      aarch64-softmmu/hw/arm/digic_boards.o
  CC      aarch64-softmmu/hw/arm/integratorcp.o
  CC      aarch64-softmmu/hw/arm/musicpal.o
  CC      aarch64-softmmu/hw/arm/mainstone.o
  CC      aarch64-softmmu/hw/arm/nseries.o
  CC      aarch64-softmmu/hw/arm/omap_sx1.o
  CC      aarch64-softmmu/hw/arm/palm.o
  CC      aarch64-softmmu/hw/arm/realview.o
  CC      aarch64-softmmu/hw/arm/spitz.o
  CC      aarch64-softmmu/hw/arm/stellaris.o
  CC      aarch64-softmmu/hw/arm/tosa.o
  CC      aarch64-softmmu/hw/arm/versatilepb.o
  CC      aarch64-softmmu/hw/arm/vexpress.o
  CC      aarch64-softmmu/hw/arm/virt.o
  CC      aarch64-softmmu/hw/arm/xilinx_zynq.o
  CC      aarch64-softmmu/hw/arm/z2.o
  CC      aarch64-softmmu/hw/arm/virt-acpi-build.o
  CC      aarch64-softmmu/hw/arm/netduino2.o
  CC      aarch64-softmmu/hw/arm/sysbus-fdt.o
  CC      aarch64-softmmu/hw/arm/armv7m.o
  CC      aarch64-softmmu/hw/arm/exynos4210.o
  CC      aarch64-softmmu/hw/arm/pxa2xx.o
  CC      aarch64-softmmu/hw/arm/pxa2xx_gpio.o
  CC      aarch64-softmmu/hw/arm/digic.o
  CC      aarch64-softmmu/hw/arm/pxa2xx_pic.o
  CC      aarch64-softmmu/hw/arm/omap1.o
  CC      aarch64-softmmu/hw/arm/omap2.o
  CC      aarch64-softmmu/hw/arm/strongarm.o
  CC      aarch64-softmmu/hw/arm/allwinner-a10.o
  CC      aarch64-softmmu/hw/arm/cubieboard.o
  CC      aarch64-softmmu/hw/arm/bcm2835_peripherals.o
  CC      aarch64-softmmu/hw/arm/bcm2836.o
  CC      aarch64-softmmu/hw/arm/raspi.o
  CC      aarch64-softmmu/hw/arm/stm32f205_soc.o
  CC      aarch64-softmmu/hw/arm/xlnx-zynqmp.o
  CC      aarch64-softmmu/hw/arm/xlnx-ep108.o
  CC      aarch64-softmmu/hw/arm/fsl-imx25.o
  CC      aarch64-softmmu/hw/arm/imx25_pdk.o
  CC      aarch64-softmmu/hw/arm/fsl-imx31.o
  CC      aarch64-softmmu/hw/arm/kzm.o
  CC      aarch64-softmmu/hw/arm/fsl-imx6.o
  CC      aarch64-softmmu/hw/arm/sabrelite.o
  CC      aarch64-softmmu/hw/arm/aspeed_soc.o
  CC      aarch64-softmmu/hw/arm/mps2.o
  CC      aarch64-softmmu/hw/arm/aspeed.o
  CC      aarch64-softmmu/target/arm/arm-semi.o
  CC      aarch64-softmmu/target/arm/psci.o
  CC      aarch64-softmmu/target/arm/machine.o
  CC      aarch64-softmmu/target/arm/arch_dump.o
  CC      aarch64-softmmu/target/arm/monitor.o
  CC      aarch64-softmmu/target/arm/kvm-stub.o
  CC      aarch64-softmmu/target/arm/translate.o
  CC      aarch64-softmmu/target/arm/op_helper.o
  CC      aarch64-softmmu/target/arm/helper.o
  CC      aarch64-softmmu/target/arm/cpu.o
  CC      aarch64-softmmu/target/arm/iwmmxt_helper.o
  CC      aarch64-softmmu/target/arm/neon_helper.o
  CC      aarch64-softmmu/target/arm/gdbstub.o
  CC      aarch64-softmmu/target/arm/cpu64.o
  CC      aarch64-softmmu/target/arm/translate-a64.o
  CC      aarch64-softmmu/target/arm/gdbstub64.o
  CC      aarch64-softmmu/target/arm/helper-a64.o
  CC      aarch64-softmmu/target/arm/crypto_helper.o
  CC      aarch64-softmmu/target/arm/arm-powerctl.o
/tmp/qemu-test/src/target/arm/translate-a64.c: In function ‘handle_shri_with_rndacc’:
/tmp/qemu-test/src/target/arm/translate-a64.c:6357: warning: ‘tcg_src_hi’ may be used uninitialized in this function
/tmp/qemu-test/src/target/arm/translate-a64.c: In function ‘disas_simd_scalar_two_reg_misc’:
/tmp/qemu-test/src/target/arm/translate-a64.c:8084: warning: ‘rmode’ may be used uninitialized in this function
  GEN     trace/generated-helpers.c
  CC      aarch64-softmmu/trace/control-target.o
  CC      aarch64-softmmu/gdbstub-xml.o
  CC      aarch64-softmmu/trace/generated-helpers.o
  LINK    aarch64-softmmu/qemu-system-aarch64
  TEST    tests/qapi-schema/alternate-array.out
  TEST    tests/qapi-schema/alternate-any.out
  TEST    tests/qapi-schema/alternate-base.out
  TEST    tests/qapi-schema/alternate-clash.out
  TEST    tests/qapi-schema/alternate-conflict-dict.out
  TEST    tests/qapi-schema/alternate-conflict-enum-bool.out
  TEST    tests/qapi-schema/alternate-conflict-enum-int.out
  TEST    tests/qapi-schema/alternate-conflict-string.out
  TEST    tests/qapi-schema/alternate-empty.out
  TEST    tests/qapi-schema/alternate-nested.out
  TEST    tests/qapi-schema/alternate-unknown.out
  TEST    tests/qapi-schema/args-alternate.out
  TEST    tests/qapi-schema/args-any.out
  TEST    tests/qapi-schema/args-array-empty.out
  TEST    tests/qapi-schema/args-array-unknown.out
  TEST    tests/qapi-schema/args-bad-boxed.out
  TEST    tests/qapi-schema/args-boxed-anon.out
  TEST    tests/qapi-schema/args-boxed-empty.out
  TEST    tests/qapi-schema/args-boxed-string.out
  TEST    tests/qapi-schema/args-int.out
  TEST    tests/qapi-schema/args-invalid.out
  TEST    tests/qapi-schema/args-member-array-bad.out
  TEST    tests/qapi-schema/args-member-case.out
  TEST    tests/qapi-schema/args-member-unknown.out
  TEST    tests/qapi-schema/args-name-clash.out
  TEST    tests/qapi-schema/args-union.out
  TEST    tests/qapi-schema/args-unknown.out
  TEST    tests/qapi-schema/bad-base.out
  TEST    tests/qapi-schema/bad-data.out
  TEST    tests/qapi-schema/bad-ident.out
  TEST    tests/qapi-schema/bad-type-bool.out
  TEST    tests/qapi-schema/bad-type-dict.out
  TEST    tests/qapi-schema/bad-type-int.out
  TEST    tests/qapi-schema/base-cycle-direct.out
  TEST    tests/qapi-schema/base-cycle-indirect.out
  TEST    tests/qapi-schema/command-int.out
  TEST    tests/qapi-schema/comments.out
  TEST    tests/qapi-schema/doc-bad-alternate-member.out
  TEST    tests/qapi-schema/doc-bad-command-arg.out
  TEST    tests/qapi-schema/doc-bad-symbol.out
  TEST    tests/qapi-schema/doc-bad-union-member.out
  TEST    tests/qapi-schema/doc-before-include.out
  TEST    tests/qapi-schema/doc-before-pragma.out
  TEST    tests/qapi-schema/doc-duplicated-arg.out
  TEST    tests/qapi-schema/doc-duplicated-return.out
  TEST    tests/qapi-schema/doc-duplicated-since.out
  TEST    tests/qapi-schema/doc-empty-arg.out
  TEST    tests/qapi-schema/doc-empty-section.out
  TEST    tests/qapi-schema/doc-empty-symbol.out
  TEST    tests/qapi-schema/doc-good.out
  TEST    tests/qapi-schema/doc-interleaved-section.out
  TEST    tests/qapi-schema/doc-invalid-end.out
  TEST    tests/qapi-schema/doc-invalid-end2.out
  TEST    tests/qapi-schema/doc-invalid-return.out
  TEST    tests/qapi-schema/doc-invalid-section.out
  TEST    tests/qapi-schema/doc-invalid-start.out
  TEST    tests/qapi-schema/doc-missing.out
  TEST    tests/qapi-schema/doc-missing-colon.out
  TEST    tests/qapi-schema/doc-missing-expr.out
  TEST    tests/qapi-schema/doc-missing-space.out
  TEST    tests/qapi-schema/doc-no-symbol.out
  TEST    tests/qapi-schema/double-type.out
  TEST    tests/qapi-schema/double-data.out
  TEST    tests/qapi-schema/duplicate-key.out
  TEST    tests/qapi-schema/empty.out
  TEST    tests/qapi-schema/enum-bad-name.out
  TEST    tests/qapi-schema/enum-bad-prefix.out
  TEST    tests/qapi-schema/enum-clash-member.out
  TEST    tests/qapi-schema/enum-dict-member.out
  TEST    tests/qapi-schema/enum-int-member.out
  TEST    tests/qapi-schema/enum-member-case.out
  TEST    tests/qapi-schema/enum-missing-data.out
  TEST    tests/qapi-schema/enum-wrong-data.out
  TEST    tests/qapi-schema/escape-outside-string.out
  TEST    tests/qapi-schema/escape-too-short.out
  TEST    tests/qapi-schema/escape-too-big.out
  TEST    tests/qapi-schema/event-boxed-empty.out
  TEST    tests/qapi-schema/event-case.out
  TEST    tests/qapi-schema/event-nest-struct.out
  TEST    tests/qapi-schema/flat-union-array-branch.out
  TEST    tests/qapi-schema/flat-union-bad-base.out
  TEST    tests/qapi-schema/flat-union-bad-discriminator.out
  TEST    tests/qapi-schema/flat-union-base-any.out
  TEST    tests/qapi-schema/flat-union-base-union.out
  TEST    tests/qapi-schema/flat-union-clash-member.out
  TEST    tests/qapi-schema/flat-union-empty.out
  TEST    tests/qapi-schema/flat-union-incomplete-branch.out
  TEST    tests/qapi-schema/flat-union-inline.out
  TEST    tests/qapi-schema/flat-union-int-branch.out
  TEST    tests/qapi-schema/flat-union-invalid-branch-key.out
  TEST    tests/qapi-schema/flat-union-invalid-discriminator.out
  TEST    tests/qapi-schema/flat-union-no-base.out
  TEST    tests/qapi-schema/flat-union-optional-discriminator.out
  TEST    tests/qapi-schema/flat-union-string-discriminator.out
  TEST    tests/qapi-schema/funny-char.out
  TEST    tests/qapi-schema/ident-with-escape.out
  TEST    tests/qapi-schema/include-before-err.out
  TEST    tests/qapi-schema/include-cycle.out
  TEST    tests/qapi-schema/include-extra-junk.out
  TEST    tests/qapi-schema/include-format-err.out
  TEST    tests/qapi-schema/include-nested-err.out
  TEST    tests/qapi-schema/include-no-file.out
  TEST    tests/qapi-schema/include-non-file.out
  TEST    tests/qapi-schema/include-relpath.out
  TEST    tests/qapi-schema/include-repetition.out
  TEST    tests/qapi-schema/include-self-cycle.out
  TEST    tests/qapi-schema/include-simple.out
  TEST    tests/qapi-schema/indented-expr.out
  TEST    tests/qapi-schema/leading-comma-list.out
  TEST    tests/qapi-schema/leading-comma-object.out
  TEST    tests/qapi-schema/missing-colon.out
  TEST    tests/qapi-schema/missing-comma-list.out
  TEST    tests/qapi-schema/missing-comma-object.out
  TEST    tests/qapi-schema/missing-type.out
  TEST    tests/qapi-schema/nested-struct-data.out
  TEST    tests/qapi-schema/non-objects.out
  TEST    tests/qapi-schema/pragma-doc-required-crap.out
  TEST    tests/qapi-schema/pragma-extra-junk.out
  TEST    tests/qapi-schema/pragma-name-case-whitelist-crap.out
  TEST    tests/qapi-schema/pragma-non-dict.out
  TEST    tests/qapi-schema/qapi-schema-test.out
  TEST    tests/qapi-schema/pragma-returns-whitelist-crap.out
  TEST    tests/qapi-schema/quoted-structural-chars.out
  TEST    tests/qapi-schema/redefined-builtin.out
  TEST    tests/qapi-schema/redefined-command.out
  TEST    tests/qapi-schema/redefined-event.out
  TEST    tests/qapi-schema/redefined-type.out
  TEST    tests/qapi-schema/reserved-command-q.out
  TEST    tests/qapi-schema/reserved-enum-q.out
  TEST    tests/qapi-schema/reserved-member-has.out
  TEST    tests/qapi-schema/reserved-member-q.out
  TEST    tests/qapi-schema/reserved-member-u.out
  TEST    tests/qapi-schema/reserved-member-underscore.out
  TEST    tests/qapi-schema/reserved-type-kind.out
  TEST    tests/qapi-schema/returns-alternate.out
  TEST    tests/qapi-schema/reserved-type-list.out
  TEST    tests/qapi-schema/returns-array-bad.out
  TEST    tests/qapi-schema/returns-dict.out
  TEST    tests/qapi-schema/returns-unknown.out
  TEST    tests/qapi-schema/returns-whitelist.out
  TEST    tests/qapi-schema/struct-base-clash-deep.out
  TEST    tests/qapi-schema/struct-base-clash.out
  TEST    tests/qapi-schema/struct-data-invalid.out
  TEST    tests/qapi-schema/struct-member-invalid.out
  TEST    tests/qapi-schema/trailing-comma-list.out
  TEST    tests/qapi-schema/trailing-comma-object.out
  TEST    tests/qapi-schema/type-bypass-bad-gen.out
  TEST    tests/qapi-schema/unclosed-list.out
  TEST    tests/qapi-schema/unclosed-object.out
  TEST    tests/qapi-schema/unclosed-string.out
  TEST    tests/qapi-schema/unicode-str.out
  TEST    tests/qapi-schema/union-base-empty.out
  TEST    tests/qapi-schema/union-base-no-discriminator.out
  TEST    tests/qapi-schema/union-branch-case.out
  TEST    tests/qapi-schema/union-clash-branches.out
  TEST    tests/qapi-schema/union-empty.out
  TEST    tests/qapi-schema/union-invalid-base.out
  TEST    tests/qapi-schema/union-optional-branch.out
  TEST    tests/qapi-schema/union-unknown.out
  TEST    tests/qapi-schema/unknown-escape.out
  TEST    tests/qapi-schema/unknown-expr-key.out
  GEN     tests/qapi-schema/doc-good.test.texi
  CC      tests/check-qdict.o
  CC      tests/test-char.o
  CC      tests/check-qnum.o
  CC      tests/check-qstring.o
  CC      tests/check-qlist.o
  CC      tests/check-qnull.o
  CC      tests/test-qobject-output-visitor.o
  GEN     tests/test-qapi-visit.c
  CC      tests/check-qjson.o
  GEN     tests/test-qapi-types.c
  GEN     tests/test-qapi-event.c
  GEN     tests/test-qmp-introspect.c
  CC      tests/test-clone-visitor.o
  CC      tests/test-qobject-input-visitor.o
  CC      tests/test-qmp-commands.o
  GEN     tests/test-qmp-marshal.c
  CC      tests/test-string-input-visitor.o
  CC      tests/test-string-output-visitor.o
  CC      tests/test-qmp-event.o
  CC      tests/test-opts-visitor.o
  CC      tests/test-coroutine.o
  CC      tests/iothread.o
  CC      tests/test-visitor-serialization.o
  CC      tests/test-iov.o
  CC      tests/test-aio.o
  CC      tests/test-aio-multithread.o
  CC      tests/test-throttle.o
  CC      tests/test-thread-pool.o
  CC      tests/test-hbitmap.o
  CC      tests/test-blockjob.o
  CC      tests/test-x86-cpuid.o
  CC      tests/test-blockjob-txn.o
  CC      tests/test-xbzrle.o
  CC      tests/test-vmstate.o
  CC      tests/test-cutils.o
  CC      tests/test-shift128.o
  CC      tests/test-mul64.o
  CC      tests/test-int128.o
  CC      tests/rcutorture.o
  CC      tests/test-rcu-list.o
  CC      tests/test-qdist.o
/tmp/qemu-test/src/tests/test-int128.c:180: warning: ‘__noclone__’ attribute directive ignored
  CC      tests/test-qht.o
  CC      tests/test-qht-par.o
  CC      tests/qht-bench.o
  CC      tests/test-bitops.o
  CC      tests/test-bitcnt.o
  CC      tests/check-qom-interface.o
  CC      tests/check-qom-proplist.o
  CC      tests/test-qemu-opts.o
  CC      tests/test-keyval.o
  CC      tests/test-write-threshold.o
  CC      tests/test-crypto-hash.o
  CC      tests/test-crypto-hmac.o
  CC      tests/test-crypto-cipher.o
  CC      tests/test-crypto-secret.o
  CC      tests/libqtest.o
  CC      tests/test-qga.o
  CC      tests/test-timed-average.o
  CC      tests/test-io-channel-socket.o
  CC      tests/io-channel-helpers.o
  CC      tests/test-io-task.o
  CC      tests/test-io-channel-file.o
  CC      tests/test-io-channel-command.o
  CC      tests/test-io-channel-buffer.o
  CC      tests/test-base64.o
  CC      tests/test-crypto-ivgen.o
  CC      tests/test-crypto-xts.o
  CC      tests/test-crypto-afsplit.o
  CC      tests/test-crypto-block.o
  CC      tests/test-logging.o
  CC      tests/test-replication.o
  CC      tests/test-bufferiszero.o
  CC      tests/test-uuid.o
  CC      tests/ptimer-test.o
  CC      tests/ptimer-test-stubs.o
  CC      tests/test-qapi-util.o
  CC      tests/vhost-user-test.o
  CC      tests/libqos/pci.o
  CC      tests/libqos/fw_cfg.o
  CC      tests/libqos/i2c.o
  CC      tests/libqos/malloc.o
  CC      tests/libqos/libqos.o
  CC      tests/libqos/malloc-spapr.o
  CC      tests/libqos/libqos-spapr.o
  CC      tests/libqos/rtas.o
  CC      tests/libqos/pci-spapr.o
  CC      tests/libqos/pci-pc.o
  CC      tests/libqos/malloc-pc.o
  CC      tests/libqos/libqos-pc.o
  CC      tests/libqos/ahci.o
  CC      tests/libqos/virtio.o
  CC      tests/libqos/virtio-pci.o
  CC      tests/libqos/virtio-mmio.o
  CC      tests/libqos/malloc-generic.o
  CC      tests/endianness-test.o
  CC      tests/fdc-test.o
  CC      tests/ide-test.o
  CC      tests/ahci-test.o
  CC      tests/hd-geo-test.o
  CC      tests/boot-order-test.o
  CC      tests/bios-tables-test.o
  CC      tests/boot-sector.o
  CC      tests/acpi-utils.o
  CC      tests/pxe-test.o
  CC      tests/boot-serial-test.o
  CC      tests/rtc-test.o
  CC      tests/ipmi-kcs-test.o
  CC      tests/ipmi-bt-test.o
  CC      tests/i440fx-test.o
  CC      tests/fw_cfg-test.o
  CC      tests/drive_del-test.o
  CC      tests/wdt_ib700-test.o
  CC      tests/tco-test.o
  CC      tests/e1000-test.o
  CC      tests/e1000e-test.o
  CC      tests/rtl8139-test.o
  CC      tests/pcnet-test.o
  CC      tests/eepro100-test.o
  CC      tests/ne2000-test.o
  CC      tests/nvme-test.o
  CC      tests/ac97-test.o
  CC      tests/es1370-test.o
  CC      tests/virtio-net-test.o
  CC      tests/virtio-balloon-test.o
  CC      tests/virtio-blk-test.o
  CC      tests/virtio-rng-test.o
  CC      tests/virtio-scsi-test.o
  CC      tests/virtio-serial-test.o
  CC      tests/virtio-console-test.o
  CC      tests/tpci200-test.o
  CC      tests/ipoctal232-test.o
  CC      tests/display-vga-test.o
  CC      tests/intel-hda-test.o
  CC      tests/ivshmem-test.o
  CC      tests/megasas-test.o
  CC      tests/vmxnet3-test.o
  CC      tests/pvpanic-test.o
  CC      tests/ioh3420-test.o
  CC      tests/i82801b11-test.o
  CC      tests/usb-hcd-ohci-test.o
  CC      tests/libqos/usb.o
  CC      tests/usb-hcd-uhci-test.o
  CC      tests/usb-hcd-ehci-test.o
  CC      tests/usb-hcd-xhci-test.o
  CC      tests/q35-test.o
  CC      tests/vmgenid-test.o
  CC      tests/test-netfilter.o
  CC      tests/test-filter-mirror.o
  CC      tests/pc-cpu-test.o
  CC      tests/test-filter-redirector.o
  CC      tests/postcopy-test.o
  CC      tests/test-x86-cpuid-compat.o
  CC      tests/numa-test.o
  CC      tests/qmp-test.o
  CC      tests/device-introspect-test.o
  CC      tests/qom-test.o
  CC      tests/test-hmp.o
  CC      tests/test-sockets-proto.o
  LINK    tests/check-qdict
  LINK    tests/test-char
  LINK    tests/check-qnum
  LINK    tests/check-qstring
  LINK    tests/check-qlist
  LINK    tests/check-qnull
  LINK    tests/check-qjson
  CC      tests/test-qapi-types.o
  CC      tests/test-qapi-visit.o
  CC      tests/test-qapi-event.o
  CC      tests/test-qmp-introspect.o
  CC      tests/test-qmp-marshal.o
  LINK    tests/test-coroutine
  LINK    tests/test-visitor-serialization
  LINK    tests/test-iov
  LINK    tests/test-aio
  LINK    tests/test-aio-multithread
  LINK    tests/test-throttle
  LINK    tests/test-thread-pool
  LINK    tests/test-hbitmap
  LINK    tests/test-blockjob
  LINK    tests/test-blockjob-txn
  LINK    tests/test-x86-cpuid
  LINK    tests/test-xbzrle
  LINK    tests/test-vmstate
  LINK    tests/test-cutils
  LINK    tests/test-shift128
  LINK    tests/test-mul64
  LINK    tests/test-int128
  LINK    tests/rcutorture
  LINK    tests/test-rcu-list
  LINK    tests/test-qdist
  LINK    tests/test-qht
  LINK    tests/qht-bench
  LINK    tests/test-bitops
  LINK    tests/test-bitcnt
  LINK    tests/check-qom-interface
  LINK    tests/check-qom-proplist
  LINK    tests/test-qemu-opts
  LINK    tests/test-keyval
  LINK    tests/test-write-threshold
  LINK    tests/test-crypto-hash
  LINK    tests/test-crypto-hmac
  LINK    tests/test-crypto-cipher
  LINK    tests/test-crypto-secret
  LINK    tests/test-qga
  LINK    tests/test-timed-average
  LINK    tests/test-io-task
  LINK    tests/test-io-channel-socket
  LINK    tests/test-io-channel-file
  LINK    tests/test-io-channel-command
  LINK    tests/test-io-channel-buffer
  LINK    tests/test-base64
  LINK    tests/test-crypto-ivgen
  LINK    tests/test-crypto-afsplit
  LINK    tests/test-crypto-xts
  LINK    tests/test-crypto-block
  LINK    tests/test-logging
  LINK    tests/test-replication
  LINK    tests/test-bufferiszero
  LINK    tests/test-uuid
  LINK    tests/ptimer-test
  LINK    tests/test-qapi-util
  LINK    tests/vhost-user-test
  LINK    tests/endianness-test
  LINK    tests/fdc-test
  LINK    tests/ide-test
  LINK    tests/ahci-test
  LINK    tests/hd-geo-test
  LINK    tests/boot-order-test
  LINK    tests/bios-tables-test
  LINK    tests/boot-serial-test
  LINK    tests/pxe-test
  LINK    tests/rtc-test
  LINK    tests/ipmi-kcs-test
  LINK    tests/ipmi-bt-test
  LINK    tests/i440fx-test
  LINK    tests/fw_cfg-test
  LINK    tests/drive_del-test
  LINK    tests/wdt_ib700-test
  LINK    tests/tco-test
  LINK    tests/e1000-test
  LINK    tests/e1000e-test
  LINK    tests/rtl8139-test
  LINK    tests/pcnet-test
  LINK    tests/eepro100-test
  LINK    tests/ne2000-test
  LINK    tests/nvme-test
  LINK    tests/ac97-test
  LINK    tests/es1370-test
  LINK    tests/virtio-net-test
  LINK    tests/virtio-balloon-test
  LINK    tests/virtio-blk-test
  LINK    tests/virtio-rng-test
  LINK    tests/virtio-scsi-test
  LINK    tests/virtio-serial-test
  LINK    tests/virtio-console-test
  LINK    tests/tpci200-test
  LINK    tests/ipoctal232-test
  LINK    tests/display-vga-test
  LINK    tests/intel-hda-test
  LINK    tests/ivshmem-test
  LINK    tests/megasas-test
  LINK    tests/vmxnet3-test
  LINK    tests/pvpanic-test
  LINK    tests/i82801b11-test
  LINK    tests/ioh3420-test
  LINK    tests/usb-hcd-ohci-test
  LINK    tests/usb-hcd-uhci-test
  LINK    tests/usb-hcd-ehci-test
  LINK    tests/usb-hcd-xhci-test
  LINK    tests/pc-cpu-test
  LINK    tests/q35-test
  LINK    tests/vmgenid-test
  LINK    tests/test-netfilter
  LINK    tests/test-filter-mirror
  LINK    tests/test-filter-redirector
  LINK    tests/postcopy-test
  LINK    tests/test-x86-cpuid-compat
  LINK    tests/numa-test
  LINK    tests/qmp-test
  LINK    tests/device-introspect-test
  LINK    tests/qom-test
  LINK    tests/test-hmp
  LINK    tests/test-sockets-proto
  GTESTER tests/test-char
  GTESTER tests/check-qdict
  GTESTER tests/check-qnum
  GTESTER tests/check-qstring
  GTESTER tests/check-qlist
  GTESTER tests/check-qnull
  GTESTER tests/check-qjson
  LINK    tests/test-qobject-output-visitor
  LINK    tests/test-clone-visitor
  LINK    tests/test-qobject-input-visitor
  LINK    tests/test-qmp-commands
  LINK    tests/test-string-input-visitor
  LINK    tests/test-string-output-visitor
  LINK    tests/test-qmp-event
  LINK    tests/test-opts-visitor
  GTESTER tests/test-coroutine
  GTESTER tests/test-visitor-serialization
  GTESTER tests/test-iov
  GTESTER tests/test-aio
  GTESTER tests/test-aio-multithread
  GTESTER tests/test-throttle
  GTESTER tests/test-thread-pool
  GTESTER tests/test-hbitmap
  GTESTER tests/test-blockjob
  GTESTER tests/test-blockjob-txn
  GTESTER tests/test-x86-cpuid
  GTESTER tests/test-xbzrle
  GTESTER tests/test-vmstate
Failed to load simple/primitive:b_1
Failed to load simple/primitive:i64_2
Failed to load simple/primitive:i32_1
Failed to load simple/primitive:i32_1
Failed to load test/with_tmp:a
Failed to load test/tmp_child_parent:f
Failed to load test/tmp_child:parent
Failed to load test/with_tmp:tmp
Failed to load test/tmp_child:diff
Failed to load test/with_tmp:tmp
Failed to load test/tmp_child:diff
Failed to load test/with_tmp:tmp
  GTESTER tests/test-cutils
  GTESTER tests/test-shift128
  GTESTER tests/test-mul64
  GTESTER tests/test-int128
  GTESTER tests/rcutorture
  GTESTER tests/test-rcu-list
  GTESTER tests/test-qdist
  GTESTER tests/test-qht
  LINK    tests/test-qht-par
  GTESTER tests/test-bitops
  GTESTER tests/test-bitcnt
  GTESTER tests/check-qom-interface
  GTESTER tests/check-qom-proplist
  GTESTER tests/test-qemu-opts
  GTESTER tests/test-keyval
  GTESTER tests/test-write-threshold
  GTESTER tests/test-crypto-hash
  GTESTER tests/test-crypto-hmac
  GTESTER tests/test-crypto-cipher
  GTESTER tests/test-crypto-secret
  GTESTER tests/test-qga
  GTESTER tests/test-timed-average
  GTESTER tests/test-io-task
  GTESTER tests/test-io-channel-socket
  GTESTER tests/test-io-channel-file
  GTESTER tests/test-io-channel-command
  GTESTER tests/test-io-channel-buffer
  GTESTER tests/test-base64
  GTESTER tests/test-crypto-ivgen
  GTESTER tests/test-crypto-afsplit
  GTESTER tests/test-crypto-xts
  GTESTER tests/test-crypto-block
  GTESTER tests/test-logging
  GTESTER tests/test-replication
  GTESTER tests/test-bufferiszero
  GTESTER tests/test-uuid
  GTESTER tests/ptimer-test
  GTESTER tests/test-qapi-util
  GTESTER check-qtest-x86_64
  GTESTER check-qtest-aarch64
  GTESTER tests/test-qobject-output-visitor
  GTESTER tests/test-clone-visitor
  GTESTER tests/test-qobject-input-visitor
  GTESTER tests/test-qmp-commands
  GTESTER tests/test-string-input-visitor
  GTESTER tests/test-string-output-visitor
  GTESTER tests/test-qmp-event
  GTESTER tests/test-opts-visitor
  GTESTER tests/test-qht-par
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize KVM: No such file or directory
qemu-system-x86_64: Back to tcg accelerator
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize KVM: No such file or directory
qemu-system-x86_64: Back to tcg accelerator
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize KVM: No such file or directory
qemu-system-x86_64: Back to tcg accelerator
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize KVM: No such file or directory
qemu-system-x86_64: Back to tcg accelerator
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize KVM: No such file or directory
qemu-system-x86_64: Back to tcg accelerator
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize KVM: No such file or directory
qemu-system-x86_64: Back to tcg accelerator
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize KVM: No such file or directory
qemu-system-x86_64: Back to tcg accelerator
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize KVM: No such file or directory
qemu-system-x86_64: Back to tcg accelerator
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize KVM: No such file or directory
qemu-system-x86_64: Back to tcg accelerator
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize KVM: No such file or directory
qemu-system-x86_64: Back to tcg accelerator
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize KVM: No such file or directory
qemu-system-x86_64: Back to tcg accelerator
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize KVM: No such file or directory
qemu-system-x86_64: Back to tcg accelerator
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize KVM: No such file or directory
qemu-system-x86_64: Back to tcg accelerator
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize KVM: No such file or directory
qemu-system-x86_64: Back to tcg accelerator
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize KVM: No such file or directory
qemu-system-x86_64: Back to tcg accelerator
**
ERROR:/tmp/qemu-test/src/tests/test-sockets-proto.c:834:test_listen: assertion failed: (data->ipv4 == 0)
GTester: last random seed: R02S6391c532507b3dba274fd7fac6f9837c
make: *** [check-qtest-aarch64] Error 1
make: *** Waiting for unfinished jobs....
Traceback (most recent call last):
  File "./tests/docker/docker.py", line 382, in <module>
    sys.exit(main())
  File "./tests/docker/docker.py", line 379, in main
    return args.cmdobj.run(args, argv)
  File "./tests/docker/docker.py", line 237, in run
    return Docker().run(argv, args.keep, quiet=args.quiet)
  File "./tests/docker/docker.py", line 205, in run
    quiet=quiet)
  File "./tests/docker/docker.py", line 123, in _do_check
    return subprocess.check_call(self._command + cmd, **kwargs)
  File "/usr/lib64/python2.7/subprocess.py", line 186, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['docker', 'run', '--label', 'com.qemu.instance.uuid=946d6db47de811e783c452540069c830', '-u', '0', '-t', '--rm', '--net=none', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=8', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/var/tmp/patchew-tester-tmp-7o1dgdzo/src/docker-src.2017-08-10-12.25.49.32618:/var/tmp/qemu:z,ro', '-v', '/root/.cache/qemu-docker-ccache:/var/tmp/ccache:z', 'qemu:centos6', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2
make[1]: *** [tests/docker/Makefile.include:139: docker-run] Error 1
make[1]: Leaving directory '/var/tmp/patchew-tester-tmp-7o1dgdzo/src'
make: *** [tests/docker/Makefile.include:168: docker-run-test-quick@centos6] Error 2

real	7m19.388s
user	0m5.307s
sys	0m1.785s
=== OUTPUT END ===

Test command exited with code: 2


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
[Qemu-devel] [PATCH 1/8] tests: add functional test validating ipv4/ipv6 address flag handling
Posted by Daniel P. Berrange, 1 week ago
The semantics around handling ipv4=on|off & ipv6=on|off are quite
subtle to understand in combination with the various hostname addresses
and backend types. Introduce a massive test matrix that launches QEMU
and validates the ability to connect a client on each protocol as
appropriate.

The test requires that the host has ability to bind to both :: and
0.0.0.0, on port 9000. If either protocol is not available, or if
something is already listening on that port the test will skip.

Although it isn't using the QTest APIs, it expects the
QTEST_QEMU_BINARY env variable to be set.

Reviewed-by: Eric Blake <eblake@redhat.com>
Tested-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 tests/.gitignore           |   1 +
 tests/Makefile.include     |   3 +
 tests/test-sockets-proto.c | 924 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 928 insertions(+)
 create mode 100644 tests/test-sockets-proto.c

diff --git a/tests/.gitignore b/tests/.gitignore
index fed0189a5a..044183f4a0 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -78,6 +78,7 @@ test-qobject-output-visitor
 test-rcu-list
 test-replication
 test-shift128
+test-sockets-proto
 test-string-input-visitor
 test-string-output-visitor
 test-thread-pool
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 59e536bf0b..8caa5a7ae8 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -340,6 +340,7 @@ check-qtest-s390x-y = tests/boot-serial-test$(EXESUF)
 
 check-qtest-generic-y += tests/qom-test$(EXESUF)
 check-qtest-generic-y += tests/test-hmp$(EXESUF)
+check-qtest-generic-y += tests/test-sockets-proto$(EXESUF)
 
 qapi-schema += alternate-any.json
 qapi-schema += alternate-array.json
@@ -750,6 +751,8 @@ tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-usb-obj-y)
 tests/usb-hcd-xhci-test$(EXESUF): tests/usb-hcd-xhci-test.o $(libqos-usb-obj-y)
 tests/pc-cpu-test$(EXESUF): tests/pc-cpu-test.o
 tests/postcopy-test$(EXESUF): tests/postcopy-test.o
+tests/test-sockets-proto$(EXESUF): tests/test-sockets-proto.o \
+	$(test-io-obj-y)
 tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o $(test-util-obj-y) \
 	$(qtest-obj-y) $(test-io-obj-y) $(libqos-virtio-obj-y) $(libqos-pc-obj-y) \
 	$(chardev-obj-y)
diff --git a/tests/test-sockets-proto.c b/tests/test-sockets-proto.c
new file mode 100644
index 0000000000..1d6beda59f
--- /dev/null
+++ b/tests/test-sockets-proto.c
@@ -0,0 +1,924 @@
+/*
+ * QTest for IPv4/IPv6 protocol setup
+ *
+ * Copyright (c) 2017 Red Hat, Inc.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "qemu/osdep.h"
+
+#include "io/channel-socket.h"
+#include "qapi/error.h"
+#include "qemu/cutils.h"
+
+typedef struct {
+    const char *name;
+    const char *args;
+    int ipv4; /* 0 -> disabled, 1 -> enabled */
+    int ipv6; /* 0 -> disabled, 1 -> enabled, -1 -> check getaddrinfo() order */
+    bool error;
+} QSocketsData;
+
+/*
+ * This is the giant matrix of combinations we need to consider.
+ * There are 3 axes we deal with
+ *
+ * Axis 1: Protocol flags:
+ *
+ *  ipv4=unset, ipv6=unset  -> v4 & v6 clients ([1]
+ *  ipv4=unset, ipv6=off    -> v4 clients only
+ *  ipv4=unset, ipv6=on     -> v6 clients only
+ *  ipv4=off, ipv6=unset    -> v6 clients only
+ *  ipv4=off, ipv6=off      -> error - can't disable both [2]
+ *  ipv4=off, ipv6=on       -> v6 clients only
+ *  ipv4=on, ipv6=unset     -> v4 clients only
+ *  ipv4=on, ipv6=off       -> v4 clients only
+ *  ipv4=on, ipv6=on        -> v4 & v6 clients [3]
+ *
+ * Depending on the listening address, some of those combinations
+ * may result in errors. eg ipv4=off,ipv6=on combined with 0.0.0.0
+ * is nonsensical.
+ *
+ * [1] Some backends only support a single socket listener, so
+ *     will actually only allow v4 clients
+ * [2] QEMU should fail to startup in this case
+ * [3] If hostname is "" or "::", then we get a single listener
+ *     on IPv6 and thus can also accept v4 clients. For all other
+ *     hostnames, have same problem as [1].
+ *
+ * Axis 2: Listening address:
+ *
+ *  ""        - resolves to 0.0.0.0 and ::, in that order
+ *  "0.0.0.0" - v4 clients only
+ *  "::"      - Mostly v6 clients only. Some scenarios should
+ *              permit v4 clients too.
+ *
+ * Axis 3: Backend type:
+ *
+ *  Migration - restricted to a single listener. Also relies
+ *              on buggy inet_parse() which can't accept
+ *              =off/=on parameters to ipv4/ipv6 flags
+ *  Chardevs  - restricted to a single listener.
+ *  VNC       - supports multiple listeners. Also supports
+ *              socket ranges, so has extra set of tests
+ *              in the matrix
+ *
+ */
+static QSocketsData test_data[] = {
+    /* Migrate with "" address */
+    /* XXX all settings with =off are disabled due to inet_parse() bug */
+    /* XXX multilistener bug - should be .ipv6 = 1 */
+    { .ipv4 = 1, .ipv6 = -1, .error = false,
+      .name = "/sockets/migrate/wildcard/all",
+      .args = "-incoming tcp::9000" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/migrate/wildcard/ipv4",
+      .args = "-incoming tcp::9000,ipv4" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/migrate/wildcard/ipv6",
+      .args = "-incoming tcp::9000,ipv6" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/migrate/wildcard/ipv4on",
+      .args = "-incoming tcp::9000,ipv4=on" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/migrate/wildcard/ipv6on",
+      .args = "-incoming tcp::9000,ipv6=on" },
+    /*
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/migrate/wildcard/ipv4off",
+      .args = "-incoming tcp::9000,ipv4=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/migrate/wildcard/ipv6off",
+      .args = "-incoming tcp::9000,ipv6=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/migrate/wildcard/ipv4onipv6off",
+      .args = "-incoming tcp::9000,ipv4=on,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/migrate/wildcard/ipv4offipv6on",
+      .args = "-incoming tcp::9000,ipv4=off,ipv6=on" },
+    */
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
+      .name = "/sockets/migrate/wildcard/ipv4onipv6on",
+      .args = "-incoming tcp::9000,ipv4=on,ipv6=on" },
+    /*
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/migrate/wildcard/ipv4offipv6off",
+      .args = "-incoming tcp::9000,ipv4=off,ipv6=off" },
+    */
+
+    /* Migrate with 0.0.0.0 address */
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/migrate/0.0.0.0/all",
+      .args = "-incoming tcp:0.0.0.0:9000" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/migrate/0.0.0.0/ipv4",
+      .args = "-incoming tcp:0.0.0.0:9000,ipv4" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/migrate/0.0.0.0/ipv6",
+      .args = "-incoming tcp:0.0.0.0:9000,ipv6" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/migrate/0.0.0.0/ipv4on",
+      .args = "-incoming tcp:0.0.0.0:9000,ipv4=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/migrate/0.0.0.0/ipv6on",
+      .args = "-incoming tcp:0.0.0.0:9000,ipv6=on" },
+    /*
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/migrate/0.0.0.0/ipv4off",
+      .args = "-incoming tcp:0.0.0.0:9000,ipv4=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/migrate/0.0.0.0/ipv6off",
+      .args = "-incoming tcp:0.0.0.0:9000,ipv6=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/migrate/0.0.0.0/ipv4onipv6off",
+      .args = "-incoming tcp:0.0.0.0:9000,ipv4=on,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/migrate/0.0.0.0/ipv4offipv6on",
+      .args = "-incoming tcp:0.0.0.0:9000,ipv4=off,ipv6=on" },
+    */
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/migrate/0.0.0.0/ipv4onipv6on",
+      .args = "-incoming tcp:0.0.0.0:9000,ipv4=on,ipv6=on" },
+    /*
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/migrate/0.0.0.0/ipv4offipv6off",
+      .args = "-incoming tcp:0.0.0.0:9000,ipv4=off,ipv6=off" },
+    */
+
+    /* Migrate with :: address */
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
+      .name = "/sockets/migrate/::/all",
+      .args = "-incoming tcp:[::]:9000" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/migrate/::/ipv4",
+      .args = "-incoming tcp:[::]:9000,ipv4" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/migrate/::/ipv6",
+      .args = "-incoming tcp:[::]:9000,ipv6" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/migrate/::/ipv4on",
+      .args = "-incoming tcp:[::]:9000,ipv4=on" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/migrate/::/ipv6on",
+      .args = "-incoming tcp:[::]:9000,ipv6=on" },
+    /*
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/migrate/::/ipv4off",
+      .args = "-incoming tcp:[::]:9000,ipv4=off" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/migrate/::/ipv6off",
+      .args = "-incoming tcp:[::]:9000,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/migrate/::/ipv4onipv6off",
+      .args = "-incoming tcp:[::]:9000,ipv4=on,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/migrate/::/ipv4offipv6on",
+      .args = "-incoming tcp:[::]:9000,ipv4=off,ipv6=on" },
+    */
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
+      .name = "/sockets/migrate/::/ipv4onipv6on",
+      .args = "-incoming tcp:[::]:9000,ipv4=on,ipv6=on" },
+    /*
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/migrate/::/ipv4offipv6off",
+      .args = "-incoming tcp:[::]:9000,ipv4=off,ipv6=off" },
+    */
+
+
+
+    /* Chardev with "" address */
+    /* XXX multilistener bug - should be .ipv6 = 1 */
+    { .ipv4 = 1, .ipv6 = -1, .error = false,
+      .name = "/sockets/chardev/wildcard/all",
+      .args = "-chardev socket,id=cdev0,host=,port=9000,server,nowait" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/chardev/wildcard/ipv4",
+      .args = "-chardev socket,id=cdev0,host=,port=9000,server,nowait,"
+              "ipv4" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/chardev/wildcard/ipv6",
+      .args = "-chardev socket,id=cdev0,host=,port=9000,server,nowait,"
+              "ipv6" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/chardev/wildcard/ipv4on",
+      .args = "-chardev socket,id=cdev0,host=,port=9000,server,nowait,"
+              "ipv4=on" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/chardev/wildcard/ipv6on",
+      .args = "-chardev socket,id=cdev0,host=,port=9000,server,nowait,"
+              "ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/chardev/wildcard/ipv4off",
+      .args = "-chardev socket,id=cdev0,host=,port=9000,server,nowait,"
+              "ipv4=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/chardev/wildcard/ipv6off",
+      .args = "-chardev socket,id=cdev0,host=,port=9000,server,nowait,"
+              "ipv6=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/chardev/wildcard/ipv4onipv6off",
+      .args = "-chardev socket,id=cdev0,host=,port=9000,server,nowait,"
+              "ipv4=on,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/chardev/wildcard/ipv4offipv6on",
+      .args = "-chardev socket,id=cdev0,host=,port=9000,server,nowait,"
+              "ipv4=off,ipv6=on" },
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
+      .name = "/sockets/chardev/wildcard/ipv4onipv6on",
+      .args = "-chardev socket,id=cdev0,host=,port=9000,server,nowait,"
+              "ipv4=on,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/chardev/wildcard/ipv4offipv6off",
+      .args = "-chardev socket,id=cdev0,host=,port=9000,server,nowait,"
+              "ipv4=off,ipv6=off" },
+
+    /* Chardev with 0.0.0.0 address */
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/chardev/0.0.0.0/all",
+      .args = "-chardev socket,id=cdev0,host=0.0.0.0,port=9000,server,nowait" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/chardev/0.0.0.0/ipv4",
+      .args = "-chardev socket,id=cdev0,host=0.0.0.0,port=9000,server,nowait,"
+              "ipv4" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/chardev/0.0.0.0/ipv6",
+      .args = "-chardev socket,id=cdev0,host=0.0.0.0,port=9000,server,nowait,"
+              "ipv6" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/chardev/0.0.0.0/ipv4on",
+      .args = "-chardev socket,id=cdev0,host=0.0.0.0,port=9000,server,nowait,"
+              "ipv4=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/chardev/0.0.0.0/ipv6on",
+      .args = "-chardev socket,id=cdev0,host=0.0.0.0,port=9000,server,nowait,"
+              "ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/chardev/0.0.0.0/ipv4off",
+      .args = "-chardev socket,id=cdev0,host=0.0.0.0,port=9000,server,nowait,"
+              "ipv4=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/chardev/0.0.0.0/ipv6off",
+      .args = "-chardev socket,id=cdev0,host=0.0.0.0,port=9000,server,nowait,"
+              "ipv6=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/chardev/0.0.0.0/ipv4onipv6off",
+      .args = "-chardev socket,id=cdev0,host=0.0.0.0,port=9000,server,nowait,"
+              "ipv4=on,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/chardev/0.0.0.0/ipv4offipv6on",
+      .args = "-chardev socket,id=cdev0,host=0.0.0.0,port=9000,server,nowait,"
+              "ipv4=off,ipv6=on" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/chardev/0.0.0.0/ipv4onipv6on",
+      .args = "-chardev socket,id=cdev0,host=0.0.0.0,port=9000,server,nowait,"
+              "ipv4=on,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/chardev/0.0.0.0/ipv4offipv6off",
+      .args = "-chardev socket,id=cdev0,host=0.0.0.0,port=9000,server,nowait,"
+              "ipv4=off,ipv6=off" },
+
+    /* Chardev with :: address */
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
+      .name = "/sockets/chardev/::/all",
+      .args = "-chardev socket,id=cdev0,host=::,port=9000,server,nowait" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/chardev/::/ipv4",
+      .args = "-chardev socket,id=cdev0,host=::,port=9000,server,nowait,"
+              "ipv4" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/chardev/::/ipv6",
+      .args = "-chardev socket,id=cdev0,host=::,port=9000,server,nowait,"
+              "ipv6" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/chardev/::/ipv4on",
+      .args = "-chardev socket,id=cdev0,host=::,port=9000,server,nowait,"
+              "ipv4=on" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/chardev/::/ipv6on",
+      .args = "-chardev socket,id=cdev0,host=::,port=9000,server,nowait,"
+              "ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/chardev/::/ipv4off",
+      .args = "-chardev socket,id=cdev0,host=::,port=9000,server,nowait,"
+              "ipv4=off" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/chardev/::/ipv6off",
+      .args = "-chardev socket,id=cdev0,host=::,port=9000,server,nowait,"
+              "ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/chardev/::/ipv4onipv6off",
+      .args = "-chardev socket,id=cdev0,host=::,port=9000,server,nowait,"
+              "ipv4=on,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/chardev/::/ipv4offipv6on",
+      .args = "-chardev socket,id=cdev0,host=::,port=9000,server,nowait,"
+              "ipv4=off,ipv6=on" },
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
+      .name = "/sockets/chardev/::/ipv4onipv6on",
+      .args = "-chardev socket,id=cdev0,host=::,port=9000,server,nowait,"
+              "ipv4=on,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/chardev/::/ipv4offipv6off",
+      .args = "-chardev socket,id=cdev0,host=::,port=9000,server,nowait,"
+              "ipv4=off,ipv6=off" },
+
+
+
+    /* Net with "" address */
+    /* XXX does not yet support ipv4/ipv6 flags at all */
+    /* XXX multilistener bug - should be .ipv6 = 1 */
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/net/wildcard/all",
+      .args = "-netdev socket,id=net0,listen=:9000" },
+    /*
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/net/wildcard/ipv4",
+      .args = "-netdev socket,id=net0,listen=:9000,ipv4" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/net/wildcard/ipv6",
+      .args = "-netdev socket,id=net0,listen=:9000,ipv6" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/net/wildcard/ipv4on",
+      .args = "-netdev socket,id=net0,listen=:9000,ipv4=on" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/net/wildcard/ipv6on",
+      .args = "-netdev socket,id=net0,listen=:9000,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/net/wildcard/ipv4off",
+      .args = "-netdev socket,id=net0,listen=:9000,ipv4=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/net/wildcard/ipv6off",
+      .args = "-netdev socket,id=net0,listen=:9000,ipv6=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/net/wildcard/ipv4onipv6off",
+      .args = "-netdev socket,id=net0,listen=:9000,ipv4=on,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/net/wildcard/ipv4offipv6on",
+      .args = "-netdev socket,id=net0,listen=:9000,ipv4=off,ipv6=on" },
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
+      .name = "/sockets/net/wildcard/ipv4onipv6on",
+      .args = "-netdev socket,id=net0,listen=:9000,ipv4=on,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/net/wildcard/ipv4offipv6off",
+      .args = "-netdev socket,id=net0,listen=:9000,ipv4=off,ipv6=off" },
+    */
+
+    /* Net with 0.0.0.0 address */
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/net/0.0.0.0/all",
+      .args = "-netdev socket,id=net0,listen=0.0.0.0:9000" },
+    /*
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/net/0.0.0.0/ipv4",
+      .args = "-netdev socket,id=net0,listen=0.0.0.0:9000,ipv4" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/net/0.0.0.0/ipv6",
+      .args = "-netdev socket,id=net0,listen=0.0.0.0:9000,ipv6" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/net/0.0.0.0/ipv4on",
+      .args = "-netdev socket,id=net0,listen=0.0.0.0:9000,ipv4=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/net/0.0.0.0/ipv6on",
+      .args = "-netdev socket,id=net0,listen=0.0.0.0:9000,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/net/0.0.0.0/ipv4off",
+      .args = "-netdev socket,id=net0,listen=0.0.0.0:9000,ipv4=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/net/0.0.0.0/ipv6off",
+      .args = "-netdev socket,id=net0,listen=0.0.0.0:9000,ipv6=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/net/0.0.0.0/ipv4onipv6off",
+      .args = "-netdev socket,id=net0,listen=0.0.0.0:9000,ipv4=on,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/net/0.0.0.0/ipv4offipv6on",
+      .args = "-netdev socket,id=net0,listen=0.0.0.0:9000,ipv4=off,ipv6=on" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/net/0.0.0.0/ipv4onipv6on",
+      .args = "-netdev socket,id=net0,listen=0.0.0.0:9000,ipv4=on,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/net/0.0.0.0/ipv4offipv6off",
+      .args = "-netdev socket,id=net0,listen=0.0.0.0:9000,ipv4=off,ipv6=off" },
+    */
+
+    /* Net with :: address */
+    /* parse_host_port() doesn't cope with [] for IPv6 addrs
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
+      .name = "/sockets/net/::/all",
+      .args = "-netdev socket,id=net0,listen=[::]:9000" },
+    */
+    /*
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/net/::/ipv4",
+      .args = "-netdev socket,id=net0,listen=[::]:9000,ipv4" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/net/::/ipv6",
+      .args = "-netdev socket,id=net0,listen=[::]:9000,ipv6" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/net/::/ipv4on",
+      .args = "-netdev socket,id=net0,listen=[::]:9000,ipv4=on" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/net/::/ipv6on",
+      .args = "-netdev socket,id=net0,listen=[::]:9000,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/net/::/ipv4off",
+      .args = "-netdev socket,id=net0,listen=[::]:9000,ipv4=off" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/net/::/ipv6off",
+      .args = "-netdev socket,id=net0,listen=[::]:9000,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/net/::/ipv4onipv6off",
+      .args = "-netdev socket,id=net0,listen=[::]:9000,ipv4=on,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/net/::/ipv4offipv6on",
+      .args = "-netdev socket,id=net0,listen=[::]:9000,ipv4=off,ipv6=on" },
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
+      .name = "/sockets/net/::/ipv4onipv6on",
+      .args = "-netdev socket,id=net0,listen=[::]:9000,ipv4=on,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/net/::/ipv4offipv6off",
+      .args = "-netdev socket,id=net0,listen=[::]:9000,ipv4=off,ipv6=off" },
+    */
+
+
+    /* VNC with "" address */
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc/wildcard/all",
+      .args = "-vnc :3100" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc/wildcard/ipv4",
+      .args = "-vnc :3100,ipv4" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc/wildcard/ipv6",
+      .args = "-vnc :3100,ipv6" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc/wildcard/ipv4on",
+      .args = "-vnc :3100,ipv4=on" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc/wildcard/ipv6on",
+      .args = "-vnc :3100,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc/wildcard/ipv4off",
+      .args = "-vnc :3100,ipv4=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc/wildcard/ipv6off",
+      .args = "-vnc :3100,ipv6=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc/wildcard/ipv4onipv6off",
+      .args = "-vnc :3100,ipv4=on,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc/wildcard/ipv4offipv6on",
+      .args = "-vnc :3100,ipv4=off,ipv6=on" },
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc/wildcard/ipv4onipv6on",
+      .args = "-vnc :3100,ipv4=on,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc/wildcard/ipv4offipv6off",
+      .args = "-vnc :3100,ipv4=off,ipv6=off" },
+
+    /* VNC with 0.0.0.0 address */
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc/0.0.0.0/all",
+      .args = "-vnc 0.0.0.0:3100" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc/0.0.0.0/ipv4",
+      .args = "-vnc 0.0.0.0:3100,ipv4" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc/0.0.0.0/ipv6",
+      .args = "-vnc 0.0.0.0:3100,ipv6" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc/0.0.0.0/ipv4on",
+      .args = "-vnc 0.0.0.0:3100,ipv4=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc/0.0.0.0/ipv6on",
+      .args = "-vnc 0.0.0.0:3100,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc/0.0.0.0/ipv4off",
+      .args = "-vnc 0.0.0.0:3100,ipv4=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc/0.0.0.0/ipv6off",
+      .args = "-vnc 0.0.0.0:3100,ipv6=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc/0.0.0.0/ipv4onipv6off",
+      .args = "-vnc 0.0.0.0:3100,ipv4=on,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc/0.0.0.0/ipv4offipv6on",
+      .args = "-vnc 0.0.0.0:3100,ipv4=off,ipv6=on" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc/0.0.0.0/ipv4onipv6on",
+      .args = "-vnc 0.0.0.0:3100,ipv4=on,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc/0.0.0.0/ipv4offipv6off",
+      .args = "-vnc 0.0.0.0:3100,ipv4=off,ipv6=off" },
+
+    /* VNC with :: address */
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc/::/all",
+      .args = "-vnc :::3100" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc/::/ipv4",
+      .args = "-vnc :::3100,ipv4" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc/::/ipv6",
+      .args = "-vnc :::3100,ipv6" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc/::/ipv4on",
+      .args = "-vnc :::3100,ipv4=on" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc/::/ipv6on",
+      .args = "-vnc :::3100,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc/::/ipv4off",
+      .args = "-vnc :::3100,ipv4=off" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc/::/ipv6off",
+      .args = "-vnc :::3100,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc/::/ipv4onipv6off",
+      .args = "-vnc :::3100,ipv4=on,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc/::/ipv4offipv6on",
+      .args = "-vnc :::3100,ipv4=off,ipv6=on" },
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc/::/ipv4onipv6on",
+      .args = "-vnc :::3100,ipv4=on,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc/::/ipv4offipv6off",
+      .args = "-vnc :::3100,ipv4=off,ipv6=off" },
+
+
+
+    /* VNC with "" address and range */
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc-to/wildcard/all",
+      .args = "-vnc :3100,to=9005" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc-to/wildcard/ipv4",
+      .args = "-vnc :3100,to=9005,ipv4" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc-to/wildcard/ipv6",
+      .args = "-vnc :3100,to=9005,ipv6" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc-to/wildcard/ipv4on",
+      .args = "-vnc :3100,to=9005,ipv4=on" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc-to/wildcard/ipv6on",
+      .args = "-vnc :3100,to=9005,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc-to/wildcard/ipv4off",
+      .args = "-vnc :3100,to=9005,ipv4=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc-to/wildcard/ipv6off",
+      .args = "-vnc :3100,to=9005,ipv6=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc-to/wildcard/ipv4onipv6off",
+      .args = "-vnc :3100,to=9005,ipv4=on,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc-to/wildcard/ipv4offipv6on",
+      .args = "-vnc :3100,to=9005,ipv4=off,ipv6=on" },
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc-to/wildcard/ipv4onipv6on",
+      .args = "-vnc :3100,to=9005,ipv4=on,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc-to/wildcard/ipv4offipv6off",
+      .args = "-vnc :3100,to=9005,ipv4=off,ipv6=off" },
+
+    /* VNC with 0.0.0.0 address and range */
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc-to/0.0.0.0/all",
+      .args = "-vnc 0.0.0.0:3100,to=9005" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc-to/0.0.0.0/ipv4",
+      .args = "-vnc 0.0.0.0:3100,to=9005,ipv4" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc-to/0.0.0.0/ipv6",
+      .args = "-vnc 0.0.0.0:3100,to=9005,ipv6" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc-to/0.0.0.0/ipv4on",
+      .args = "-vnc 0.0.0.0:3100,to=9005,ipv4=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc-to/0.0.0.0/ipv6on",
+      .args = "-vnc 0.0.0.0:3100,to=9005,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc-to/0.0.0.0/ipv4off",
+      .args = "-vnc 0.0.0.0:3100,to=9005,ipv4=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc-to/0.0.0.0/ipv6off",
+      .args = "-vnc 0.0.0.0:3100,to=9005,ipv6=off" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc-to/0.0.0.0/ipv4onipv6off",
+      .args = "-vnc 0.0.0.0:3100,to=9005,ipv4=on,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc-to/0.0.0.0/ipv4offipv6on",
+      .args = "-vnc 0.0.0.0:3100,to=9005,ipv4=off,ipv6=on" },
+    { .ipv4 = 1, .ipv6 = 0, .error = false,
+      .name = "/sockets/vnc-to/0.0.0.0/ipv4onipv6on",
+      .args = "-vnc 0.0.0.0:3100,to=9005,ipv4=on,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc-to/0.0.0.0/ipv4offipv6off",
+      .args = "-vnc 0.0.0.0:3100,to=9005,ipv4=off,ipv6=off" },
+
+    /* VNC with :: address and range */
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc-to/::/all",
+      .args = "-vnc :::3100,to=9005" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc-to/::/ipv4",
+      .args = "-vnc :::3100,to=9005,ipv4" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc-to/::/ipv6",
+      .args = "-vnc :::3100,to=9005,ipv6" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc-to/::/ipv4on",
+      .args = "-vnc :::3100,to=9005,ipv4=on" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc-to/::/ipv6on",
+      .args = "-vnc :::3100,to=9005,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc-to/::/ipv4off",
+      .args = "-vnc :::3100,to=9005,ipv4=off" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc-to/::/ipv6off",
+      .args = "-vnc :::3100,to=9005,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc-to/::/ipv4onipv6off",
+      .args = "-vnc :::3100,to=9005,ipv4=on,ipv6=off" },
+    { .ipv4 = 0, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc-to/::/ipv4offipv6on",
+      .args = "-vnc :::3100,to=9005,ipv4=off,ipv6=on" },
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
+      .name = "/sockets/vnc-to/::/ipv4onipv6on",
+      .args = "-vnc :::3100,to=9005,ipv4=on,ipv6=on" },
+    { .ipv4 = 0, .ipv6 = 0, .error = true,
+      .name = "/sockets/vnc-to/::/ipv4offipv6off",
+      .args = "-vnc :::3100,to=9005,ipv4=off,ipv6=off" },
+};
+
+static int check_bind(const char *hostname)
+{
+    int fd = -1;
+    struct addrinfo ai, *res = NULL;
+    int rc;
+    int ret = -1;
+
+    memset(&ai, 0, sizeof(ai));
+    ai.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
+    ai.ai_family = AF_UNSPEC;
+    ai.ai_socktype = SOCK_STREAM;
+
+    /* lookup */
+    rc = getaddrinfo(hostname, "9000", &ai, &res);
+    if (rc != 0) {
+        goto cleanup;
+    }
+
+    fd = qemu_socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+    if (fd < 0) {
+        goto cleanup;
+    }
+
+    if (bind(fd, res->ai_addr, res->ai_addrlen) < 0) {
+        goto cleanup;
+    }
+
+    ret = 0;
+
+ cleanup:
+    if (fd != -1) {
+        close(fd);
+    }
+    if (res) {
+        freeaddrinfo(res);
+    }
+    return ret;
+}
+
+
+/*
+ * Validates that getaddrinfo() with a hostname of "",
+ * returns both an IPv4 and IPv6 address, and reports
+ * their order
+ *
+ * Returns:
+ *  -1: if resolving "" didn't return IPv4+IPv6 addrs
+ *   0: if IPv4 addr is first
+ *   1: if IPv6 addr is first
+ */
+static int check_resolve_order(void)
+{
+    struct addrinfo ai, *res = NULL, *e;
+    int rc;
+    int ret = -1;
+    int ipv4_idx = -1, ipv6_idx = -1;
+    int idx;
+
+    memset(&ai, 0, sizeof(ai));
+    ai.ai_flags = AI_ADDRCONFIG | AI_PASSIVE;
+    ai.ai_family = AF_UNSPEC;
+    ai.ai_socktype = SOCK_STREAM;
+
+    /* lookup */
+    rc = getaddrinfo(NULL, "9000", &ai, &res);
+    if (rc != 0) {
+        goto cleanup;
+    }
+
+    for (e = res, idx = 0; e != NULL; e = e->ai_next, idx++) {
+        if (e->ai_family == AF_INET) {
+            ipv4_idx = idx;
+        } else if (e->ai_family == AF_INET6) {
+            ipv6_idx = idx;
+        } else {
+            goto cleanup;
+        }
+    }
+
+    if (ipv4_idx == -1 || ipv6_idx == -1) {
+        goto cleanup;
+    }
+
+    if (ipv4_idx < ipv6_idx) {
+        ret = 0;
+    } else {
+        ret = 1;
+    }
+
+ cleanup:
+    if (res) {
+        freeaddrinfo(res);
+    }
+    return ret;
+}
+
+static int check_protocol_support(void)
+{
+    if (check_bind("0.0.0.0") < 0) {
+        return -1;
+    }
+    if (check_bind("::") < 0) {
+        return -1;
+    }
+
+    return check_resolve_order();
+}
+
+static pid_t run_qemu(const char *args)
+{
+    const char *pidfile = "test-sockets-proto.pid";
+    char *pidstr;
+    pid_t child;
+    int status;
+    pid_t ret;
+    const char *binary = getenv("QTEST_QEMU_BINARY");
+    long pid = 0;
+    if (binary == NULL) {
+        g_printerr("Missing QTEST_QEMU_BINARY env variable\n");
+        exit(1);
+    }
+
+    unlink(pidfile);
+    child = fork();
+    if (child == 0) {
+        setenv("QEMU_AUDIO_DRV", "none", true);
+        char *cmd = g_strdup_printf(
+            "exec %s -pidfile %s -daemonize -nodefconfig -nodefaults "
+            "-machine none -display none %s 1>/dev/null 2>&1",
+            binary, pidfile, args);
+        execlp("/bin/sh", "sh", "-c", cmd, NULL);
+        _exit(1);
+    }
+
+    do {
+        ret = waitpid(child, &status, 0);
+    } while (ret == -1 && errno == EINTR);
+
+    if (WEXITSTATUS(status) != 0) {
+        goto cleanup;
+    }
+
+    if (!g_file_get_contents(pidfile, &pidstr, NULL, NULL)) {
+        goto cleanup;
+    }
+
+    qemu_strtol(pidstr, NULL, 0, &pid);
+
+ cleanup:
+    unlink(pidfile);
+    return (pid_t)pid;
+}
+
+static void test_listen(const void *opaque)
+{
+    const QSocketsData *data = opaque;
+    QIOChannelSocket *sioc;
+    SocketAddress *saddr;
+    Error *err = NULL;
+    pid_t child;
+
+    /* First test IPv4 */
+    saddr = g_new0(SocketAddress, 1);
+    saddr->type = SOCKET_ADDRESS_TYPE_INET;
+    saddr->u.inet.host = g_strdup("127.0.0.1");
+    saddr->u.inet.port = g_strdup("9000");
+    saddr->u.inet.has_ipv4 = true;
+    saddr->u.inet.ipv4 = true;
+    saddr->u.inet.has_ipv6 = true;
+    saddr->u.inet.ipv6 = false;
+
+    child = run_qemu(data->args);
+
+    if (!child) {
+        /* QEMU failed to start, so make sure we are expecting
+         * this scenario to fail
+         */
+        g_assert(data->error);
+        goto cleanup;
+    } else {
+        g_assert(!data->error);
+    }
+
+    sioc = qio_channel_socket_new();
+    qio_channel_socket_connect_sync(sioc, saddr, &err);
+
+    if (err != NULL) {
+        /* We failed to connect to IPv4, make sure that
+         * matches the scenario expectation
+         */
+        g_assert(data->ipv4 == 0);
+        error_free(err);
+        err = NULL;
+    } else {
+        g_assert(data->ipv4 != 0);
+        object_unref(OBJECT(sioc));
+    }
+
+    kill(child, SIGKILL);
+
+
+    /* Now test IPv6 */
+    child = run_qemu(data->args);
+
+    /*
+     * The child should always succeed, because its the
+     * same config as the successful run we just did above
+     */
+    g_assert(child != 0);
+
+    g_free(saddr->u.inet.host);
+    saddr->u.inet.host = g_strdup("::1");
+    saddr->u.inet.ipv4 = false;
+    saddr->u.inet.ipv6 = true;
+
+    sioc = qio_channel_socket_new();
+    qio_channel_socket_connect_sync(sioc, saddr, &err);
+
+    if (err != NULL) {
+        /* We failed to connect to IPv6, make sure that
+         * matches the scenario expectation
+         */
+        g_assert(data->ipv6 == 0);
+        error_free(err);
+        err = NULL;
+    } else {
+        g_assert(data->ipv6 != 0);
+        object_unref(OBJECT(sioc));
+    }
+    kill(child, SIGKILL);
+
+ cleanup:
+    qapi_free_SocketAddress(saddr);
+}
+
+
+int main(int argc, char **argv)
+{
+    int ret;
+    gsize i;
+    int ipv6_first;
+
+    ipv6_first = check_protocol_support();
+    if (ipv6_first < 0) {
+        /* Skip test if we can't bind, or have unexpected
+         * results from getaddrinfo */
+         return 0;
+     }
+
+    signal(SIGPIPE, SIG_IGN);
+
+    module_call_init(MODULE_INIT_QOM);
+    g_test_init(&argc, &argv, NULL);
+
+    for (i = 0; i < G_N_ELEMENTS(test_data); i++) {
+        QSocketsData *data = &test_data[i];
+        if (data->ipv6 == -1) {
+            data->ipv6 = ipv6_first ? 1 : 0;
+        }
+        g_test_add_data_func(data->name, data, test_listen);
+    }
+
+    ret = g_test_run();
+
+    return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+}
-- 
2.13.3


[Qemu-devel] [PATCH 2/8] io: introduce a network socket listener API
Posted by Daniel P. Berrange, 1 week ago
The existing QIOChannelSocket class provides the ability to
listen on a single socket at a time. This patch introduces
a QIONetListener class that provides a higher level API
concept around listening for network services, allowing
for listening on multiple sockets.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 include/io/net-listener.h | 174 +++++++++++++++++++++++++
 io/Makefile.objs          |   1 +
 io/net-listener.c         | 315 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 490 insertions(+)
 create mode 100644 include/io/net-listener.h
 create mode 100644 io/net-listener.c

diff --git a/include/io/net-listener.h b/include/io/net-listener.h
new file mode 100644
index 0000000000..0ac5c9cc72
--- /dev/null
+++ b/include/io/net-listener.h
@@ -0,0 +1,174 @@
+/*
+ * QEMU I/O network listener
+ *
+ * Copyright (c) 2016 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef QIO_NET_LISTENER_H
+#define QIO_NET_LISTENER_H
+
+#include "io/channel-socket.h"
+
+#define TYPE_QIO_NET_LISTENER "qio-net-listener"
+#define QIO_NET_LISTENER(obj)                                    \
+    OBJECT_CHECK(QIONetListener, (obj), TYPE_QIO_NET_LISTENER)
+#define QIO_NET_LISTENER_CLASS(klass)                                    \
+    OBJECT_CLASS_CHECK(QIONetListenerClass, klass, TYPE_QIO_NET_LISTENER)
+#define QIO_NET_LISTENER_GET_CLASS(obj)                                  \
+    OBJECT_GET_CLASS(QIONetListenerClass, obj, TYPE_QIO_NET_LISTENER)
+
+typedef struct QIONetListener QIONetListener;
+typedef struct QIONetListenerClass QIONetListenerClass;
+
+typedef void (*QIONetListenerClientFunc)(QIONetListener *listener,
+                                         QIOChannelSocket *sioc,
+                                         gpointer data);
+
+/**
+ * QIONetListener:
+ *
+ * The QIONetListener object encapsulates the management of a
+ * listening socket. It is able to listen on multiple sockets
+ * concurrently, to deal with the scenario where IPv4 / IPv6
+ * needs separate sockets, or there is a need to listen on a
+ * subset of interface IP addresses, instead of the wildcard
+ * address.
+ */
+struct QIONetListener {
+    Object parent;
+
+    char *name;
+    QIOChannelSocket **sioc;
+    gulong *io_tag;
+    size_t nsioc;
+
+    gboolean disconnected;
+
+    QIONetListenerClientFunc io_func;
+    gpointer io_data;
+    GDestroyNotify io_notify;
+};
+
+struct QIONetListenerClass {
+    ObjectClass parent;
+};
+
+
+/**
+ * qio_net_listener_new:
+ *
+ * Create a new network listener service, which is not
+ * listening on any sockets initially.
+ *
+ * Returns: the new listener
+ */
+QIONetListener *qio_net_listener_new(void);
+
+
+/**
+ * qio_net_listener_set_name:
+ * @listener: the network listener object
+ * @name: the listener name
+ *
+ * Set the name of the listener. This is used as a debugging
+ * aid, to set names on any GSource instances associated
+ * with the listener
+ */
+void qio_net_listener_set_name(QIONetListener *listener,
+                               const char *name);
+
+/**
+ * qio_net_listener_open_sync:
+ * @listener: the network listener object
+ * @addr: the address to listen on
+ * @errp: pointer to a NULL initialized error object
+ *
+ * Synchronously open a listening connection on all
+ * addresses associated with @addr. This method may
+ * also be invoked multiple times, in order to have a
+ * single listener on multiple distinct addresses.
+ */
+int qio_net_listener_open_sync(QIONetListener *listener,
+                               SocketAddress *addr,
+                               Error **errp);
+
+/**
+ * qio_net_listener_add:
+ * @listener: the network listener object
+ * @sioc: the socket I/O channel
+ *
+ * Associate a listening socket I/O channel with the
+ * listener. The listener will acquire an new reference
+ * on @sioc, so the caller should release its own reference
+ * if it no longer requires the object.
+ */
+void qio_net_listener_add(QIONetListener *listener,
+                          QIOChannelSocket *sioc);
+
+/**
+ * qio_net_listener_set_client_func:
+ * @listener: the network listener object
+ * @func: the callback function
+ * @data: opaque data to pass to @func
+ * @notify: callback to free @data
+ *
+ * Register @func to be invoked whenever a new client
+ * connects to the listener. @func will be invoked
+ * passing in the QIOChannelSocket instance for the
+ * client.
+ */
+void qio_net_listener_set_client_func(QIONetListener *listener,
+                                      QIONetListenerClientFunc func,
+                                      gpointer data,
+                                      GDestroyNotify notify);
+
+/**
+ * qio_net_listener_wait_client:
+ * @listener: the network listener object
+ *
+ * Block execution of the caller until a new client arrives
+ * on one of the listening sockets. If there was previously
+ * a callback registered with qio_net_listener_set_client_func
+ * it will be temporarily disabled, and re-enabled afterwards.
+ *
+ * Returns: the new client socket
+ */
+QIOChannelSocket *qio_net_listener_wait_client(QIONetListener *listener);
+
+
+/**
+ * qio_net_listener_disconnect:
+ * @listener: the network listener object
+ *
+ * Disconnect the listener, removing all I/O callback
+ * watches and closing the socket channels.
+ */
+void qio_net_listener_disconnect(QIONetListener *listener);
+
+
+/**
+ * qio_net_listener_is_disconnected:
+ * @listener: the network listener object
+ *
+ * Determine if the listener is connected to any socket
+ * channels
+ *
+ * Returns: TRUE if connected, FALSE otherwise
+ */
+gboolean qio_net_listener_is_disconnected(QIONetListener *listener);
+
+#endif /* QIO_NET_LISTENER_H */
diff --git a/io/Makefile.objs b/io/Makefile.objs
index 12983cca79..9a20fce4ed 100644
--- a/io/Makefile.objs
+++ b/io/Makefile.objs
@@ -8,4 +8,5 @@ io-obj-y += channel-watch.o
 io-obj-y += channel-websock.o
 io-obj-y += channel-util.o
 io-obj-y += dns-resolver.o
+io-obj-y += net-listener.o
 io-obj-y += task.o
diff --git a/io/net-listener.c b/io/net-listener.c
new file mode 100644
index 0000000000..065429f6fb
--- /dev/null
+++ b/io/net-listener.c
@@ -0,0 +1,315 @@
+/*
+ * QEMU network listener
+ *
+ * Copyright (c) 2016 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "qemu/osdep.h"
+#include "io/net-listener.h"
+#include "io/dns-resolver.h"
+#include "qapi/error.h"
+
+QIONetListener *qio_net_listener_new(void)
+{
+    QIONetListener *ret;
+
+    ret = QIO_NET_LISTENER(object_new(TYPE_QIO_NET_LISTENER));
+
+    return ret;
+}
+
+void qio_net_listener_set_name(QIONetListener *listener,
+                               const char *name)
+{
+    g_free(listener->name);
+    listener->name = g_strdup(name);
+}
+
+
+static gboolean qio_net_listener_channel_func(QIOChannel *ioc,
+                                              GIOCondition condition,
+                                              gpointer opaque)
+{
+    QIONetListener *listener = QIO_NET_LISTENER(opaque);
+    QIOChannelSocket *sioc;
+
+    sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc),
+                                     NULL);
+    if (!sioc) {
+        return TRUE;
+    }
+
+    if (listener->io_func) {
+        listener->io_func(listener, sioc, listener->io_data);
+    }
+
+    object_unref(OBJECT(sioc));
+
+    return TRUE;
+}
+
+
+int qio_net_listener_open_sync(QIONetListener *listener,
+                               SocketAddress *addr,
+                               Error **errp)
+{
+    QIODNSResolver *resolver = qio_dns_resolver_get_instance();
+    SocketAddress **resaddrs;
+    size_t nresaddrs;
+    size_t i;
+    Error *err = NULL;
+    bool success = false;
+
+    if (qio_dns_resolver_lookup_sync(resolver,
+                                     addr,
+                                     &nresaddrs,
+                                     &resaddrs,
+                                     errp) < 0) {
+        return -1;
+    }
+
+    for (i = 0; i < nresaddrs; i++) {
+        QIOChannelSocket *sioc = qio_channel_socket_new();
+
+        if (qio_channel_socket_listen_sync(sioc, resaddrs[i],
+                                           err ? NULL : &err) == 0) {
+            success = true;
+        }
+
+        qio_net_listener_add(listener, sioc);
+
+        qapi_free_SocketAddress(resaddrs[i]);
+        object_unref(OBJECT(sioc));
+    }
+    g_free(resaddrs);
+
+    if (success) {
+        error_free(err);
+        return 0;
+    } else {
+        error_propagate(errp, err);
+        return -1;
+    }
+}
+
+
+void qio_net_listener_add(QIONetListener *listener,
+                          QIOChannelSocket *sioc)
+{
+    if (listener->name) {
+        char *name = g_strdup_printf("%s-listen", listener->name);
+        qio_channel_set_name(QIO_CHANNEL(sioc), name);
+        g_free(name);
+    }
+
+    listener->sioc = g_renew(QIOChannelSocket *, listener->sioc,
+                             listener->nsioc + 1);
+    listener->io_tag = g_renew(gulong, listener->io_tag, listener->nsioc + 1);
+    listener->sioc[listener->nsioc] = sioc;
+    listener->io_tag[listener->nsioc] = 0;
+
+    object_ref(OBJECT(sioc));
+    listener->disconnected = FALSE;
+
+    if (listener->io_func != NULL) {
+        object_ref(OBJECT(listener));
+        listener->io_tag[listener->nsioc] = qio_channel_add_watch(
+            QIO_CHANNEL(listener->sioc[listener->nsioc]), G_IO_IN,
+            qio_net_listener_channel_func,
+            listener, (GDestroyNotify)object_unref);
+    }
+
+    listener->nsioc++;
+}
+
+
+void qio_net_listener_set_client_func(QIONetListener *listener,
+                                      QIONetListenerClientFunc func,
+                                      gpointer data,
+                                      GDestroyNotify notify)
+{
+    size_t i;
+
+    if (listener->io_notify) {
+        listener->io_notify(listener->io_data);
+    }
+    listener->io_func = func;
+    listener->io_data = data;
+    listener->io_notify = notify;
+
+    for (i = 0; i < listener->nsioc; i++) {
+        if (listener->io_tag[i]) {
+            g_source_remove(listener->io_tag[i]);
+            listener->io_tag[i] = 0;
+        }
+    }
+
+    if (listener->io_func != NULL) {
+        for (i = 0; i < listener->nsioc; i++) {
+            object_ref(OBJECT(listener));
+            listener->io_tag[i] = qio_channel_add_watch(
+                QIO_CHANNEL(listener->sioc[i]), G_IO_IN,
+                qio_net_listener_channel_func,
+                listener, (GDestroyNotify)object_unref);
+        }
+    }
+}
+
+
+struct QIONetListenerClientWaitData {
+    QIOChannelSocket *sioc;
+    GMainLoop *loop;
+};
+
+
+static gboolean qio_net_listener_wait_client_func(QIOChannel *ioc,
+                                                  GIOCondition condition,
+                                                  gpointer opaque)
+{
+    struct QIONetListenerClientWaitData *data = opaque;
+    QIOChannelSocket *sioc;
+
+    sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc),
+                                     NULL);
+    if (!sioc) {
+        return TRUE;
+    }
+
+    if (data->sioc) {
+        object_unref(OBJECT(sioc));
+    } else {
+        data->sioc = sioc;
+        g_main_loop_quit(data->loop);
+    }
+
+    return TRUE;
+}
+
+QIOChannelSocket *qio_net_listener_wait_client(QIONetListener *listener)
+{
+    GMainContext *ctxt = g_main_context_new();
+    GMainLoop *loop = g_main_loop_new(ctxt, TRUE);
+    GSource **sources;
+    struct QIONetListenerClientWaitData data = {
+        .sioc = NULL,
+        .loop = loop
+    };
+    size_t i;
+
+    for (i = 0; i < listener->nsioc; i++) {
+        if (listener->io_tag[i]) {
+            g_source_remove(listener->io_tag[i]);
+            listener->io_tag[i] = 0;
+        }
+    }
+
+    sources = g_new0(GSource *, listener->nsioc);
+    for (i = 0; i < listener->nsioc; i++) {
+        sources[i] = qio_channel_create_watch(QIO_CHANNEL(listener->sioc[i]),
+                                              G_IO_IN);
+
+        g_source_set_callback(sources[i],
+                              (GSourceFunc)qio_net_listener_wait_client_func,
+                              &data,
+                              NULL);
+        g_source_attach(sources[i], ctxt);
+    }
+
+    g_main_loop_run(loop);
+
+    for (i = 0; i < listener->nsioc; i++) {
+        g_source_unref(sources[i]);
+    }
+    g_main_loop_unref(loop);
+    g_main_context_unref(ctxt);
+
+    if (listener->io_func != NULL) {
+        for (i = 0; i < listener->nsioc; i++) {
+            object_ref(OBJECT(listener));
+            listener->io_tag[i] = qio_channel_add_watch(
+                QIO_CHANNEL(listener->sioc[i]), G_IO_IN,
+                qio_net_listener_channel_func,
+                listener, (GDestroyNotify)object_unref);
+        }
+    }
+
+    return data.sioc;
+}
+
+void qio_net_listener_disconnect(QIONetListener *listener)
+{
+    size_t i;
+
+    if (listener->disconnected) {
+        return;
+    }
+
+    for (i = 0; i < listener->nsioc; i++) {
+        if (listener->io_tag[i]) {
+            g_source_remove(listener->io_tag[i]);
+            listener->io_tag[i] = 0;
+        }
+        qio_channel_close(QIO_CHANNEL(listener->sioc[i]), NULL);
+    }
+    listener->disconnected = TRUE;
+}
+
+
+gboolean qio_net_listener_is_disconnected(QIONetListener *listener)
+{
+    return listener->disconnected;
+}
+
+static void qio_net_listener_init(Object *obj)
+{
+    QIONetListener *listener = QIO_NET_LISTENER(obj);
+
+    listener->disconnected = TRUE;
+}
+
+static void qio_net_listener_finalize(Object *obj)
+{
+    QIONetListener *listener = QIO_NET_LISTENER(obj);
+    size_t i;
+
+    qio_net_listener_disconnect(listener);
+
+    for (i = 0; i < listener->nsioc; i++) {
+        object_unref(OBJECT(listener->sioc[i]));
+    }
+    g_free(listener->io_tag);
+    g_free(listener->sioc);
+    g_free(listener->name);
+}
+
+static const TypeInfo qio_net_listener_info = {
+    .parent = TYPE_OBJECT,
+    .name = TYPE_QIO_NET_LISTENER,
+    .instance_size = sizeof(QIONetListener),
+    .instance_finalize = qio_net_listener_finalize,
+    .instance_init = qio_net_listener_init,
+    .class_size = sizeof(QIONetListenerClass),
+};
+
+
+static void qio_net_listener_register_types(void)
+{
+    type_register_static(&qio_net_listener_info);
+}
+
+
+type_init(qio_net_listener_register_types);
-- 
2.13.3


Re: [Qemu-devel] [PATCH 2/8] io: introduce a network socket listener API
Posted by Eric Blake, 1 week ago
On 08/10/2017 11:04 AM, Daniel P. Berrange wrote:
> The existing QIOChannelSocket class provides the ability to
> listen on a single socket at a time. This patch introduces
> a QIONetListener class that provides a higher level API
> concept around listening for network services, allowing
> for listening on multiple sockets.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---

> +++ b/include/io/net-listener.h
> @@ -0,0 +1,174 @@
> +/*
> + * QEMU I/O network listener
> + *
> + * Copyright (c) 2016 Red Hat, Inc.

Want to add 2017?

At least it's covered by MAINTAINERS :)


> +/**
> + * qio_net_listener_is_disconnected:
> + * @listener: the network listener object
> + *
> + * Determine if the listener is connected to any socket
> + * channels
> + *
> + * Returns: TRUE if connected, FALSE otherwise
> + */
> +gboolean qio_net_listener_is_disconnected(QIONetListener *listener);
> +

Must it return gboolean, or is bool sufficient?

TRUE if connected for a function named 'is_disconnected' sounds
backwards.  Avoid the double negative, name it:

qio_net_listener_is_connected(), returning true if connected

> +++ b/io/net-listener.c
> @@ -0,0 +1,315 @@
> +/*
> + * QEMU network listener
> + *
> + * Copyright (c) 2016 Red Hat, Inc.

More 2017.  Probably for the whole series :)


> +static gboolean qio_net_listener_channel_func(QIOChannel *ioc,
> +                                              GIOCondition condition,
> +                                              gpointer opaque)
> +{

Again, can we use bool instead of gboolean?

> +int qio_net_listener_open_sync(QIONetListener *listener,
> +                               SocketAddress *addr,
> +                               Error **errp)
> +{
> +    QIODNSResolver *resolver = qio_dns_resolver_get_instance();
> +    SocketAddress **resaddrs;
> +    size_t nresaddrs;
> +    size_t i;
> +    Error *err = NULL;
> +    bool success = false;
> +
> +    if (qio_dns_resolver_lookup_sync(resolver,
> +                                     addr,
> +                                     &nresaddrs,
> +                                     &resaddrs,
> +                                     errp) < 0) {
> +        return -1;
> +    }
> +
> +    for (i = 0; i < nresaddrs; i++) {
> +        QIOChannelSocket *sioc = qio_channel_socket_new();
> +
> +        if (qio_channel_socket_listen_sync(sioc, resaddrs[i],
> +                                           err ? NULL : &err) == 0) {
> +            success = true;
> +        }

This says that as long as at least one address connected, we are
successful...

> +
> +        qio_net_listener_add(listener, sioc);

...but this adds sioc as a listener regardless of whether listen_sync()
succeeded.  Is that right?


> +gboolean qio_net_listener_is_disconnected(QIONetListener *listener)
> +{
> +    return listener->disconnected;

Documentation says it returns true on connected, but here you are
returning true on disconnected?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Re: [Qemu-devel] [PATCH 2/8] io: introduce a network socket listener API
Posted by Daniel P. Berrange, 1 week ago
On Thu, Aug 10, 2017 at 01:12:25PM -0500, Eric Blake wrote:
> On 08/10/2017 11:04 AM, Daniel P. Berrange wrote:
> > The existing QIOChannelSocket class provides the ability to
> > listen on a single socket at a time. This patch introduces
> > a QIONetListener class that provides a higher level API
> > concept around listening for network services, allowing
> > for listening on multiple sockets.
> > 
> > Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> > ---
> 
> > +++ b/include/io/net-listener.h
> > @@ -0,0 +1,174 @@
> > +/*
> > + * QEMU I/O network listener
> > + *
> > + * Copyright (c) 2016 Red Hat, Inc.
> 
> Want to add 2017?
> 
> At least it's covered by MAINTAINERS :)
> 
> 
> > +/**
> > + * qio_net_listener_is_disconnected:
> > + * @listener: the network listener object
> > + *
> > + * Determine if the listener is connected to any socket
> > + * channels
> > + *
> > + * Returns: TRUE if connected, FALSE otherwise
> > + */
> > +gboolean qio_net_listener_is_disconnected(QIONetListener *listener);
> > +
> 
> Must it return gboolean, or is bool sufficient?

bool is fine.

> 
> TRUE if connected for a function named 'is_disconnected' sounds
> backwards.  Avoid the double negative, name it:
> 
> qio_net_listener_is_connected(), returning true if connected

The docs are wrong, as you noticed below

> 
> > +++ b/io/net-listener.c
> > @@ -0,0 +1,315 @@
> > +/*
> > + * QEMU network listener
> > + *
> > + * Copyright (c) 2016 Red Hat, Inc.
> 
> More 2017.  Probably for the whole series :)
> 
> 
> > +static gboolean qio_net_listener_channel_func(QIOChannel *ioc,
> > +                                              GIOCondition condition,
> > +                                              gpointer opaque)
> > +{
> 
> Again, can we use bool instead of gboolean?

Yes

> > +    for (i = 0; i < nresaddrs; i++) {
> > +        QIOChannelSocket *sioc = qio_channel_socket_new();
> > +
> > +        if (qio_channel_socket_listen_sync(sioc, resaddrs[i],
> > +                                           err ? NULL : &err) == 0) {
> > +            success = true;
> > +        }
> 
> This says that as long as at least one address connected, we are
> successful...
> 
> > +
> > +        qio_net_listener_add(listener, sioc);
> 
> ...but this adds sioc as a listener regardless of whether listen_sync()
> succeeded.  Is that right?

No, it should skip the add

> 
> 
> > +gboolean qio_net_listener_is_disconnected(QIONetListener *listener)
> > +{
> > +    return listener->disconnected;
> 
> Documentation says it returns true on connected, but here you are
> returning true on disconnected?

Bad docs.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [Qemu-devel] [PATCH 2/8] io: introduce a network socket listener API
Posted by Daniel P. Berrange, 1 week ago
On Fri, Aug 11, 2017 at 10:15:04AM +0100, Daniel P. Berrange wrote:
> On Thu, Aug 10, 2017 at 01:12:25PM -0500, Eric Blake wrote:
> > On 08/10/2017 11:04 AM, Daniel P. Berrange wrote:
> > > The existing QIOChannelSocket class provides the ability to
> > > listen on a single socket at a time. This patch introduces
> > > a QIONetListener class that provides a higher level API
> > > concept around listening for network services, allowing
> > > for listening on multiple sockets.
> > > 
> > > Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> > > ---
> > 
> > > +++ b/include/io/net-listener.h
> > > @@ -0,0 +1,174 @@
> > > +/*
> > > + * QEMU I/O network listener
> > > + *
> > > + * Copyright (c) 2016 Red Hat, Inc.
> > 
> > Want to add 2017?
> > 
> > At least it's covered by MAINTAINERS :)
> > 
> > 
> > > +/**
> > > + * qio_net_listener_is_disconnected:
> > > + * @listener: the network listener object
> > > + *
> > > + * Determine if the listener is connected to any socket
> > > + * channels
> > > + *
> > > + * Returns: TRUE if connected, FALSE otherwise
> > > + */
> > > +gboolean qio_net_listener_is_disconnected(QIONetListener *listener);
> > > +
> > 
> > Must it return gboolean, or is bool sufficient?
> 
> bool is fine.
> 
> > 
> > TRUE if connected for a function named 'is_disconnected' sounds
> > backwards.  Avoid the double negative, name it:
> > 
> > qio_net_listener_is_connected(), returning true if connected
> 
> The docs are wrong, as you noticed below
> 
> > 
> > > +++ b/io/net-listener.c
> > > @@ -0,0 +1,315 @@
> > > +/*
> > > + * QEMU network listener
> > > + *
> > > + * Copyright (c) 2016 Red Hat, Inc.
> > 
> > More 2017.  Probably for the whole series :)
> > 
> > 
> > > +static gboolean qio_net_listener_channel_func(QIOChannel *ioc,
> > > +                                              GIOCondition condition,
> > > +                                              gpointer opaque)
> > > +{
> > 
> > Again, can we use bool instead of gboolean?
> 
> Yes

Opps, no, this one must be gboolean. The others can be bool though.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [Qemu-devel] [PATCH 2/8] io: introduce a network socket listener API
Posted by Dr. David Alan Gilbert, 1 week ago
* Daniel P. Berrange (berrange@redhat.com) wrote:
> The existing QIOChannelSocket class provides the ability to
> listen on a single socket at a time. This patch introduces
> a QIONetListener class that provides a higher level API
> concept around listening for network services, allowing
> for listening on multiple sockets.

What protects against a connection on more than one of the sockets?

Dave

> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  include/io/net-listener.h | 174 +++++++++++++++++++++++++
>  io/Makefile.objs          |   1 +
>  io/net-listener.c         | 315 ++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 490 insertions(+)
>  create mode 100644 include/io/net-listener.h
>  create mode 100644 io/net-listener.c
> 
> diff --git a/include/io/net-listener.h b/include/io/net-listener.h
> new file mode 100644
> index 0000000000..0ac5c9cc72
> --- /dev/null
> +++ b/include/io/net-listener.h
> @@ -0,0 +1,174 @@
> +/*
> + * QEMU I/O network listener
> + *
> + * Copyright (c) 2016 Red Hat, Inc.
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, see <http://www.gnu.org/licenses/>.
> + *
> + */
> +
> +#ifndef QIO_NET_LISTENER_H
> +#define QIO_NET_LISTENER_H
> +
> +#include "io/channel-socket.h"
> +
> +#define TYPE_QIO_NET_LISTENER "qio-net-listener"
> +#define QIO_NET_LISTENER(obj)                                    \
> +    OBJECT_CHECK(QIONetListener, (obj), TYPE_QIO_NET_LISTENER)
> +#define QIO_NET_LISTENER_CLASS(klass)                                    \
> +    OBJECT_CLASS_CHECK(QIONetListenerClass, klass, TYPE_QIO_NET_LISTENER)
> +#define QIO_NET_LISTENER_GET_CLASS(obj)                                  \
> +    OBJECT_GET_CLASS(QIONetListenerClass, obj, TYPE_QIO_NET_LISTENER)
> +
> +typedef struct QIONetListener QIONetListener;
> +typedef struct QIONetListenerClass QIONetListenerClass;
> +
> +typedef void (*QIONetListenerClientFunc)(QIONetListener *listener,
> +                                         QIOChannelSocket *sioc,
> +                                         gpointer data);
> +
> +/**
> + * QIONetListener:
> + *
> + * The QIONetListener object encapsulates the management of a
> + * listening socket. It is able to listen on multiple sockets
> + * concurrently, to deal with the scenario where IPv4 / IPv6
> + * needs separate sockets, or there is a need to listen on a
> + * subset of interface IP addresses, instead of the wildcard
> + * address.
> + */
> +struct QIONetListener {
> +    Object parent;
> +
> +    char *name;
> +    QIOChannelSocket **sioc;
> +    gulong *io_tag;
> +    size_t nsioc;
> +
> +    gboolean disconnected;
> +
> +    QIONetListenerClientFunc io_func;
> +    gpointer io_data;
> +    GDestroyNotify io_notify;
> +};
> +
> +struct QIONetListenerClass {
> +    ObjectClass parent;
> +};
> +
> +
> +/**
> + * qio_net_listener_new:
> + *
> + * Create a new network listener service, which is not
> + * listening on any sockets initially.
> + *
> + * Returns: the new listener
> + */
> +QIONetListener *qio_net_listener_new(void);
> +
> +
> +/**
> + * qio_net_listener_set_name:
> + * @listener: the network listener object
> + * @name: the listener name
> + *
> + * Set the name of the listener. This is used as a debugging
> + * aid, to set names on any GSource instances associated
> + * with the listener
> + */
> +void qio_net_listener_set_name(QIONetListener *listener,
> +                               const char *name);
> +
> +/**
> + * qio_net_listener_open_sync:
> + * @listener: the network listener object
> + * @addr: the address to listen on
> + * @errp: pointer to a NULL initialized error object
> + *
> + * Synchronously open a listening connection on all
> + * addresses associated with @addr. This method may
> + * also be invoked multiple times, in order to have a
> + * single listener on multiple distinct addresses.
> + */
> +int qio_net_listener_open_sync(QIONetListener *listener,
> +                               SocketAddress *addr,
> +                               Error **errp);
> +
> +/**
> + * qio_net_listener_add:
> + * @listener: the network listener object
> + * @sioc: the socket I/O channel
> + *
> + * Associate a listening socket I/O channel with the
> + * listener. The listener will acquire an new reference
> + * on @sioc, so the caller should release its own reference
> + * if it no longer requires the object.
> + */
> +void qio_net_listener_add(QIONetListener *listener,
> +                          QIOChannelSocket *sioc);
> +
> +/**
> + * qio_net_listener_set_client_func:
> + * @listener: the network listener object
> + * @func: the callback function
> + * @data: opaque data to pass to @func
> + * @notify: callback to free @data
> + *
> + * Register @func to be invoked whenever a new client
> + * connects to the listener. @func will be invoked
> + * passing in the QIOChannelSocket instance for the
> + * client.
> + */
> +void qio_net_listener_set_client_func(QIONetListener *listener,
> +                                      QIONetListenerClientFunc func,
> +                                      gpointer data,
> +                                      GDestroyNotify notify);
> +
> +/**
> + * qio_net_listener_wait_client:
> + * @listener: the network listener object
> + *
> + * Block execution of the caller until a new client arrives
> + * on one of the listening sockets. If there was previously
> + * a callback registered with qio_net_listener_set_client_func
> + * it will be temporarily disabled, and re-enabled afterwards.
> + *
> + * Returns: the new client socket
> + */
> +QIOChannelSocket *qio_net_listener_wait_client(QIONetListener *listener);
> +
> +
> +/**
> + * qio_net_listener_disconnect:
> + * @listener: the network listener object
> + *
> + * Disconnect the listener, removing all I/O callback
> + * watches and closing the socket channels.
> + */
> +void qio_net_listener_disconnect(QIONetListener *listener);
> +
> +
> +/**
> + * qio_net_listener_is_disconnected:
> + * @listener: the network listener object
> + *
> + * Determine if the listener is connected to any socket
> + * channels
> + *
> + * Returns: TRUE if connected, FALSE otherwise
> + */
> +gboolean qio_net_listener_is_disconnected(QIONetListener *listener);
> +
> +#endif /* QIO_NET_LISTENER_H */
> diff --git a/io/Makefile.objs b/io/Makefile.objs
> index 12983cca79..9a20fce4ed 100644
> --- a/io/Makefile.objs
> +++ b/io/Makefile.objs
> @@ -8,4 +8,5 @@ io-obj-y += channel-watch.o
>  io-obj-y += channel-websock.o
>  io-obj-y += channel-util.o
>  io-obj-y += dns-resolver.o
> +io-obj-y += net-listener.o
>  io-obj-y += task.o
> diff --git a/io/net-listener.c b/io/net-listener.c
> new file mode 100644
> index 0000000000..065429f6fb
> --- /dev/null
> +++ b/io/net-listener.c
> @@ -0,0 +1,315 @@
> +/*
> + * QEMU network listener
> + *
> + * Copyright (c) 2016 Red Hat, Inc.
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, see <http://www.gnu.org/licenses/>.
> + *
> + */
> +
> +#include "qemu/osdep.h"
> +#include "io/net-listener.h"
> +#include "io/dns-resolver.h"
> +#include "qapi/error.h"
> +
> +QIONetListener *qio_net_listener_new(void)
> +{
> +    QIONetListener *ret;
> +
> +    ret = QIO_NET_LISTENER(object_new(TYPE_QIO_NET_LISTENER));
> +
> +    return ret;
> +}
> +
> +void qio_net_listener_set_name(QIONetListener *listener,
> +                               const char *name)
> +{
> +    g_free(listener->name);
> +    listener->name = g_strdup(name);
> +}
> +
> +
> +static gboolean qio_net_listener_channel_func(QIOChannel *ioc,
> +                                              GIOCondition condition,
> +                                              gpointer opaque)
> +{
> +    QIONetListener *listener = QIO_NET_LISTENER(opaque);
> +    QIOChannelSocket *sioc;
> +
> +    sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc),
> +                                     NULL);
> +    if (!sioc) {
> +        return TRUE;
> +    }
> +
> +    if (listener->io_func) {
> +        listener->io_func(listener, sioc, listener->io_data);
> +    }
> +
> +    object_unref(OBJECT(sioc));
> +
> +    return TRUE;
> +}
> +
> +
> +int qio_net_listener_open_sync(QIONetListener *listener,
> +                               SocketAddress *addr,
> +                               Error **errp)
> +{
> +    QIODNSResolver *resolver = qio_dns_resolver_get_instance();
> +    SocketAddress **resaddrs;
> +    size_t nresaddrs;
> +    size_t i;
> +    Error *err = NULL;
> +    bool success = false;
> +
> +    if (qio_dns_resolver_lookup_sync(resolver,
> +                                     addr,
> +                                     &nresaddrs,
> +                                     &resaddrs,
> +                                     errp) < 0) {
> +        return -1;
> +    }
> +
> +    for (i = 0; i < nresaddrs; i++) {
> +        QIOChannelSocket *sioc = qio_channel_socket_new();
> +
> +        if (qio_channel_socket_listen_sync(sioc, resaddrs[i],
> +                                           err ? NULL : &err) == 0) {
> +            success = true;
> +        }
> +
> +        qio_net_listener_add(listener, sioc);
> +
> +        qapi_free_SocketAddress(resaddrs[i]);
> +        object_unref(OBJECT(sioc));
> +    }
> +    g_free(resaddrs);
> +
> +    if (success) {
> +        error_free(err);
> +        return 0;
> +    } else {
> +        error_propagate(errp, err);
> +        return -1;
> +    }
> +}
> +
> +
> +void qio_net_listener_add(QIONetListener *listener,
> +                          QIOChannelSocket *sioc)
> +{
> +    if (listener->name) {
> +        char *name = g_strdup_printf("%s-listen", listener->name);
> +        qio_channel_set_name(QIO_CHANNEL(sioc), name);
> +        g_free(name);
> +    }
> +
> +    listener->sioc = g_renew(QIOChannelSocket *, listener->sioc,
> +                             listener->nsioc + 1);
> +    listener->io_tag = g_renew(gulong, listener->io_tag, listener->nsioc + 1);
> +    listener->sioc[listener->nsioc] = sioc;
> +    listener->io_tag[listener->nsioc] = 0;
> +
> +    object_ref(OBJECT(sioc));
> +    listener->disconnected = FALSE;
> +
> +    if (listener->io_func != NULL) {
> +        object_ref(OBJECT(listener));
> +        listener->io_tag[listener->nsioc] = qio_channel_add_watch(
> +            QIO_CHANNEL(listener->sioc[listener->nsioc]), G_IO_IN,
> +            qio_net_listener_channel_func,
> +            listener, (GDestroyNotify)object_unref);
> +    }
> +
> +    listener->nsioc++;
> +}
> +
> +
> +void qio_net_listener_set_client_func(QIONetListener *listener,
> +                                      QIONetListenerClientFunc func,
> +                                      gpointer data,
> +                                      GDestroyNotify notify)
> +{
> +    size_t i;
> +
> +    if (listener->io_notify) {
> +        listener->io_notify(listener->io_data);
> +    }
> +    listener->io_func = func;
> +    listener->io_data = data;
> +    listener->io_notify = notify;
> +
> +    for (i = 0; i < listener->nsioc; i++) {
> +        if (listener->io_tag[i]) {
> +            g_source_remove(listener->io_tag[i]);
> +            listener->io_tag[i] = 0;
> +        }
> +    }
> +
> +    if (listener->io_func != NULL) {
> +        for (i = 0; i < listener->nsioc; i++) {
> +            object_ref(OBJECT(listener));
> +            listener->io_tag[i] = qio_channel_add_watch(
> +                QIO_CHANNEL(listener->sioc[i]), G_IO_IN,
> +                qio_net_listener_channel_func,
> +                listener, (GDestroyNotify)object_unref);
> +        }
> +    }
> +}
> +
> +
> +struct QIONetListenerClientWaitData {
> +    QIOChannelSocket *sioc;
> +    GMainLoop *loop;
> +};
> +
> +
> +static gboolean qio_net_listener_wait_client_func(QIOChannel *ioc,
> +                                                  GIOCondition condition,
> +                                                  gpointer opaque)
> +{
> +    struct QIONetListenerClientWaitData *data = opaque;
> +    QIOChannelSocket *sioc;
> +
> +    sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc),
> +                                     NULL);
> +    if (!sioc) {
> +        return TRUE;
> +    }
> +
> +    if (data->sioc) {
> +        object_unref(OBJECT(sioc));
> +    } else {
> +        data->sioc = sioc;
> +        g_main_loop_quit(data->loop);
> +    }
> +
> +    return TRUE;
> +}
> +
> +QIOChannelSocket *qio_net_listener_wait_client(QIONetListener *listener)
> +{
> +    GMainContext *ctxt = g_main_context_new();
> +    GMainLoop *loop = g_main_loop_new(ctxt, TRUE);
> +    GSource **sources;
> +    struct QIONetListenerClientWaitData data = {
> +        .sioc = NULL,
> +        .loop = loop
> +    };
> +    size_t i;
> +
> +    for (i = 0; i < listener->nsioc; i++) {
> +        if (listener->io_tag[i]) {
> +            g_source_remove(listener->io_tag[i]);
> +            listener->io_tag[i] = 0;
> +        }
> +    }
> +
> +    sources = g_new0(GSource *, listener->nsioc);
> +    for (i = 0; i < listener->nsioc; i++) {
> +        sources[i] = qio_channel_create_watch(QIO_CHANNEL(listener->sioc[i]),
> +                                              G_IO_IN);
> +
> +        g_source_set_callback(sources[i],
> +                              (GSourceFunc)qio_net_listener_wait_client_func,
> +                              &data,
> +                              NULL);
> +        g_source_attach(sources[i], ctxt);
> +    }
> +
> +    g_main_loop_run(loop);
> +
> +    for (i = 0; i < listener->nsioc; i++) {
> +        g_source_unref(sources[i]);
> +    }
> +    g_main_loop_unref(loop);
> +    g_main_context_unref(ctxt);
> +
> +    if (listener->io_func != NULL) {
> +        for (i = 0; i < listener->nsioc; i++) {
> +            object_ref(OBJECT(listener));
> +            listener->io_tag[i] = qio_channel_add_watch(
> +                QIO_CHANNEL(listener->sioc[i]), G_IO_IN,
> +                qio_net_listener_channel_func,
> +                listener, (GDestroyNotify)object_unref);
> +        }
> +    }
> +
> +    return data.sioc;
> +}
> +
> +void qio_net_listener_disconnect(QIONetListener *listener)
> +{
> +    size_t i;
> +
> +    if (listener->disconnected) {
> +        return;
> +    }
> +
> +    for (i = 0; i < listener->nsioc; i++) {
> +        if (listener->io_tag[i]) {
> +            g_source_remove(listener->io_tag[i]);
> +            listener->io_tag[i] = 0;
> +        }
> +        qio_channel_close(QIO_CHANNEL(listener->sioc[i]), NULL);
> +    }
> +    listener->disconnected = TRUE;
> +}
> +
> +
> +gboolean qio_net_listener_is_disconnected(QIONetListener *listener)
> +{
> +    return listener->disconnected;
> +}
> +
> +static void qio_net_listener_init(Object *obj)
> +{
> +    QIONetListener *listener = QIO_NET_LISTENER(obj);
> +
> +    listener->disconnected = TRUE;
> +}
> +
> +static void qio_net_listener_finalize(Object *obj)
> +{
> +    QIONetListener *listener = QIO_NET_LISTENER(obj);
> +    size_t i;
> +
> +    qio_net_listener_disconnect(listener);
> +
> +    for (i = 0; i < listener->nsioc; i++) {
> +        object_unref(OBJECT(listener->sioc[i]));
> +    }
> +    g_free(listener->io_tag);
> +    g_free(listener->sioc);
> +    g_free(listener->name);
> +}
> +
> +static const TypeInfo qio_net_listener_info = {
> +    .parent = TYPE_OBJECT,
> +    .name = TYPE_QIO_NET_LISTENER,
> +    .instance_size = sizeof(QIONetListener),
> +    .instance_finalize = qio_net_listener_finalize,
> +    .instance_init = qio_net_listener_init,
> +    .class_size = sizeof(QIONetListenerClass),
> +};
> +
> +
> +static void qio_net_listener_register_types(void)
> +{
> +    type_register_static(&qio_net_listener_info);
> +}
> +
> +
> +type_init(qio_net_listener_register_types);
> -- 
> 2.13.3
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

Re: [Qemu-devel] [PATCH 2/8] io: introduce a network socket listener API
Posted by Daniel P. Berrange, 1 week ago
On Fri, Aug 11, 2017 at 01:26:00PM +0100, Dr. David Alan Gilbert wrote:
> * Daniel P. Berrange (berrange@redhat.com) wrote:
> > The existing QIOChannelSocket class provides the ability to
> > listen on a single socket at a time. This patch introduces
> > a QIONetListener class that provides a higher level API
> > concept around listening for network services, allowing
> > for listening on multiple sockets.
> 
> What protects against a connection on more than one of the sockets?

That's not the responsibility of this module. If a backend only
wants to allow a single client at a time, it has to unregister
the new client callback and re-register when it is ready to
accept a new client. This aspect is no different to the existing
case of multiple clients connecting to a single listener socket.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [Qemu-devel] [PATCH 2/8] io: introduce a network socket listener API
Posted by Dr. David Alan Gilbert, 1 week ago
* Daniel P. Berrange (berrange@redhat.com) wrote:
> On Fri, Aug 11, 2017 at 01:26:00PM +0100, Dr. David Alan Gilbert wrote:
> > * Daniel P. Berrange (berrange@redhat.com) wrote:
> > > The existing QIOChannelSocket class provides the ability to
> > > listen on a single socket at a time. This patch introduces
> > > a QIONetListener class that provides a higher level API
> > > concept around listening for network services, allowing
> > > for listening on multiple sockets.
> > 
> > What protects against a connection on more than one of the sockets?
> 
> That's not the responsibility of this module. If a backend only
> wants to allow a single client at a time, it has to unregister
> the new client callback and re-register when it is ready to
> accept a new client. This aspect is no different to the existing
> case of multiple clients connecting to a single listener socket.

OK, and we guarantee that we never call accept() twice because we
make sure we do that unregister before we get back to the main loop?

Dave

> 
> Regards,
> Daniel
> -- 
> |: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org         -o-            https://fstop138.berrange.com :|
> |: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

Re: [Qemu-devel] [PATCH 2/8] io: introduce a network socket listener API
Posted by Daniel P. Berrange, 1 week ago
On Fri, Aug 11, 2017 at 01:39:43PM +0100, Dr. David Alan Gilbert wrote:
> * Daniel P. Berrange (berrange@redhat.com) wrote:
> > On Fri, Aug 11, 2017 at 01:26:00PM +0100, Dr. David Alan Gilbert wrote:
> > > * Daniel P. Berrange (berrange@redhat.com) wrote:
> > > > The existing QIOChannelSocket class provides the ability to
> > > > listen on a single socket at a time. This patch introduces
> > > > a QIONetListener class that provides a higher level API
> > > > concept around listening for network services, allowing
> > > > for listening on multiple sockets.
> > > 
> > > What protects against a connection on more than one of the sockets?
> > 
> > That's not the responsibility of this module. If a backend only
> > wants to allow a single client at a time, it has to unregister
> > the new client callback and re-register when it is ready to
> > accept a new client. This aspect is no different to the existing
> > case of multiple clients connecting to a single listener socket.
> 
> OK, and we guarantee that we never call accept() twice because we
> make sure we do that unregister before we get back to the main loop?

Yes, and even if 2 clients arrive at exactly the same time, and thus
both sockets show G_IO_IN on the same iteration of the main loop,
we check whether the new client callback is NULL, and so will just
drop the 2nd client.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

[Qemu-devel] [PATCH 3/8] blockdev: convert internal NBD server to QIONetListener
Posted by Daniel P. Berrange, 1 week ago
Instead of creating a QIOChannelSocket directly for the NBD
server socket, use a QIONetListener. This provides the ability
to listen on multiple sockets at the same time, so enables
full support for IPv4/IPv6 dual stack.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 blockdev-nbd.c | 50 ++++++++++++++++----------------------------------
 1 file changed, 16 insertions(+), 34 deletions(-)

diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 28f551a7b0..9e3c22109c 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -18,10 +18,10 @@
 #include "qmp-commands.h"
 #include "block/nbd.h"
 #include "io/channel-socket.h"
+#include "io/net-listener.h"
 
 typedef struct NBDServerData {
-    QIOChannelSocket *listen_ioc;
-    int watch;
+    QIONetListener *listener;
     QCryptoTLSCreds *tlscreds;
 } NBDServerData;
 
@@ -32,27 +32,13 @@ static void nbd_blockdev_client_closed(NBDClient *client, bool ignored)
     nbd_client_put(client);
 }
 
-static gboolean nbd_accept(QIOChannel *ioc, GIOCondition condition,
-                           gpointer opaque)
+static void nbd_accept(QIONetListener *listener, QIOChannelSocket *cioc,
+                       gpointer opaque)
 {
-    QIOChannelSocket *cioc;
-
-    if (!nbd_server) {
-        return FALSE;
-    }
-
-    cioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc),
-                                     NULL);
-    if (!cioc) {
-        return TRUE;
-    }
-
     qio_channel_set_name(QIO_CHANNEL(cioc), "nbd-server");
     nbd_client_new(NULL, cioc,
                    nbd_server->tlscreds, NULL,
                    nbd_blockdev_client_closed);
-    object_unref(OBJECT(cioc));
-    return TRUE;
 }
 
 
@@ -62,10 +48,8 @@ static void nbd_server_free(NBDServerData *server)
         return;
     }
 
-    if (server->watch != -1) {
-        g_source_remove(server->watch);
-    }
-    object_unref(OBJECT(server->listen_ioc));
+    qio_net_listener_disconnect(server->listener);
+    object_unref(OBJECT(server->listener));
     if (server->tlscreds) {
         object_unref(OBJECT(server->tlscreds));
     }
@@ -112,12 +96,12 @@ void nbd_server_start(SocketAddress *addr, const char *tls_creds,
     }
 
     nbd_server = g_new0(NBDServerData, 1);
-    nbd_server->watch = -1;
-    nbd_server->listen_ioc = qio_channel_socket_new();
-    qio_channel_set_name(QIO_CHANNEL(nbd_server->listen_ioc),
-                         "nbd-listener");
-    if (qio_channel_socket_listen_sync(
-            nbd_server->listen_ioc, addr, errp) < 0) {
+    nbd_server->listener = qio_net_listener_new();
+
+    qio_net_listener_set_name(nbd_server->listener,
+                              "nbd-listener");
+
+    if (qio_net_listener_open_sync(nbd_server->listener, addr, errp) < 0) {
         goto error;
     }
 
@@ -134,12 +118,10 @@ void nbd_server_start(SocketAddress *addr, const char *tls_creds,
         }
     }
 
-    nbd_server->watch = qio_channel_add_watch(
-        QIO_CHANNEL(nbd_server->listen_ioc),
-        G_IO_IN,
-        nbd_accept,
-        NULL,
-        NULL);
+    qio_net_listener_set_client_func(nbd_server->listener,
+                                     nbd_accept,
+                                     NULL,
+                                     NULL);
 
     return;
 
-- 
2.13.3


Re: [Qemu-devel] [PATCH 3/8] blockdev: convert internal NBD server to QIONetListener
Posted by Eric Blake, 1 week ago
On 08/10/2017 11:04 AM, Daniel P. Berrange wrote:
> Instead of creating a QIOChannelSocket directly for the NBD
> server socket, use a QIONetListener. This provides the ability
> to listen on multiple sockets at the same time, so enables
> full support for IPv4/IPv6 dual stack.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  blockdev-nbd.c | 50 ++++++++++++++++----------------------------------
>  1 file changed, 16 insertions(+), 34 deletions(-)

May need rebasing on top of other pending NBD cleanups; we'll see how
that plays out.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

[Qemu-devel] [PATCH 4/8] blockdev: convert qemu-nbd server to QIONetListener
Posted by Daniel P. Berrange, 1 week ago
Instead of creating a QIOChannelSocket directly for the NBD
server socket, use a QIONetListener. This provides the ability
to listen on multiple sockets at the same time, so enables
full support for IPv4/IPv6 dual stack.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 qemu-nbd.c | 50 +++++++++++++++++---------------------------------
 1 file changed, 17 insertions(+), 33 deletions(-)

diff --git a/qemu-nbd.c b/qemu-nbd.c
index b8666bb575..dcde7ac75c 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -38,6 +38,7 @@
 #include "qapi/qmp/qstring.h"
 #include "qom/object_interfaces.h"
 #include "io/channel-socket.h"
+#include "io/net-listener.h"
 #include "crypto/init.h"
 #include "trace/control.h"
 #include "qemu-version.h"
@@ -63,8 +64,7 @@ static int persistent = 0;
 static enum { RUNNING, TERMINATE, TERMINATING, TERMINATED } state;
 static int shared = 1;
 static int nb_fds;
-static QIOChannelSocket *server_ioc;
-static int server_watch = -1;
+static QIONetListener *server;
 static QCryptoTLSCreds *tlscreds;
 
 static void usage(const char *name)
@@ -345,44 +345,24 @@ static void nbd_client_closed(NBDClient *client, bool negotiated)
     nbd_client_put(client);
 }
 
-static gboolean nbd_accept(QIOChannel *ioc, GIOCondition cond, gpointer opaque)
+static void nbd_accept(QIONetListener *listener, QIOChannelSocket *cioc, gpointer opaque)
 {
-    QIOChannelSocket *cioc;
-
-    cioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc),
-                                     NULL);
-    if (!cioc) {
-        return TRUE;
-    }
-
     if (state >= TERMINATE) {
-        object_unref(OBJECT(cioc));
-        return TRUE;
+        return;
     }
 
     nb_fds++;
     nbd_update_server_watch();
     nbd_client_new(newproto ? NULL : exp, cioc,
                    tlscreds, NULL, nbd_client_closed);
-    object_unref(OBJECT(cioc));
-
-    return TRUE;
 }
 
 static void nbd_update_server_watch(void)
 {
     if (nbd_can_accept()) {
-        if (server_watch == -1) {
-            server_watch = qio_channel_add_watch(QIO_CHANNEL(server_ioc),
-                                                 G_IO_IN,
-                                                 nbd_accept,
-                                                 NULL, NULL);
-        }
+        qio_net_listener_set_client_func(server, nbd_accept, NULL, NULL);
     } else {
-        if (server_watch != -1) {
-            g_source_remove(server_watch);
-            server_watch = -1;
-        }
+        qio_net_listener_set_client_func(server, NULL, NULL, NULL);
     }
 }
 
@@ -917,24 +897,28 @@ int main(int argc, char **argv)
         snprintf(sockpath, 128, SOCKET_PATH, basename(device));
     }
 
+    server = qio_net_listener_new();
     if (socket_activation == 0) {
-        server_ioc = qio_channel_socket_new();
         saddr = nbd_build_socket_address(sockpath, bindto, port);
-        if (qio_channel_socket_listen_sync(server_ioc, saddr, &local_err) < 0) {
-            object_unref(OBJECT(server_ioc));
+        if (qio_net_listener_open_sync(server, saddr, &local_err) < 0) {
+            object_unref(OBJECT(server));
             error_report_err(local_err);
-            return 1;
+            exit(EXIT_FAILURE);
         }
     } else {
+        QIOChannelSocket *sioc;
         /* See comment in check_socket_activation above. */
         assert(socket_activation == 1);
-        server_ioc = qio_channel_socket_new_fd(FIRST_SOCKET_ACTIVATION_FD,
-                                               &local_err);
-        if (server_ioc == NULL) {
+        sioc = qio_channel_socket_new_fd(FIRST_SOCKET_ACTIVATION_FD,
+                                         &local_err);
+        if (sioc == NULL) {
+            object_unref(OBJECT(server));
             error_report("Failed to use socket activation: %s",
                          error_get_pretty(local_err));
             exit(EXIT_FAILURE);
         }
+        qio_net_listener_add(server, sioc);
+        object_unref(OBJECT(sioc));
     }
 
     if (qemu_init_main_loop(&local_err)) {
-- 
2.13.3


Re: [Qemu-devel] [PATCH 4/8] blockdev: convert qemu-nbd server to QIONetListener
Posted by Eric Blake, 1 week ago
On 08/10/2017 11:04 AM, Daniel P. Berrange wrote:
> Instead of creating a QIOChannelSocket directly for the NBD
> server socket, use a QIONetListener. This provides the ability
> to listen on multiple sockets at the same time, so enables
> full support for IPv4/IPv6 dual stack.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  qemu-nbd.c | 50 +++++++++++++++++---------------------------------
>  1 file changed, 17 insertions(+), 33 deletions(-)
> 
Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

[Qemu-devel] [PATCH 5/8] migration: convert socket server to QIONetListener
Posted by Daniel P. Berrange, 1 week ago
Instead of creating a QIOChannelSocket directly for the migration
server socket, use a QIONetListener. This provides the ability
to listen on multiple sockets at the same time, so enables
full support for IPv4/IPv6 dual stack.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 migration/socket.c         | 44 ++++++++++++++------------------------------
 tests/test-sockets-proto.c |  3 +--
 2 files changed, 15 insertions(+), 32 deletions(-)

diff --git a/migration/socket.c b/migration/socket.c
index 757d3821a1..34811addc5 100644
--- a/migration/socket.c
+++ b/migration/socket.c
@@ -24,6 +24,7 @@
 #include "migration.h"
 #include "qemu-file.h"
 #include "io/channel-socket.h"
+#include "io/net-listener.h"
 #include "trace.h"
 
 
@@ -130,53 +131,36 @@ void unix_start_outgoing_migration(MigrationState *s,
 }
 
 
-static gboolean socket_accept_incoming_migration(QIOChannel *ioc,
-                                                 GIOCondition condition,
-                                                 gpointer opaque)
+static void socket_accept_incoming_migration(QIONetListener *listener,
+                                             QIOChannelSocket *cioc,
+                                             gpointer opaque)
 {
-    QIOChannelSocket *sioc;
-    Error *err = NULL;
-
-    sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc),
-                                     &err);
-    if (!sioc) {
-        error_report("could not accept migration connection (%s)",
-                     error_get_pretty(err));
-        goto out;
-    }
-
     trace_migration_socket_incoming_accepted();
 
-    qio_channel_set_name(QIO_CHANNEL(sioc), "migration-socket-incoming");
-    migration_channel_process_incoming(QIO_CHANNEL(sioc));
-    object_unref(OBJECT(sioc));
+    qio_channel_set_name(QIO_CHANNEL(cioc), "migration-socket-incoming");
+    migration_channel_process_incoming(QIO_CHANNEL(cioc));
 
-out:
     /* Close listening socket as its no longer needed */
-    qio_channel_close(ioc, NULL);
-    return FALSE; /* unregister */
+    qio_net_listener_disconnect(listener);
+
+    object_unref(OBJECT(listener));
 }
 
 
 static void socket_start_incoming_migration(SocketAddress *saddr,
                                             Error **errp)
 {
-    QIOChannelSocket *listen_ioc = qio_channel_socket_new();
+    QIONetListener *listener = qio_net_listener_new();
 
-    qio_channel_set_name(QIO_CHANNEL(listen_ioc),
-                         "migration-socket-listener");
+    qio_net_listener_set_name(listener, "migration-socket-listener");
 
-    if (qio_channel_socket_listen_sync(listen_ioc, saddr, errp) < 0) {
-        object_unref(OBJECT(listen_ioc));
+    if (qio_net_listener_open_sync(listener, saddr, errp) < 0) {
+        object_unref(OBJECT(listener));
         qapi_free_SocketAddress(saddr);
         return;
     }
 
-    qio_channel_add_watch(QIO_CHANNEL(listen_ioc),
-                          G_IO_IN,
-                          socket_accept_incoming_migration,
-                          listen_ioc,
-                          (GDestroyNotify)object_unref);
+    qio_net_listener_set_client_func(listener, socket_accept_incoming_migration, NULL, NULL);
     qapi_free_SocketAddress(saddr);
 }
 
diff --git a/tests/test-sockets-proto.c b/tests/test-sockets-proto.c
index 1d6beda59f..1495369696 100644
--- a/tests/test-sockets-proto.c
+++ b/tests/test-sockets-proto.c
@@ -70,8 +70,7 @@ typedef struct {
 static QSocketsData test_data[] = {
     /* Migrate with "" address */
     /* XXX all settings with =off are disabled due to inet_parse() bug */
-    /* XXX multilistener bug - should be .ipv6 = 1 */
-    { .ipv4 = 1, .ipv6 = -1, .error = false,
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
       .name = "/sockets/migrate/wildcard/all",
       .args = "-incoming tcp::9000" },
     { .ipv4 = 1, .ipv6 = 0, .error = false,
-- 
2.13.3


[Qemu-devel] [PATCH 6/8] chardev: convert the socket server to QIONetListener
Posted by Daniel P. Berrange, 1 week ago
Instead of creating a QIOChannelSocket directly for the chardev
server socket, use a QIONetListener. This provides the ability
to listen on multiple sockets at the same time, so enables
full support for IPv4/IPv6 dual stack.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 chardev/char-socket.c      | 70 ++++++++++++++++++----------------------------
 tests/test-sockets-proto.c |  8 ++----
 2 files changed, 29 insertions(+), 49 deletions(-)

diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 1ae730a4cb..96ff2a3ff4 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -25,6 +25,7 @@
 #include "chardev/char.h"
 #include "io/channel-socket.h"
 #include "io/channel-tls.h"
+#include "io/net-listener.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "qapi/clone-visitor.h"
@@ -40,8 +41,7 @@ typedef struct {
     Chardev parent;
     QIOChannel *ioc; /* Client I/O channel */
     QIOChannelSocket *sioc; /* Client master channel */
-    QIOChannelSocket *listen_ioc;
-    guint listen_tag;
+    QIONetListener *listener;
     QCryptoTLSCreds *tls_creds;
     int connected;
     int max_size;
@@ -93,9 +93,9 @@ static void check_report_connect_error(Chardev *chr,
     qemu_chr_socket_restart_timer(chr);
 }
 
-static gboolean tcp_chr_accept(QIOChannel *chan,
-                               GIOCondition cond,
-                               void *opaque);
+static void tcp_chr_accept(QIONetListener *listener,
+                           QIOChannelSocket *cioc,
+                           void *opaque);
 
 static int tcp_chr_read_poll(void *opaque);
 static void tcp_chr_disconnect(Chardev *chr);
@@ -404,9 +404,8 @@ static void tcp_chr_disconnect(Chardev *chr)
 
     tcp_chr_free_connection(chr);
 
-    if (s->listen_ioc) {
-        s->listen_tag = qio_channel_add_watch(
-            QIO_CHANNEL(s->listen_ioc), G_IO_IN, tcp_chr_accept, chr, NULL);
+    if (s->listener) {
+        qio_net_listener_set_client_func(s->listener, tcp_chr_accept, chr, NULL);
     }
     update_disconnected_filename(s);
     qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
@@ -704,9 +703,8 @@ static int tcp_chr_new_client(Chardev *chr, QIOChannelSocket *sioc)
     if (s->do_nodelay) {
         qio_channel_set_delay(s->ioc, false);
     }
-    if (s->listen_tag) {
-        g_source_remove(s->listen_tag);
-        s->listen_tag = 0;
+    if (s->listener) {
+        qio_net_listener_set_client_func(s->listener, NULL, NULL, NULL);
     }
 
     if (s->tls_creds) {
@@ -738,24 +736,14 @@ static int tcp_chr_add_client(Chardev *chr, int fd)
     return ret;
 }
 
-static gboolean tcp_chr_accept(QIOChannel *channel,
-                               GIOCondition cond,
-                               void *opaque)
+static void tcp_chr_accept(QIONetListener *listener,
+                           QIOChannelSocket *cioc,
+                           void *opaque)
 {
     Chardev *chr = CHARDEV(opaque);
-    QIOChannelSocket *sioc;
-
-    sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(channel),
-                                     NULL);
-    if (!sioc) {
-        return TRUE;
-    }
-
-    tcp_chr_new_client(chr, sioc);
 
-    object_unref(OBJECT(sioc));
-
-    return TRUE;
+    tcp_chr_set_client_ioc_name(chr, cioc);
+    tcp_chr_new_client(chr, cioc);
 }
 
 static int tcp_chr_wait_connected(Chardev *chr, Error **errp)
@@ -769,9 +757,10 @@ static int tcp_chr_wait_connected(Chardev *chr, Error **errp)
         if (s->is_listen) {
             info_report("QEMU waiting for connection on: %s",
                         chr->filename);
-            qio_channel_set_blocking(QIO_CHANNEL(s->listen_ioc), true, NULL);
-            tcp_chr_accept(QIO_CHANNEL(s->listen_ioc), G_IO_IN, chr);
-            qio_channel_set_blocking(QIO_CHANNEL(s->listen_ioc), false, NULL);
+            sioc = qio_net_listener_wait_client(s->listener);
+            tcp_chr_set_client_ioc_name(chr, sioc);
+            tcp_chr_new_client(chr, sioc);
+            object_unref(OBJECT(sioc));
         } else {
             sioc = qio_channel_socket_new();
             tcp_chr_set_client_ioc_name(chr, sioc);
@@ -799,12 +788,9 @@ static void char_socket_finalize(Object *obj)
         s->reconnect_timer = 0;
     }
     qapi_free_SocketAddress(s->addr);
-    if (s->listen_tag) {
-        g_source_remove(s->listen_tag);
-        s->listen_tag = 0;
-    }
-    if (s->listen_ioc) {
-        object_unref(OBJECT(s->listen_ioc));
+    if (s->listener) {
+        qio_net_listener_set_client_func(s->listener, NULL, NULL, NULL);
+        object_unref(OBJECT(s->listener));
     }
     if (s->tls_creds) {
         object_unref(OBJECT(s->tls_creds));
@@ -937,29 +923,27 @@ static void qmp_chardev_open_socket(Chardev *chr,
     } else {
         if (s->is_listen) {
             char *name;
-            sioc = qio_channel_socket_new();
+            s->listener = qio_net_listener_new();
 
             name = g_strdup_printf("chardev-tcp-listener-%s", chr->label);
-            qio_channel_set_name(QIO_CHANNEL(sioc), name);
+            qio_net_listener_set_name(s->listener, name);
             g_free(name);
 
-            if (qio_channel_socket_listen_sync(sioc, s->addr, errp) < 0) {
+            if (qio_net_listener_open_sync(s->listener, s->addr, errp) < 0) {
+                object_unref(OBJECT(s->listener));
                 goto error;
             }
 
             qapi_free_SocketAddress(s->addr);
-            s->addr = socket_local_address(sioc->fd, errp);
+            s->addr = socket_local_address(s->listener->sioc[0]->fd, errp);
             update_disconnected_filename(s);
 
-            s->listen_ioc = sioc;
             if (is_waitconnect &&
                 qemu_chr_wait_connected(chr, errp) < 0) {
                 return;
             }
             if (!s->ioc) {
-                s->listen_tag = qio_channel_add_watch(
-                    QIO_CHANNEL(s->listen_ioc), G_IO_IN,
-                    tcp_chr_accept, chr, NULL);
+                qio_net_listener_set_client_func(s->listener, tcp_chr_accept, chr, NULL);
             }
         } else if (qemu_chr_wait_connected(chr, errp) < 0) {
             goto error;
diff --git a/tests/test-sockets-proto.c b/tests/test-sockets-proto.c
index 1495369696..a92389bef6 100644
--- a/tests/test-sockets-proto.c
+++ b/tests/test-sockets-proto.c
@@ -18,7 +18,7 @@ typedef struct {
     const char *name;
     const char *args;
     int ipv4; /* 0 -> disabled, 1 -> enabled */
-    int ipv6; /* 0 -> disabled, 1 -> enabled, -1 -> check getaddrinfo() order */
+    int ipv6; /* 0 -> disabled, 1 -> enabled */
     bool error;
 } QSocketsData;
 
@@ -189,8 +189,7 @@ static QSocketsData test_data[] = {
 
 
     /* Chardev with "" address */
-    /* XXX multilistener bug - should be .ipv6 = 1 */
-    { .ipv4 = 1, .ipv6 = -1, .error = false,
+    { .ipv4 = 1, .ipv6 = 1, .error = false,
       .name = "/sockets/chardev/wildcard/all",
       .args = "-chardev socket,id=cdev0,host=,port=9000,server,nowait" },
     { .ipv4 = 1, .ipv6 = 0, .error = false,
@@ -911,9 +910,6 @@ int main(int argc, char **argv)
 
     for (i = 0; i < G_N_ELEMENTS(test_data); i++) {
         QSocketsData *data = &test_data[i];
-        if (data->ipv6 == -1) {
-            data->ipv6 = ipv6_first ? 1 : 0;
-        }
         g_test_add_data_func(data->name, data, test_listen);
     }
 
-- 
2.13.3


[Qemu-devel] [PATCH 7/8] ui: convert VNC server to QIONetListener
Posted by Daniel P. Berrange, 1 week ago
The VNC server already has the ability to listen on multiple sockets.
Converting it to use the QIONetListener APIs though, will reduce the
amount of code in the VNC server and improve the clarity of what is
left.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 ui/vnc.c | 194 ++++++++++++++++++---------------------------------------------
 ui/vnc.h |   9 +--
 2 files changed, 57 insertions(+), 146 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 651cbb8606..5b78541575 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -227,12 +227,12 @@ static VncServerInfo *vnc_server_info_get(VncDisplay *vd)
     VncServerInfo *info;
     Error *err = NULL;
 
-    if (!vd->nlsock) {
+    if (!vd->listener || !vd->listener->nsioc) {
         return NULL;
     }
 
     info = g_malloc0(sizeof(*info));
-    vnc_init_basic_info_from_server_addr(vd->lsock[0],
+    vnc_init_basic_info_from_server_addr(vd->listener->sioc[0],
                                          qapi_VncServerInfo_base(info), &err);
     info->has_auth = true;
     info->auth = g_strdup(vnc_auth_name(vd));
@@ -378,7 +378,7 @@ VncInfo *qmp_query_vnc(Error **errp)
     VncDisplay *vd = vnc_display_find(NULL);
     SocketAddress *addr = NULL;
 
-    if (vd == NULL || !vd->nlsock) {
+    if (vd == NULL || !vd->listener || !vd->listener->nsioc) {
         info->enabled = false;
     } else {
         info->enabled = true;
@@ -387,11 +387,7 @@ VncInfo *qmp_query_vnc(Error **errp)
         info->has_clients = true;
         info->clients = qmp_query_client_list(vd);
 
-        if (vd->lsock == NULL) {
-            return info;
-        }
-
-        addr = qio_channel_socket_get_local_address(vd->lsock[0], errp);
+        addr = qio_channel_socket_get_local_address(vd->listener->sioc[0], errp);
         if (!addr) {
             goto out_error;
         }
@@ -571,13 +567,14 @@ VncInfo2List *qmp_query_vnc_servers(Error **errp)
             info->has_display = true;
             info->display = g_strdup(dev->id);
         }
-        for (i = 0; i < vd->nlsock; i++) {
+        for (i = 0; vd->listener != NULL && i < vd->listener->nsioc; i++) {
             info->server = qmp_query_server_entry(
-                vd->lsock[i], false, vd->auth, vd->subauth, info->server);
+                vd->listener->sioc[i], false, vd->auth, vd->subauth,
+                info->server);
         }
-        for (i = 0; i < vd->nlwebsock; i++) {
+        for (i = 0; vd->wslistener != NULL && i < vd->wslistener->nsioc; i++) {
             info->server = qmp_query_server_entry(
-                vd->lwebsock[i], true, vd->ws_auth,
+                vd->wslistener->sioc[i], true, vd->ws_auth,
                 vd->ws_subauth, info->server);
         }
 
@@ -2991,36 +2988,18 @@ void vnc_start_protocol(VncState *vs)
     qemu_add_mouse_mode_change_notifier(&vs->mouse_mode_notifier);
 }
 
-static gboolean vnc_listen_io(QIOChannel *ioc,
-                              GIOCondition condition,
-                              void *opaque)
+static void vnc_listen_io(QIONetListener *listener,
+                          QIOChannelSocket *cioc,
+                          void *opaque)
 {
     VncDisplay *vd = opaque;
-    QIOChannelSocket *sioc = NULL;
-    Error *err = NULL;
-    bool isWebsock = false;
-    size_t i;
-
-    for (i = 0; i < vd->nlwebsock; i++) {
-        if (ioc == QIO_CHANNEL(vd->lwebsock[i])) {
-            isWebsock = true;
-            break;
-        }
-    }
-
-    sioc = qio_channel_socket_accept(QIO_CHANNEL_SOCKET(ioc), &err);
-    if (sioc != NULL) {
-        qio_channel_set_name(QIO_CHANNEL(sioc),
-                             isWebsock ? "vnc-ws-server" : "vnc-server");
-        qio_channel_set_delay(QIO_CHANNEL(sioc), false);
-        vnc_connect(vd, sioc, false, isWebsock);
-        object_unref(OBJECT(sioc));
-    } else {
-        /* client probably closed connection before we got there */
-        error_free(err);
-    }
+    bool isWebsock = listener == vd->wslistener;
 
-    return TRUE;
+    qio_channel_set_name(QIO_CHANNEL(cioc),
+                         isWebsock ? "vnc-ws-server" : "vnc-server");
+    qio_channel_set_delay(QIO_CHANNEL(cioc), false);
+    vnc_connect(vd, cioc, false, isWebsock);
+    object_unref(OBJECT(cioc));
 }
 
 static const DisplayChangeListenerOps dcl_ops = {
@@ -3072,34 +3051,22 @@ void vnc_display_init(const char *id)
 
 static void vnc_display_close(VncDisplay *vd)
 {
-    size_t i;
     if (!vd) {
         return;
     }
     vd->is_unix = false;
-    for (i = 0; i < vd->nlsock; i++) {
-        if (vd->lsock_tag[i]) {
-            g_source_remove(vd->lsock_tag[i]);
-        }
-        object_unref(OBJECT(vd->lsock[i]));
+
+    if (vd->listener) {
+        qio_net_listener_disconnect(vd->listener);
+        object_unref(OBJECT(vd->listener));
     }
-    g_free(vd->lsock);
-    g_free(vd->lsock_tag);
-    vd->lsock = NULL;
-    vd->lsock_tag = NULL;
-    vd->nlsock = 0;
+    vd->listener = NULL;
 
-    for (i = 0; i < vd->nlwebsock; i++) {
-        if (vd->lwebsock_tag[i]) {
-            g_source_remove(vd->lwebsock_tag[i]);
-        }
-        object_unref(OBJECT(vd->lwebsock[i]));
+    if (vd->wslistener) {
+        qio_net_listener_disconnect(vd->wslistener);
+        object_unref(OBJECT(vd->wslistener));
     }
-    g_free(vd->lwebsock);
-    g_free(vd->lwebsock_tag);
-    vd->lwebsock = NULL;
-    vd->lwebsock_tag = NULL;
-    vd->nlwebsock = 0;
+    vd->wslistener = NULL;
 
     vd->auth = VNC_AUTH_INVALID;
     vd->subauth = VNC_AUTH_INVALID;
@@ -3151,11 +3118,11 @@ static void vnc_display_print_local_addr(VncDisplay *vd)
     SocketAddress *addr;
     Error *err = NULL;
 
-    if (!vd->nlsock) {
+    if (!vd->listener || !vd->listener->nsioc) {
         return;
     }
 
-    addr = qio_channel_socket_get_local_address(vd->lsock[0], &err);
+    addr = qio_channel_socket_get_local_address(vd->listener->sioc[0], &err);
     if (!addr) {
         return;
     }
@@ -3663,68 +3630,6 @@ static int vnc_display_connect(VncDisplay *vd,
 }
 
 
-static int vnc_display_listen_addr(VncDisplay *vd,
-                                   SocketAddress *addr,
-                                   const char *name,
-                                   QIOChannelSocket ***lsock,
-                                   guint **lsock_tag,
-                                   size_t *nlsock,
-                                   Error **errp)
-{
-    QIODNSResolver *resolver = qio_dns_resolver_get_instance();
-    SocketAddress **rawaddrs = NULL;
-    size_t nrawaddrs = 0;
-    Error *listenerr = NULL;
-    bool listening = false;
-    size_t i;
-
-    if (qio_dns_resolver_lookup_sync(resolver, addr, &nrawaddrs,
-                                     &rawaddrs, errp) < 0) {
-        return -1;
-    }
-
-    for (i = 0; i < nrawaddrs; i++) {
-        QIOChannelSocket *sioc = qio_channel_socket_new();
-
-        qio_channel_set_name(QIO_CHANNEL(sioc), name);
-        if (qio_channel_socket_listen_sync(
-                sioc, rawaddrs[i], listenerr == NULL ? &listenerr : NULL) < 0) {
-            object_unref(OBJECT(sioc));
-            continue;
-        }
-        listening = true;
-        (*nlsock)++;
-        *lsock = g_renew(QIOChannelSocket *, *lsock, *nlsock);
-        *lsock_tag = g_renew(guint, *lsock_tag, *nlsock);
-
-        (*lsock)[*nlsock - 1] = sioc;
-        (*lsock_tag)[*nlsock - 1] = 0;
-    }
-
-    for (i = 0; i < nrawaddrs; i++) {
-        qapi_free_SocketAddress(rawaddrs[i]);
-    }
-    g_free(rawaddrs);
-
-    if (listenerr) {
-        if (!listening) {
-            error_propagate(errp, listenerr);
-            return -1;
-        } else {
-            error_free(listenerr);
-        }
-    }
-
-    for (i = 0; i < *nlsock; i++) {
-        (*lsock_tag)[i] = qio_channel_add_watch(
-            QIO_CHANNEL((*lsock)[i]),
-            G_IO_IN, vnc_listen_io, vd, NULL);
-    }
-
-    return 0;
-}
-
-
 static int vnc_display_listen(VncDisplay *vd,
                               SocketAddress **saddr,
                               size_t nsaddr,
@@ -3734,25 +3639,34 @@ static int vnc_display_listen(VncDisplay *vd,
 {
     size_t i;
 
-    for (i = 0; i < nsaddr; i++) {
-        if (vnc_display_listen_addr(vd, saddr[i],
-                                    "vnc-listen",
-                                    &vd->lsock,
-                                    &vd->lsock_tag,
-                                    &vd->nlsock,
-                                    errp) < 0) {
-            return -1;
+    if (nsaddr) {
+        vd->listener = qio_net_listener_new();
+        qio_net_listener_set_name(vd->listener, "vnc-listen");
+        for (i = 0; i < nsaddr; i++) {
+            if (qio_net_listener_open_sync(vd->listener,
+                                           saddr[i],
+                                           errp) < 0)  {
+                return -1;
+            }
         }
+
+        qio_net_listener_set_client_func(vd->listener,
+                                         vnc_listen_io, vd, NULL);
     }
-    for (i = 0; i < nwsaddr; i++) {
-        if (vnc_display_listen_addr(vd, wsaddr[i],
-                                    "vnc-ws-listen",
-                                    &vd->lwebsock,
-                                    &vd->lwebsock_tag,
-                                    &vd->nlwebsock,
-                                    errp) < 0) {
-            return -1;
+
+    if (nwsaddr) {
+        vd->wslistener = qio_net_listener_new();
+        qio_net_listener_set_name(vd->wslistener, "vnc-ws-listen");
+        for (i = 0; i < nwsaddr; i++) {
+            if (qio_net_listener_open_sync(vd->wslistener,
+                                           wsaddr[i],
+                                           errp) < 0)  {
+                return -1;
+            }
         }
+
+        qio_net_listener_set_client_func(vd->wslistener,
+                                         vnc_listen_io, vd, NULL);
     }
 
     return 0;
diff --git a/ui/vnc.h b/ui/vnc.h
index 694cf32ca9..d6f685b473 100644
--- a/ui/vnc.h
+++ b/ui/vnc.h
@@ -37,6 +37,7 @@
 #include "qemu/buffer.h"
 #include "io/channel-socket.h"
 #include "io/channel-tls.h"
+#include "io/net-listener.h"
 #include <zlib.h>
 
 #include "keymaps.h"
@@ -146,12 +147,8 @@ struct VncDisplay
     int num_exclusive;
     int connections_limit;
     VncSharePolicy share_policy;
-    size_t nlsock;
-    QIOChannelSocket **lsock;
-    guint *lsock_tag;
-    size_t nlwebsock;
-    QIOChannelSocket **lwebsock;
-    guint *lwebsock_tag;
+    QIONetListener *listener;
+    QIONetListener *wslistener;
     DisplaySurface *ds;
     DisplayChangeListener dcl;
     kbd_layout_t *kbd_layout;
-- 
2.13.3


[Qemu-devel] [PATCH 8/8] sockets: fix parsing of ipv4/ipv6 opts in parse_socket_addr
Posted by Daniel P. Berrange, 1 week ago
The inet_parse() function looks for 'ipv4' and 'ipv6'
flags, but only treats them as bare bool flags. The normal
QemuOpts parsing would allow on/off values to be set too.

This updated inet_parse() so that its handling of the
'ipv4' and 'ipv6' flags matches that done by QemuOpts.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 tests/test-sockets-proto.c | 13 -------------
 util/qemu-sockets.c        | 36 ++++++++++++++++++++++++++++++++----
 2 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/tests/test-sockets-proto.c b/tests/test-sockets-proto.c
index a92389bef6..5805d2be5f 100644
--- a/tests/test-sockets-proto.c
+++ b/tests/test-sockets-proto.c
@@ -69,7 +69,6 @@ typedef struct {
  */
 static QSocketsData test_data[] = {
     /* Migrate with "" address */
-    /* XXX all settings with =off are disabled due to inet_parse() bug */
     { .ipv4 = 1, .ipv6 = 1, .error = false,
       .name = "/sockets/migrate/wildcard/all",
       .args = "-incoming tcp::9000" },
@@ -85,7 +84,6 @@ static QSocketsData test_data[] = {
     { .ipv4 = 0, .ipv6 = 1, .error = false,
       .name = "/sockets/migrate/wildcard/ipv6on",
       .args = "-incoming tcp::9000,ipv6=on" },
-    /*
     { .ipv4 = 0, .ipv6 = 1, .error = false,
       .name = "/sockets/migrate/wildcard/ipv4off",
       .args = "-incoming tcp::9000,ipv4=off" },
@@ -98,15 +96,12 @@ static QSocketsData test_data[] = {
     { .ipv4 = 0, .ipv6 = 1, .error = false,
       .name = "/sockets/migrate/wildcard/ipv4offipv6on",
       .args = "-incoming tcp::9000,ipv4=off,ipv6=on" },
-    */
     { .ipv4 = 1, .ipv6 = 1, .error = false,
       .name = "/sockets/migrate/wildcard/ipv4onipv6on",
       .args = "-incoming tcp::9000,ipv4=on,ipv6=on" },
-    /*
     { .ipv4 = 0, .ipv6 = 0, .error = true,
       .name = "/sockets/migrate/wildcard/ipv4offipv6off",
       .args = "-incoming tcp::9000,ipv4=off,ipv6=off" },
-    */
 
     /* Migrate with 0.0.0.0 address */
     { .ipv4 = 1, .ipv6 = 0, .error = false,
@@ -124,7 +119,6 @@ static QSocketsData test_data[] = {
     { .ipv4 = 0, .ipv6 = 0, .error = true,
       .name = "/sockets/migrate/0.0.0.0/ipv6on",
       .args = "-incoming tcp:0.0.0.0:9000,ipv6=on" },
-    /*
     { .ipv4 = 0, .ipv6 = 0, .error = true,
       .name = "/sockets/migrate/0.0.0.0/ipv4off",
       .args = "-incoming tcp:0.0.0.0:9000,ipv4=off" },
@@ -137,15 +131,12 @@ static QSocketsData test_data[] = {
     { .ipv4 = 0, .ipv6 = 0, .error = true,
       .name = "/sockets/migrate/0.0.0.0/ipv4offipv6on",
       .args = "-incoming tcp:0.0.0.0:9000,ipv4=off,ipv6=on" },
-    */
     { .ipv4 = 1, .ipv6 = 0, .error = false,
       .name = "/sockets/migrate/0.0.0.0/ipv4onipv6on",
       .args = "-incoming tcp:0.0.0.0:9000,ipv4=on,ipv6=on" },
-    /*
     { .ipv4 = 0, .ipv6 = 0, .error = true,
       .name = "/sockets/migrate/0.0.0.0/ipv4offipv6off",
       .args = "-incoming tcp:0.0.0.0:9000,ipv4=off,ipv6=off" },
-    */
 
     /* Migrate with :: address */
     { .ipv4 = 1, .ipv6 = 1, .error = false,
@@ -163,7 +154,6 @@ static QSocketsData test_data[] = {
     { .ipv4 = 0, .ipv6 = 1, .error = false,
       .name = "/sockets/migrate/::/ipv6on",
       .args = "-incoming tcp:[::]:9000,ipv6=on" },
-    /*
     { .ipv4 = 0, .ipv6 = 1, .error = false,
       .name = "/sockets/migrate/::/ipv4off",
       .args = "-incoming tcp:[::]:9000,ipv4=off" },
@@ -176,15 +166,12 @@ static QSocketsData test_data[] = {
     { .ipv4 = 0, .ipv6 = 1, .error = false,
       .name = "/sockets/migrate/::/ipv4offipv6on",
       .args = "-incoming tcp:[::]:9000,ipv4=off,ipv6=on" },
-    */
     { .ipv4 = 1, .ipv6 = 1, .error = false,
       .name = "/sockets/migrate/::/ipv4onipv6on",
       .args = "-incoming tcp:[::]:9000,ipv4=on,ipv6=on" },
-    /*
     { .ipv4 = 0, .ipv6 = 0, .error = true,
       .name = "/sockets/migrate/::/ipv4offipv6off",
       .args = "-incoming tcp:[::]:9000,ipv4=off,ipv6=off" },
-    */
 
 
 
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 1358c81bcc..76202949f5 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -616,6 +616,25 @@ err:
 }
 
 /* compatibility wrapper */
+static int inet_parse_flag(const char *flagname, const char *optstr, bool *val,
+                           Error **errp)
+{
+    char *end;
+    size_t len;
+
+    end = strstr(optstr, ",");
+    len = end ? end - optstr : strlen(optstr);
+    if (len == 0 || (len == 3 && strncmp(optstr, "=on", len) == 0)) {
+        *val = true;
+    } else if ((len == 4) && strncmp(optstr, "=off", len) == 0) {
+        *val = false;
+    } else {
+        error_setg(errp, "error parsing '%s' flag '%s'", flagname, optstr);
+        return -1;
+    }
+    return 0;
+}
+
 int inet_parse(InetSocketAddress *addr, const char *str, Error **errp)
 {
     const char *optstr, *h;
@@ -623,6 +642,7 @@ int inet_parse(InetSocketAddress *addr, const char *str, Error **errp)
     char port[33];
     int to;
     int pos;
+    char *begin;
 
     memset(addr, 0, sizeof(*addr));
 
@@ -664,11 +684,19 @@ int inet_parse(InetSocketAddress *addr, const char *str, Error **errp)
         addr->has_to = true;
         addr->to = to;
     }
-    if (strstr(optstr, ",ipv4")) {
-        addr->ipv4 = addr->has_ipv4 = true;
+    begin = strstr(optstr, ",ipv4");
+    if (begin) {
+        if (inet_parse_flag("ipv4", begin + 5, &addr->ipv4, errp) < 0) {
+            return -1;
+        }
+        addr->has_ipv4 = true;
     }
-    if (strstr(optstr, ",ipv6")) {
-        addr->ipv6 = addr->has_ipv6 = true;
+    begin = strstr(optstr, ",ipv6");
+    if (begin) {
+        if (inet_parse_flag("ipv6", begin + 5, &addr->ipv6, errp) < 0) {
+            return -1;
+        }
+        addr->has_ipv6 = true;
     }
     return 0;
 }
-- 
2.13.3


Re: [Qemu-devel] [PATCH 8/8] sockets: fix parsing of ipv4/ipv6 opts in parse_socket_addr
Posted by Eric Blake, 1 week ago
On 08/10/2017 11:04 AM, Daniel P. Berrange wrote:
> The inet_parse() function looks for 'ipv4' and 'ipv6'
> flags, but only treats them as bare bool flags. The normal
> QemuOpts parsing would allow on/off values to be set too.
> 
> This updated inet_parse() so that its handling of the

s/updated/updates/ ?

> 'ipv4' and 'ipv6' flags matches that done by QemuOpts.

Do we have a regression compared to any previous version, such that this
patch might be considered 2.10 material?  Offhand, though, I think it's
fine as the end of your series, waiting for 2.11.

> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  tests/test-sockets-proto.c | 13 -------------
>  util/qemu-sockets.c        | 36 ++++++++++++++++++++++++++++++++----
>  2 files changed, 32 insertions(+), 17 deletions(-)
> 

> +++ b/util/qemu-sockets.c
> @@ -616,6 +616,25 @@ err:
>  }
>  
>  /* compatibility wrapper */
> +static int inet_parse_flag(const char *flagname, const char *optstr, bool *val,
> +                           Error **errp)
> +{
> +    char *end;
> +    size_t len;
> +
> +    end = strstr(optstr, ",");

Do we need to check that we are not landing on a ',,' escape that would
make QemuOpts behave differently?  [That is, ipv4=on,,garbage should be
parsed as setting ipv4 to 'on,garbage' (which is not valid), and NOT
setting 'ipv4=on' followed by the 'garbage' or ',garbage' key - while
the key named 'garbage' would fail, there might be other key names where
the distinction matters for catching command line typos]

But if this is unrelated to QemuOpts escape parsing, it seems okay.

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Re: [Qemu-devel] [PATCH 8/8] sockets: fix parsing of ipv4/ipv6 opts in parse_socket_addr
Posted by Daniel P. Berrange, 1 week ago
On Thu, Aug 10, 2017 at 01:35:15PM -0500, Eric Blake wrote:
> On 08/10/2017 11:04 AM, Daniel P. Berrange wrote:
> > The inet_parse() function looks for 'ipv4' and 'ipv6'
> > flags, but only treats them as bare bool flags. The normal
> > QemuOpts parsing would allow on/off values to be set too.
> > 
> > This updated inet_parse() so that its handling of the
> 
> s/updated/updates/ ?
> 
> > 'ipv4' and 'ipv6' flags matches that done by QemuOpts.
> 
> Do we have a regression compared to any previous version, such that this
> patch might be considered 2.10 material?  Offhand, though, I think it's
> fine as the end of your series, waiting for 2.11.

Well this code has been like this for years, so waiting to fix
it in 2.11 isn't making our life any worse than it already
us.

The original code merely looks for a prefix so treats

   ,ipv6
   ,ipv6dumpsterfire
   ,ipv6=off
   ,ipv6=fishfood
   ,ipv6<anything>

as all meaning 'true'. The new code only treats ,ipv6 and ,ipv6=on
as meaning true, or ipv6=off as false, rejecting all others.

So yes, that is technically a regression, but IMHO it is a desirable
regression :-)

> 
> > 
> > Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> > ---
> >  tests/test-sockets-proto.c | 13 -------------
> >  util/qemu-sockets.c        | 36 ++++++++++++++++++++++++++++++++----
> >  2 files changed, 32 insertions(+), 17 deletions(-)
> > 
> 
> > +++ b/util/qemu-sockets.c
> > @@ -616,6 +616,25 @@ err:
> >  }
> >  
> >  /* compatibility wrapper */
> > +static int inet_parse_flag(const char *flagname, const char *optstr, bool *val,
> > +                           Error **errp)
> > +{
> > +    char *end;
> > +    size_t len;
> > +
> > +    end = strstr(optstr, ",");
> 
> Do we need to check that we are not landing on a ',,' escape that would
> make QemuOpts behave differently?  [That is, ipv4=on,,garbage should be
> parsed as setting ipv4 to 'on,garbage' (which is not valid), and NOT
> setting 'ipv4=on' followed by the 'garbage' or ',garbage' key - while
> the key named 'garbage' would fail, there might be other key names where
> the distinction matters for catching command line typos]
> 
> But if this is unrelated to QemuOpts escape parsing, it seems okay.

Ultimately this code should probably be converted to actually use
QemuOpts. The existing code already allows ipv4=on,,garbage but as
you point out I've not detected that case here. Should be easye
enough to fix though.

> 
> Reviewed-by: Eric Blake <eblake@redhat.com>



Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|