]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
4 years agoMerge remote-tracking branch 'remotes/berrange/tags/qcrypto-next-pull-request' into...
Peter Maydell [Fri, 27 Sep 2019 15:53:29 +0000 (16:53 +0100)]
Merge remote-tracking branch 'remotes/berrange/tags/qcrypto-next-pull-request' into staging

Refactoring of LUKS support to facilitate keyslot updates

No current functional change is expected with this series.

# gpg: Signature made Fri 27 Sep 2019 10:58:54 BST
# gpg:                using RSA key DAF3A6FDB26B62912D0E8E3FBE86EBB415104FDF
# gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>" [full]
# gpg:                 aka "Daniel P. Berrange <berrange@redhat.com>" [full]
# Primary key fingerprint: DAF3 A6FD B26B 6291 2D0E  8E3F BE86 EBB4 1510 4FDF

* remotes/berrange/tags/qcrypto-next-pull-request:
  qcrypto-luks: more rigorous header checking
  qcrypto-luks: simplify the math used for keyslot locations
  qcrypto-luks: extract store key function
  qcrypto-luks: extract check and parse header
  qcrypto-luks: extract store and load header
  qcrypto-luks: purge unused error codes from open callback
  qcrypto-luks: use the parsed encryption settings in QCryptoBlockLUKS
  qcrypto-luks: pass keyslot index rather that pointer to the keyslot
  qcrypto-luks: simplify masterkey and masterkey length
  qcrypto-luks: don't overwrite cipher_mode in header
  qcrypto-luks: rename some fields in QCryptoBlockLUKSHeader

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 years agoMerge remote-tracking branch 'remotes/stsquad/tags/pull-testing-next-260919-1' into...
Peter Maydell [Fri, 27 Sep 2019 14:43:41 +0000 (15:43 +0100)]
Merge remote-tracking branch 'remotes/stsquad/tags/pull-testing-next-260919-1' into staging

Testing updates plus alpha FP fixes:

  - fix alpha handling of FtoI overflow
  - various docker cleanups
  - fix docker.py cleanup race
  - fix podman invocation
  - tests/tcg: add float and record/replay tests
  - remove unused docker images
  - expand documentation for check-tcg

# gpg: Signature made Thu 26 Sep 2019 19:33:38 BST
# gpg:                using RSA key 6685AE99E75167BCAFC8DF35FBD0DB095A9E2A44
# gpg: Good signature from "Alex Bennée (Master Work Key) <alex.bennee@linaro.org>" [full]
# Primary key fingerprint: 6685 AE99 E751 67BC AFC8  DF35 FBD0 DB09 5A9E 2A44

* remotes/stsquad/tags/pull-testing-next-260919-1: (28 commits)
  tests/docker: remove debian-powerpc-user-cross
  docker: move tests from python2 to python3
  docker: remove unused debian-sid
  docker: remove unused debian-ports
  docker: remove 'deprecated' image definitions
  docker: remove unused debian8 partial image
  docker: remove debian8-mxe definitions
  target/i386: Fix broken build with WHPX enabled
  docs/devel: add "check-tcg" to testing.rst
  configure: preserve PKG_CONFIG for subdir builds
  tests/tcg: add simple record/replay smoke test for aarch64
  tests/tcg: add generic version of float_convs
  tests/tcg: add float_madds test to multiarch
  tests/tcg: re-enable linux-test for ppc64abi32
  tests/tcg: clean-up some comments after the de-tangling
  podman: fix command invocation
  tests/docker: reduce scary warnings by cleaning up clean up
  tests/docker: remove python2.7 from debian9-mxe
  tests/docker: fix DOCKER_PARTIAL_IMAGES
  tests/docker: add sanitizers back to clang build
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 years agoMerge remote-tracking branch 'remotes/rth/tags/pull-tcg-20190925' into staging
Peter Maydell [Fri, 27 Sep 2019 10:10:49 +0000 (11:10 +0100)]
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20190925' into staging

Fixes for TLB_BSWAP
Coversion of NOTDIRTY and ROM handling to cputlb
Followup cleanups to cputlb

# gpg: Signature made Wed 25 Sep 2019 19:41:17 BST
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [full]
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* remotes/rth/tags/pull-tcg-20190925:
  cputlb: Pass retaddr to tb_check_watchpoint
  cputlb: Pass retaddr to tb_invalidate_phys_page_fast
  cputlb: Remove tb_invalidate_phys_page_range is_cpu_write_access
  cputlb: Remove cpu->mem_io_vaddr
  cputlb: Handle TLB_NOTDIRTY in probe_access
  cputlb: Merge and move memory_notdirty_write_{prepare,complete}
  cputlb: Partially inline memory_region_section_get_iotlb
  cputlb: Move NOTDIRTY handling from I/O path to TLB path
  cputlb: Move ROM handling from I/O path to TLB path
  exec: Adjust notdirty tracing
  cputlb: Introduce TLB_BSWAP
  cputlb: Split out load/store_memop
  cputlb: Use qemu_build_not_reached in load/store_helpers
  qemu/compiler.h: Add qemu_build_not_reached
  cputlb: Disable __always_inline__ without optimization
  exec: Use TARGET_PAGE_BITS_MIN for TLB flags

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 years agotests/docker: remove debian-powerpc-user-cross
Alex Bennée [Tue, 24 Sep 2019 18:44:18 +0000 (19:44 +0100)]
tests/docker: remove debian-powerpc-user-cross

Despite our attempts in 4d26c7fef4 to keep this going it still gets in
the way of "make docker-test-build" completing because of course we
can't build a modern QEMU with the image. Let's put the thing out of
its misery and remove it.

People who really care about building on powerpc can still use the
binfmt_misc support to manually build an image (or just run the build
from pre this commit).

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
4 years agodocker: move tests from python2 to python3
John Snow [Mon, 23 Sep 2019 18:11:40 +0000 (14:11 -0400)]
docker: move tests from python2 to python3

As part of the push to drop python2 support, replace any explicit python2
dependencies with python3 versions.

For centos, python2 still exists as an implicit dependency, but by adding
python3 we will be able to build even if the configure script begins to
require python 3.5+.

Tested with centos7, fedora, ubuntu, ubuntu1804, and debian 9 (amd64).
Tested under a custom configure script that requires Python 3.5+.

the travis dockerfile is also moved to using python3, which was tested
by running `make docker-test-build@travis`, which I hope is sufficient.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20190923181140.7235-7-jsnow@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Tested-by: Cleber Rosa <crosa@redhat.com>
4 years agodocker: remove unused debian-sid
John Snow [Mon, 23 Sep 2019 18:11:39 +0000 (14:11 -0400)]
docker: remove unused debian-sid

debian-sid is listed as a partial image, so we cannot run tests against it.
Since it isn't used by any other testable image, remove it for now as it
is prone to bitrot.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20190923181140.7235-6-jsnow@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4 years agodocker: remove unused debian-ports
John Snow [Mon, 23 Sep 2019 18:11:38 +0000 (14:11 -0400)]
docker: remove unused debian-ports

debian-ports is listed as a partial image, so we cannot run tests against it.
Since it isn't used by any other testable image, remove it for now as it
is prone to bitrot.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20190923181140.7235-5-jsnow@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4 years agodocker: remove 'deprecated' image definitions
John Snow [Mon, 23 Sep 2019 18:11:37 +0000 (14:11 -0400)]
docker: remove 'deprecated' image definitions

There isn't a debian.dockerfile anymore,
so perform some ghost-busting.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20190923181140.7235-4-jsnow@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4 years agodocker: remove unused debian8 partial image
John Snow [Mon, 23 Sep 2019 18:11:36 +0000 (14:11 -0400)]
docker: remove unused debian8 partial image

debian8 partial base is also not consumed by any image, so remove it.
For QEMU's development cycle, we only support debian9 (stretch) and
debian10 (buster).

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190923181140.7235-3-jsnow@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
4 years agodocker: remove debian8-mxe definitions
John Snow [Mon, 23 Sep 2019 18:11:35 +0000 (14:11 -0400)]
docker: remove debian8-mxe definitions

We don't have a debian8-mxe dockerfile anymore.

Fixes: 67bd36beda1ae
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190923181140.7235-2-jsnow@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
4 years agotarget/i386: Fix broken build with WHPX enabled
Philippe Mathieu-Daudé [Fri, 20 Sep 2019 11:33:27 +0000 (13:33 +0200)]
target/i386: Fix broken build with WHPX enabled

The WHPX build is broken since commit 12e9493df92 which removed the
"hw/boards.h" where MachineState is declared:

  $ ./configure \
     --enable-hax --enable-whpx

  $ make x86_64-softmmu/all
  [...]
    CC      x86_64-softmmu/target/i386/whpx-all.o
  target/i386/whpx-all.c: In function 'whpx_accel_init':
  target/i386/whpx-all.c:1378:25: error: dereferencing pointer to
  incomplete type 'MachineState' {aka 'struct MachineState'}
       whpx->mem_quota = ms->ram_size;
                           ^~
  make[1]: *** [rules.mak:69: target/i386/whpx-all.o] Error 1
    CC      x86_64-softmmu/trace/generated-helpers.o
  make[1]: Target 'all' not remade because of errors.
  make: *** [Makefile:471: x86_64-softmmu/all] Error 2

Restore this header, partially reverting commit 12e9493df92.

Fixes: 12e9493df92
Reported-by: Ilias Maratos <i.maratos@gmail.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20190920113329.16787-2-philmd@redhat.com>

4 years agodocs/devel: add "check-tcg" to testing.rst
Alex Bennée [Thu, 19 Sep 2019 13:36:35 +0000 (14:36 +0100)]
docs/devel: add "check-tcg" to testing.rst

It was pointed out we haven't documented the check-tcg part of the
build system. Attempt to rectify that now.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4 years agoconfigure: preserve PKG_CONFIG for subdir builds
Alex Bennée [Thu, 19 Sep 2019 13:07:36 +0000 (14:07 +0100)]
configure: preserve PKG_CONFIG for subdir builds

The slirp sub-module complains about not being able to find the glib
library on cross-compiles because it is using the default pkg-config
tool (which isn't installed in our cross-build docker images).
Preserve PKG_CONFIG in our host config and pass it down to slirp.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4 years agotests/tcg: add simple record/replay smoke test for aarch64
Alex Bennée [Wed, 18 Sep 2019 13:31:42 +0000 (14:31 +0100)]
tests/tcg: add simple record/replay smoke test for aarch64

This adds two new tests that re-use the memory test to check basic
record replay functionality is still working. We have to define our
own runners rather than using the default pattern as we want to change
the test name but re-use the memory binary.

We declare the test binaries as PHONY as they don't really exist.

[AJB: A better test would output some sort of timer value or other
otherwise variable value so we could compare the record and replay
outputs and ensure they match]

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Pavel Dovgalyuk <dovgaluk@ispras.ru>
4 years agotests/tcg: add generic version of float_convs
Alex Bennée [Mon, 16 Sep 2019 13:50:56 +0000 (14:50 +0100)]
tests/tcg: add generic version of float_convs

This is broadly similar to the existing fcvt test for ARM but using
the generic float testing framework. We should be able to pare down
the ARM fcvt test case to purely half-precision with or without the
Alt HP provision.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4 years agotests/tcg: add float_madds test to multiarch
Alex Bennée [Fri, 13 Sep 2019 11:12:17 +0000 (12:12 +0100)]
tests/tcg: add float_madds test to multiarch

This is a generic floating point multiply and accumulate test for
single precision floating point values. I've split of the common float
functions into a helper library so additional tests can use the same
common code.

As I don't have references for all architectures I've allowed some
flexibility for tests to pass without reference files. They can be
added as we get collect them.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4 years agotests/tcg: re-enable linux-test for ppc64abi32
Alex Bennée [Mon, 16 Sep 2019 09:24:05 +0000 (10:24 +0100)]
tests/tcg: re-enable linux-test for ppc64abi32

Now we have fixed the signal delivary bug we can remove this horrible
hack from the system.

Cc: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4 years agotests/tcg: clean-up some comments after the de-tangling
Alex Bennée [Wed, 11 Sep 2019 16:49:55 +0000 (17:49 +0100)]
tests/tcg: clean-up some comments after the de-tangling

These were missed in the recent de-tangling so have been updated to be
more actuate. I've also built up ARM_TESTS in a manner similar to
AARCH64_TESTS for better consistency.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4 years agopodman: fix command invocation
John Snow [Fri, 13 Sep 2019 19:38:21 +0000 (15:38 -0400)]
podman: fix command invocation

Oops; there's no argv here.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20190913193821.17756-1-jsnow@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Tested-by: Cleber Rosa <crosa@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Tested-by: Thomas Huth <thuth@redhat.com>
4 years agotests/docker: reduce scary warnings by cleaning up clean up
Alex Bennée [Thu, 19 Sep 2019 16:51:27 +0000 (17:51 +0100)]
tests/docker: reduce scary warnings by cleaning up clean up

There was in the clean-up code caused by attempting to inspect images
which finished before we got there. Clean up the clean up code by:

  - only track the one instance at a time
  - use --filter for docker ps instead of doing it by hand
  - just call docker rm -f to be done with it
  - use uuid.uuid4() for a random uid

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4 years agotests/docker: remove python2.7 from debian9-mxe
John Snow [Wed, 18 Sep 2019 22:25:46 +0000 (18:25 -0400)]
tests/docker: remove python2.7 from debian9-mxe

When it was based on debian8 which uses python-minimal, it needed this.
It no longer does.

Goodbye, python2.7.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20190918222546.11696-1-jsnow@redhat.com>
[AJB: fixed up commit message]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4 years agotests/docker: fix DOCKER_PARTIAL_IMAGES
Alex Bennée [Mon, 16 Sep 2019 17:54:33 +0000 (18:54 +0100)]
tests/docker: fix DOCKER_PARTIAL_IMAGES

Finger trouble in a previous clean-up inadvertently set
DEBIAN_PARTIAL_IMAGES instead of DOCKER_PARTIAL_IMAGES. Also fix the
typo to debian-9-mxe.

Fixes: 44d5a8bf5d2
Signed-off-by: John Snow <jsnow@redhat.com>
[AJB: merged fix from Message-Id: <20190917185537.25417-1-jsnow@redhat.com>]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
4 years agotests/docker: add sanitizers back to clang build
John Snow [Thu, 12 Sep 2019 01:44:42 +0000 (21:44 -0400)]
tests/docker: add sanitizers back to clang build

Fedora23 is but a distant twinkle. The sanitizer works again, and even
if not, we have --enable-sanitizers now.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20190912014442.5757-1-jsnow@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
4 years agotarget/ppc: fix signal delivery for ppc64abi32
Alex Bennée [Wed, 11 Sep 2019 09:37:43 +0000 (10:37 +0100)]
target/ppc: fix signal delivery for ppc64abi32

We were incorrectly using the 64-bit AIX ABI instead of the 32-bit
SYSV ABI for setting NIP for the signal handler.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
4 years agotarget/alpha: Tidy helper_fp_exc_raise_s
Richard Henderson [Sat, 21 Sep 2019 04:32:56 +0000 (21:32 -0700)]
target/alpha: Tidy helper_fp_exc_raise_s

Remove a redundant masking of ignore.  Once that's gone it is
obvious that the system-mode inner test is redundant with the
outer test.  Move the fpcr_exc_enable masking up and tidy.

No functional change.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190921043256.4575-8-richard.henderson@linaro.org>

4 years agotarget/alpha: Mask IOV exception with INV for user-only
Richard Henderson [Sat, 21 Sep 2019 04:32:55 +0000 (21:32 -0700)]
target/alpha: Mask IOV exception with INV for user-only

The kernel masks the integer overflow exception with the
software invalid exception mask.  Include IOV in the set
of exception bits masked by fpcr_exc_enable.

Fixes the new float_convs test.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20190921043256.4575-7-richard.henderson@linaro.org>

4 years agotarget/alpha: Write to fpcr_flush_to_zero once
Richard Henderson [Sat, 21 Sep 2019 04:32:54 +0000 (21:32 -0700)]
target/alpha: Write to fpcr_flush_to_zero once

Tidy the computation of the value; no functional change.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20190921043256.4575-6-richard.henderson@linaro.org>

4 years agotarget/alpha: Handle SWCR_MAP_DMZ earlier
Richard Henderson [Sat, 21 Sep 2019 04:32:53 +0000 (21:32 -0700)]
target/alpha: Handle SWCR_MAP_DMZ earlier

Since we're converting the swcr to fpcr format for exceptions,
it's trivial to add FPCR_DNZ to the set of fpcr bits overriden.
No functional change.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20190921043256.4575-5-richard.henderson@linaro.org>

4 years agotarget/alpha: Fix SWCR_TRAP_ENABLE_MASK
Richard Henderson [Sat, 21 Sep 2019 04:32:52 +0000 (21:32 -0700)]
target/alpha: Fix SWCR_TRAP_ENABLE_MASK

The CONFIG_USER_ONLY adjustment blindly mashed the swcr
exception enable bits into the fpcr exception disable bits.

However, fpcr_exc_enable has already converted the exception
disable bits into the exception status bits in order to make
it easier to mask status bits at runtime.

Instead, merge the swcr enable bits with the fpcr before we
convert to status bits.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190921043256.4575-4-richard.henderson@linaro.org>

4 years agotarget/alpha: Fix SWCR_MAP_UMZ
Richard Henderson [Sat, 21 Sep 2019 04:32:51 +0000 (21:32 -0700)]
target/alpha: Fix SWCR_MAP_UMZ

We were setting the wrong bit.  The fp_status.flush_to_zero
setting is overwritten by either the constant 1 or the value
of fpcr_flush_to_zero depending on bits within an fp insn.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20190921043256.4575-3-richard.henderson@linaro.org>

4 years agotarget/alpha: Use array for FPCR_DYN conversion
Richard Henderson [Sat, 21 Sep 2019 04:32:50 +0000 (21:32 -0700)]
target/alpha: Use array for FPCR_DYN conversion

This is a bit more straight-forward than using a switch statement.
No functional change.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190921043256.4575-2-richard.henderson@linaro.org>

4 years agoqcrypto-luks: more rigorous header checking
Maxim Levitsky [Wed, 25 Sep 2019 21:35:26 +0000 (00:35 +0300)]
qcrypto-luks: more rigorous header checking

Check that keyslots don't overlap with the data,
and check that keyslots don't overlap with each other.
(this is done using naive O(n^2) nested loops,
but since there are just 8 keyslots, this doesn't really matter.

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqcrypto-luks: simplify the math used for keyslot locations
Maxim Levitsky [Wed, 25 Sep 2019 21:35:25 +0000 (00:35 +0300)]
qcrypto-luks: simplify the math used for keyslot locations

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqcrypto-luks: extract store key function
Maxim Levitsky [Wed, 25 Sep 2019 21:35:24 +0000 (00:35 +0300)]
qcrypto-luks: extract store key function

This function will be used later to store
new keys to the luks metadata

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqcrypto-luks: extract check and parse header
Maxim Levitsky [Wed, 25 Sep 2019 21:35:23 +0000 (00:35 +0300)]
qcrypto-luks: extract check and parse header

This is just to make qcrypto_block_luks_open more
reasonable in size.

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqcrypto-luks: extract store and load header
Maxim Levitsky [Wed, 25 Sep 2019 21:35:22 +0000 (00:35 +0300)]
qcrypto-luks: extract store and load header

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqcrypto-luks: purge unused error codes from open callback
Maxim Levitsky [Wed, 25 Sep 2019 21:35:21 +0000 (00:35 +0300)]
qcrypto-luks: purge unused error codes from open callback

These values are not used by generic crypto code anyway

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqcrypto-luks: use the parsed encryption settings in QCryptoBlockLUKS
Maxim Levitsky [Wed, 25 Sep 2019 21:35:20 +0000 (00:35 +0300)]
qcrypto-luks: use the parsed encryption settings in QCryptoBlockLUKS

Prior to that patch, the parsed encryption settings
were already stored into the QCryptoBlockLUKS but not
used anywhere but in qcrypto_block_luks_get_info

Using them simplifies the code

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqcrypto-luks: pass keyslot index rather that pointer to the keyslot
Maxim Levitsky [Wed, 25 Sep 2019 21:35:19 +0000 (00:35 +0300)]
qcrypto-luks: pass keyslot index rather that pointer to the keyslot

Another minor refactoring

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqcrypto-luks: simplify masterkey and masterkey length
Maxim Levitsky [Wed, 25 Sep 2019 21:35:18 +0000 (00:35 +0300)]
qcrypto-luks: simplify masterkey and masterkey length

Let the caller allocate masterkey
Always use master key len from the header

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqcrypto-luks: don't overwrite cipher_mode in header
Maxim Levitsky [Wed, 25 Sep 2019 21:35:17 +0000 (00:35 +0300)]
qcrypto-luks: don't overwrite cipher_mode in header

This way we can store the header we loaded, which
will be used in key management code

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqcrypto-luks: rename some fields in QCryptoBlockLUKSHeader
Maxim Levitsky [Wed, 25 Sep 2019 21:35:16 +0000 (00:35 +0300)]
qcrypto-luks: rename some fields in QCryptoBlockLUKSHeader

* key_bytes -> master_key_len
* payload_offset = payload_offset_sector (to emphasise that this isn't byte offset)
* key_offset -> key_offset_sector - same as above for luks slots

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoMerge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
Peter Maydell [Thu, 26 Sep 2019 15:14:03 +0000 (16:14 +0100)]
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging

vhost: fixes

Misc fixes related to memory region handling.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
# gpg: Signature made Wed 25 Sep 2019 15:28:23 BST
# gpg:                using RSA key 281F0DB8D28D5469
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" [full]
# gpg:                 aka "Michael S. Tsirkin <mst@redhat.com>" [full]
# Primary key fingerprint: 0270 606B 6F3C DF3D 0B17  0970 C350 3912 AFBE 8E67
#      Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA  8A0D 281F 0DB8 D28D 5469

* remotes/mst/tags/for_upstream:
  vhost: Fix memory region section comparison
  memory: Provide an equality function for MemoryRegionSections
  memory: Align MemoryRegionSections fields

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 years agoMerge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20190925a' into...
Peter Maydell [Thu, 26 Sep 2019 13:23:58 +0000 (14:23 +0100)]
Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20190925a' into staging

Migration pull 2019-09-25

  me: test fixes from (should stop hangs in postcopy tests).
  me: An RDMA cleanup hang fix
  Wei: Tidy ups around postcopy
  Marc-Andre: mem leak fix

# gpg: Signature made Wed 25 Sep 2019 15:59:41 BST
# gpg:                using RSA key 45F5C71B4A0CB7FB977A9FA90516331EBC5BFDE7
# gpg: Good signature from "Dr. David Alan Gilbert (RH2) <dgilbert@redhat.com>" [full]
# Primary key fingerprint: 45F5 C71B 4A0C B7FB 977A  9FA9 0516 331E BC5B FDE7

* remotes/dgilbert/tags/pull-migration-20190925a:
  migration/postcopy: Recognise the recovery states as 'in_postcopy'
  tests/migration/postcopy: trim migration bandwidth
  tests/migration: Fail on unexpected migration states
  migration/rdma.c: Swap synchronize_rcu for call_rcu
  migration/rdma: Don't moan about disconnects at the end
  migration: remove sent parameter in get_queued_page_not_dirty
  migration/postcopy: unsentmap is not necessary for postcopy
  migration/postcopy: not necessary to do discard when canonicalizing bitmap
  migration: fix vmdesc leak on vmstate_save() error

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 years agoMerge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2019-09-24-v2' into staging
Peter Maydell [Thu, 26 Sep 2019 09:13:39 +0000 (10:13 +0100)]
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2019-09-24-v2' into staging

nbd patches for 2019-09-24

- Improved error message for plaintext client of encrypted server
- Fix various assertions when -object iothread is in use
- Silence a Coverity error for use-after-free on error path

# gpg: Signature made Wed 25 Sep 2019 14:35:52 BST
# gpg:                using RSA key 71C2CC22B1C4602927D2F3AAA7A16B4A2527436A
# gpg: Good signature from "Eric Blake <eblake@redhat.com>" [full]
# gpg:                 aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>" [full]
# gpg:                 aka "[jpeg image of size 6874]" [full]
# Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2  F3AA A7A1 6B4A 2527 436A

* remotes/ericb/tags/pull-nbd-2019-09-24-v2:
  util/qemu-sockets: fix keep_alive handling in inet_connect_saddr
  tests: Use iothreads during iotest 223
  nbd: Grab aio context lock in more places
  nbd/server: attach client channel to the export's AioContext
  nbd/client: Add hint when TLS is missing

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 years agocputlb: Pass retaddr to tb_check_watchpoint
Richard Henderson [Sun, 22 Sep 2019 03:24:12 +0000 (20:24 -0700)]
cputlb: Pass retaddr to tb_check_watchpoint

Fixes the previous TLB_WATCHPOINT patches because we are currently
failing to set cpu->mem_io_pc with the call to cpu_check_watchpoint.
Pass down the retaddr directly because it's readily available.

Fixes: 50b107c5d61
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 years agocputlb: Pass retaddr to tb_invalidate_phys_page_fast
Richard Henderson [Sun, 22 Sep 2019 03:16:09 +0000 (20:16 -0700)]
cputlb: Pass retaddr to tb_invalidate_phys_page_fast

Rather than rely on cpu->mem_io_pc, pass retaddr down directly.

Within tb_invalidate_phys_page_range__locked, the is_cpu_write_access
parameter is non-zero exactly when retaddr would be non-zero, so that
is a simple replacement.

Recognize that current_tb_not_found is true only when mem_io_pc
(and now retaddr) are also non-zero, so remove a redundant test.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 years agocputlb: Remove tb_invalidate_phys_page_range is_cpu_write_access
Richard Henderson [Sun, 22 Sep 2019 03:03:36 +0000 (20:03 -0700)]
cputlb: Remove tb_invalidate_phys_page_range is_cpu_write_access

All callers pass false to this argument.  Remove it and pass the
constant on to tb_invalidate_phys_page_range__locked.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 years agocputlb: Remove cpu->mem_io_vaddr
Richard Henderson [Sun, 22 Sep 2019 02:44:01 +0000 (19:44 -0700)]
cputlb: Remove cpu->mem_io_vaddr

With the merge of notdirty handling into store_helper,
the last user of cpu->mem_io_vaddr was removed.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 years agocputlb: Handle TLB_NOTDIRTY in probe_access
Richard Henderson [Sun, 22 Sep 2019 02:28:48 +0000 (19:28 -0700)]
cputlb: Handle TLB_NOTDIRTY in probe_access

We can use notdirty_write for the write and return a valid host
pointer for this case.

Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 years agocputlb: Merge and move memory_notdirty_write_{prepare,complete}
Richard Henderson [Sun, 22 Sep 2019 01:47:59 +0000 (18:47 -0700)]
cputlb: Merge and move memory_notdirty_write_{prepare,complete}

Since 9458a9a1df1a, all readers of the dirty bitmaps wait
for the rcu lock, which means that they wait until the end
of any executing TranslationBlock.

As a consequence, there is no need for the actual access
to happen in between the _prepare and _complete.  Therefore,
we can improve things by merging the two functions into
notdirty_write and dropping the NotDirtyInfo structure.

In addition, the only users of notdirty_write are in cputlb.c,
so move the merged function there.  Pass in the CPUIOTLBEntry
from which the ram_addr_t may be computed.

Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 years agocputlb: Partially inline memory_region_section_get_iotlb
Richard Henderson [Fri, 20 Sep 2019 04:09:58 +0000 (21:09 -0700)]
cputlb: Partially inline memory_region_section_get_iotlb

There is only one caller, tlb_set_page_with_attrs.  We cannot
inline the entire function because the AddressSpaceDispatch
structure is private to exec.c, and cannot easily be moved to
include/exec/memory-internal.h.

Compute is_ram and is_romd once within tlb_set_page_with_attrs.
Fold the number of tests against these predicates.  Compute
cpu_physical_memory_is_clean outside of the tlb lock region.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 years agocputlb: Move NOTDIRTY handling from I/O path to TLB path
Richard Henderson [Wed, 18 Sep 2019 16:15:44 +0000 (09:15 -0700)]
cputlb: Move NOTDIRTY handling from I/O path to TLB path

Pages that we want to track for NOTDIRTY are RAM.  We do not
really need to go through the I/O path to handle them.

Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 years agocputlb: Move ROM handling from I/O path to TLB path
Richard Henderson [Fri, 20 Sep 2019 00:54:10 +0000 (17:54 -0700)]
cputlb: Move ROM handling from I/O path to TLB path

It does not require going through the whole I/O path
in order to discard a write.

Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 years agoexec: Adjust notdirty tracing
Richard Henderson [Wed, 18 Sep 2019 03:39:56 +0000 (03:39 +0000)]
exec: Adjust notdirty tracing

The memory_region_tb_read tracepoint is unreachable, since notdirty
is supposed to apply only to writes.  The memory_region_tb_write
tracepoint is mis-named, because notdirty is not only used for TB
invalidation.  It is also used for e.g. VGA RAM updates and migration.

Replace memory_region_tb_write with memory_notdirty_write_access,
and place it in memory_notdirty_write_prepare where it can catch
all of the instances.  Add memory_notdirty_set_dirty to log when
we no longer intercept writes to a page.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 years agocputlb: Introduce TLB_BSWAP
Richard Henderson [Tue, 10 Sep 2019 19:47:39 +0000 (15:47 -0400)]
cputlb: Introduce TLB_BSWAP

Handle bswap on ram directly in load/store_helper.  This fixes a
bug with the previous implementation in that one cannot use the
I/O path for RAM.

Fixes: a26fc6f5152b47f1
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 years agocputlb: Split out load/store_memop
Richard Henderson [Tue, 10 Sep 2019 18:56:12 +0000 (14:56 -0400)]
cputlb: Split out load/store_memop

We will shortly be using these more than once.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 years agocputlb: Use qemu_build_not_reached in load/store_helpers
Richard Henderson [Mon, 23 Sep 2019 21:14:31 +0000 (14:14 -0700)]
cputlb: Use qemu_build_not_reached in load/store_helpers

Increase the current runtime assert to a compile-time assert.

Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 years agoqemu/compiler.h: Add qemu_build_not_reached
Richard Henderson [Mon, 23 Sep 2019 18:24:12 +0000 (11:24 -0700)]
qemu/compiler.h: Add qemu_build_not_reached

Use this as a compile-time assert that a particular
code path is not reachable.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 years agocputlb: Disable __always_inline__ without optimization
Richard Henderson [Tue, 10 Sep 2019 16:02:36 +0000 (12:02 -0400)]
cputlb: Disable __always_inline__ without optimization

This forced inlining can result in missing symbols,
which makes a debugging build harder to follow.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 years agoexec: Use TARGET_PAGE_BITS_MIN for TLB flags
Richard Henderson [Fri, 13 Sep 2019 15:29:35 +0000 (11:29 -0400)]
exec: Use TARGET_PAGE_BITS_MIN for TLB flags

These bits do not need to vary with the actual page size
used by the guest.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4 years agomigration/postcopy: Recognise the recovery states as 'in_postcopy'
Dr. David Alan Gilbert [Mon, 23 Sep 2019 17:49:42 +0000 (18:49 +0100)]
migration/postcopy: Recognise the recovery states as 'in_postcopy'

Various parts of the migration code do different things when they're
in postcopy mode; prior to this patch this has been 'postcopy-active'.
This patch extends 'in_postcopy' to include 'postcopy-paused' and
'postcopy-recover'.

In particular, when you set the max-postcopy-bandwidth parameter, this
only affects the current migration fd if we're 'in_postcopy';
this leads to a race in the postcopy recovery test where it increases
the speed from 4k/sec to unlimited, but that increase can get ignored
if the change is made between the point at which the reconnection
happens and it transitions back to active.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190923174942.12182-1-dgilbert@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Tested-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
4 years agotests/migration/postcopy: trim migration bandwidth
Dr. David Alan Gilbert [Mon, 23 Sep 2019 13:10:22 +0000 (14:10 +0100)]
tests/migration/postcopy: trim migration bandwidth

On slow hosts with tcg we were sometimes finding that the migration
would complete during precopy and never get into the postcopy test.
Trim back the bandwidth a bit to make that much less likely.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190923131022.15498-3-dgilbert@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Acked-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Cleber Rosa <crosa@redhat.com>
Tested-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
4 years agotests/migration: Fail on unexpected migration states
Dr. David Alan Gilbert [Mon, 23 Sep 2019 13:10:21 +0000 (14:10 +0100)]
tests/migration: Fail on unexpected migration states

We've got various places where we wait for a migration to enter
a given state; but if we enter an unexpected state we tend to fail
in odd ways; add a mechanism for explicitly testing for any state
which we shouldn't be in.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190923131022.15498-2-dgilbert@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Tested-by: Cleber Rosa <crosa@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
4 years agomigration/rdma.c: Swap synchronize_rcu for call_rcu
Dr. David Alan Gilbert [Fri, 13 Sep 2019 16:35:07 +0000 (17:35 +0100)]
migration/rdma.c: Swap synchronize_rcu for call_rcu

This fixes a deadlock that can occur on the migration source after
a failed RDMA migration;  as the source tries to cleanup it
clears a pair of pointers and uses synchronize_rcu to wait; this
is happening on the main thread.  With the CPUs running
a CPU thread can be an rcu reader and attempt to grab the main lock
(kvm_handle_io->address_space_write->flatview_write->flatview_write_continue->
prepare_mmio_access->qemu_mutex_lock_iothread_impl)

Replace the synchronize_rcu with a call_rcu to postpone the freeing.

Fixes: 74637e6f08fceda98806 ("migration: implement bi-directional RDMA QIOChannel")
( https://bugzilla.redhat.com/show_bug.cgi?id=1746787 )

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190913163507.1403-3-dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
4 years agomigration/rdma: Don't moan about disconnects at the end
Dr. David Alan Gilbert [Fri, 13 Sep 2019 16:35:06 +0000 (17:35 +0100)]
migration/rdma: Don't moan about disconnects at the end

If we've already finished the migration or something has
already gone wrong, don't moan about the migration stream disconnecting.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190913163507.1403-2-dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
4 years agomigration: remove sent parameter in get_queued_page_not_dirty
Wei Yang [Mon, 19 Aug 2019 06:18:43 +0000 (14:18 +0800)]
migration: remove sent parameter in get_queued_page_not_dirty

This is a cleanup for previous removal of unsentmap.

The sent parameter is not necessary now.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Message-Id: <20190819061843.28642-4-richardw.yang@linux.intel.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
4 years agomigration/postcopy: unsentmap is not necessary for postcopy
Wei Yang [Mon, 19 Aug 2019 06:18:42 +0000 (14:18 +0800)]
migration/postcopy: unsentmap is not necessary for postcopy

Commit f3f491fcd6dd594ba695 ('Postcopy: Maintain unsentmap') introduced
unsentmap to track not yet sent pages.

This is not necessary since:

    * unsentmap is a sub-set of bmap before postcopy start
    * unsentmap is the summation of bmap and unsentmap after canonicalizing

This patch just removes it.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Message-Id: <20190819061843.28642-3-richardw.yang@linux.intel.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
4 years agomigration/postcopy: not necessary to do discard when canonicalizing bitmap
Wei Yang [Mon, 19 Aug 2019 06:18:41 +0000 (14:18 +0800)]
migration/postcopy: not necessary to do discard when canonicalizing bitmap

All pages, either partially sent or partially dirty, will be discarded in
postcopy_send_discard_bm_ram(), since we update the unsentmap to be
unsentmap = unsentmap | dirty in ram_postcopy_send_discard_bitmap().

This is not necessary to do discard when canonicalizing bitmap. And by
doing so, we separate the page discard into two individual steps:

  * canonicalize bitmap
  * discard page

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
Message-Id: <20190819061843.28642-2-richardw.yang@linux.intel.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
4 years agomigration: fix vmdesc leak on vmstate_save() error
Marc-André Lureau [Thu, 12 Sep 2019 12:25:09 +0000 (16:25 +0400)]
migration: fix vmdesc leak on vmstate_save() error

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20190912122514.22504-2-marcandre.lureau@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
4 years agovhost: Fix memory region section comparison
Dr. David Alan Gilbert [Wed, 14 Aug 2019 17:55:35 +0000 (18:55 +0100)]
vhost: Fix memory region section comparison

Using memcmp to compare structures wasn't safe,
as I found out on ARM when I was getting falce miscompares.

Use the helper function for comparing the MRSs.

Fixes: ade6d081fc33948e56e6 ("vhost: Regenerate region list from changed sections list")
Cc: qemu-stable@nongnu.org
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190814175535.2023-4-dgilbert@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
4 years agomemory: Provide an equality function for MemoryRegionSections
Dr. David Alan Gilbert [Wed, 14 Aug 2019 17:55:34 +0000 (18:55 +0100)]
memory: Provide an equality function for MemoryRegionSections

Provide a comparison function that checks all the fields are the same.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190814175535.2023-3-dgilbert@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
4 years agomemory: Align MemoryRegionSections fields
Dr. David Alan Gilbert [Wed, 14 Aug 2019 17:55:33 +0000 (18:55 +0100)]
memory: Align MemoryRegionSections fields

MemoryRegionSection includes an Int128 'size' field;
on some platforms the compiler causes an alignment of this to
a 128bit boundary, leaving 8 bytes of dead space.
This deadspace can be filled with junk.

Move the size field to the top avoiding unnecessary alignment.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190814175535.2023-2-dgilbert@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
4 years agoutil/qemu-sockets: fix keep_alive handling in inet_connect_saddr
Vladimir Sementsov-Ogievskiy [Tue, 10 Sep 2019 07:59:43 +0000 (10:59 +0300)]
util/qemu-sockets: fix keep_alive handling in inet_connect_saddr

In "if (saddr->keep_alive) {" we may already be on error path, with
invalid sock < 0. Fix it by returning error earlier.

Reported-by: Coverity (CID 1405300)
Fixes: aec21d31756cbd
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20190910075943.12977-1-vsementsov@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
4 years agoMerge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2019-09-24' into staging
Peter Maydell [Wed, 25 Sep 2019 12:31:21 +0000 (13:31 +0100)]
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2019-09-24' into staging

QAPI patches for 2019-09-24

# gpg: Signature made Tue 24 Sep 2019 13:10:36 BST
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "armbru@redhat.com"
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-qapi-2019-09-24: (37 commits)
  qapi: Assert .visit() and .check_clash() run only after .check()
  qapi: Fix excessive QAPISchemaEntity.check() recursion
  qapi: Fix to .check() empty structs just once
  qapi: Delete useless check_exprs() code for simple union kind
  qapi: Clean up around check_known_keys()
  qapi: Simplify check_keys()
  qapi: Normalize 'if' in check_exprs(), like other sugar
  qapi: Fix missing 'if' checks in struct, union, alternate 'data'
  qapi: Reject blank 'if' conditions in addition to empty ones
  qapi: Fix broken discriminator error messages
  qapi: Remove null from schema language
  qapi: Improve reporting of lexical errors
  qapi: Use quotes more consistently in frontend error messages
  tests/qapi-schema: Demonstrate suboptimal lexical errors
  tests/qapi-schema: Demonstrate insufficient 'if' checking
  tests/qapi-schema: Demonstrate broken discriminator errors
  tests/qapi-schema: Demonstrate misleading optional tag error
  tests/qapi-schema: Delete two redundant tests
  tests/qapi-schema: Cover unknown pragma
  qapi: Tweak code to match docs/devel/qapi-code-gen.txt
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 years agoMerge remote-tracking branch 'remotes/aperard/tags/pull-xen-20190924' into staging
Peter Maydell [Tue, 24 Sep 2019 14:36:31 +0000 (15:36 +0100)]
Merge remote-tracking branch 'remotes/aperard/tags/pull-xen-20190924' into staging

Xen queue

* Update of maintainer email address
* Fixes for xen-bus and xen-block

# gpg: Signature made Tue 24 Sep 2019 12:27:56 BST
# gpg:                using RSA key F80C006308E22CFD8A92E7980CF5572FD7FB55AF
# gpg:                issuer "anthony.perard@citrix.com"
# gpg: Good signature from "Anthony PERARD <anthony.perard@gmail.com>" [marginal]
# gpg:                 aka "Anthony PERARD <anthony.perard@citrix.com>" [marginal]
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 5379 2F71 024C 600F 778A  7161 D8D5 7199 DF83 42C8
#      Subkey fingerprint: F80C 0063 08E2 2CFD 8A92  E798 0CF5 572F D7FB 55AF

* remotes/aperard/tags/pull-xen-20190924:
  xen-bus: only set the xen device frontend state if it is missing
  xen-block: treat XenbusStateUnknown the same as XenbusStateClosed
  MAINTAINERS: update my email address
  xen: perform XenDevice clean-up in XenBus watch handler
  xen: introduce separate XenWatchList for XenDevice objects
  xen / notify: introduce a new XenWatchList abstraction
  xen-bus: check whether the frontend is active during device reset...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 years agoMerge remote-tracking branch 'remotes/kraxel/tags/audio-20190924-pull-request' into...
Peter Maydell [Tue, 24 Sep 2019 12:51:51 +0000 (13:51 +0100)]
Merge remote-tracking branch 'remotes/kraxel/tags/audio-20190924-pull-request' into staging

audio: documentation fixes.
audio: new backend api (first part of the surround sound patch series).

# gpg: Signature made Tue 24 Sep 2019 07:19:31 BST
# gpg:                using RSA key 4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full]
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>" [full]
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full]
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/audio-20190924-pull-request:
  audio: split ctl_* functions into enable_* and volume_*
  audio: common rate control code for timer based outputs
  audio: unify input and output mixeng buffer management
  audio: remove remains of the old backend api
  wavaudio: port to the new audio backend api
  spiceaudio: port to the new audio backend api
  sdlaudio: port to the new audio backend api
  paaudio: port to the new audio backend api
  ossaudio: port to the new audio backend api
  noaudio: port to the new audio backend api
  dsoundaudio: port to the new audio backend api
  coreaudio: port to the new audio backend api
  alsaaudio: port to the new audio backend api
  audio: api for mixeng code free backends
  audio: fix ALSA period-length typo in documentation
  audio: fix buffer-length typo in documentation

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4 years agotests: Use iothreads during iotest 223
Eric Blake [Fri, 20 Sep 2019 22:07:29 +0000 (17:07 -0500)]
tests: Use iothreads during iotest 223

Doing so catches the bugs we just fixed with NBD not properly using
correct contexts.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190920220729.31801-1-eblake@redhat.com>

4 years agonbd: Grab aio context lock in more places
Eric Blake [Tue, 17 Sep 2019 02:39:17 +0000 (21:39 -0500)]
nbd: Grab aio context lock in more places

When iothreads are in use, the failure to grab the aio context results
in an assertion failure when trying to unlock things during blk_unref,
when trying to unlock a mutex that was not locked.  In short, all
calls to nbd_export_put need to done while within the correct aio
context.  But since nbd_export_put can recursively reach itself via
nbd_export_close, and recursively grabbing the context would deadlock,
we can't do the context grab directly in those functions, but must do
so in their callers.

Hoist the use of the correct aio_context from nbd_export_new() to its
caller qmp_nbd_server_add().  Then tweak qmp_nbd_server_remove(),
nbd_eject_notifier(), and nbd_esport_close_all() to grab the right
context, so that all callers during qemu now own the context before
nbd_export_put() can call blk_unref().

Remaining uses in qemu-nbd don't matter (since that use case does not
support iothreads).

Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190917023917.32226-1-eblake@redhat.com>
Reviewed-by: Sergio Lopez <slp@redhat.com>
4 years agonbd/server: attach client channel to the export's AioContext
Sergio Lopez [Thu, 12 Sep 2019 11:00:33 +0000 (13:00 +0200)]
nbd/server: attach client channel to the export's AioContext

On creation, the export's AioContext is set to the same one as the
BlockBackend, while the AioContext in the client QIOChannel is left
untouched.

As a result, when using data-plane, nbd_client_receive_next_request()
schedules coroutines in the IOThread AioContext, while the client's
QIOChannel is serviced from the main_loop, potentially triggering the
assertion at qio_channel_restart_[read|write].

To fix this, as soon we have the export corresponding to the client,
we call qio_channel_attach_aio_context() to attach the QIOChannel
context to the export's AioContext. This matches with the logic at
blk_aio_attached().

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1748253
Signed-off-by: Sergio Lopez <slp@redhat.com>
Message-Id: <20190912110032.26395-1-slp@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
4 years agonbd/client: Add hint when TLS is missing
Eric Blake [Sat, 7 Sep 2019 17:20:55 +0000 (12:20 -0500)]
nbd/client: Add hint when TLS is missing

I received an off-list report of failure to connect to an NBD server
expecting an x509 certificate, when the client was attempting something
similar to this command line:

$ ./x86_64-softmmu/qemu-system-x86_64 -name 'blah' -machine q35 -nodefaults \
  -object tls-creds-x509,id=tls0,endpoint=client,dir=$path_to_certs \
  -device virtio-scsi-pci,id=virtio_scsi_pci0,bus=pcie.0,addr=0x6 \
  -drive id=drive_image1,if=none,snapshot=off,aio=threads,cache=none,format=raw,file=nbd:localhost:9000,werror=stop,rerror=stop,tls-creds=tls0 \
  -device scsi-hd,id=image1,drive=drive_image1,bootindex=0
qemu-system-x86_64: -drive id=drive_image1,if=none,snapshot=off,aio=threads,cache=none,format=raw,file=nbd:localhost:9000,werror=stop,rerror=stop,tls-creds=tls0: TLS negotiation required before option 7 (go)
server reported: Option 0x7 not permitted before TLS

The problem?  As specified, -drive is trying to pass tls-creds to the
raw format driver instead of the nbd protocol driver, but before we
get to the point where we can detect that raw doesn't know what to do
with tls-creds, the nbd driver has already failed because the server
complained.  The fix to the broken command line?  Pass
'...,file.tls-creds=tls0' to ensure the tls-creds option is handed to
nbd, not raw.  But since the error message was rather cryptic, I'm
trying to improve the error message.

With this patch, the error message adds a line:

qemu-system-x86_64: -drive id=drive_image1,if=none,snapshot=off,aio=threads,cache=none,format=raw,file=nbd:localhost:9000,werror=stop,rerror=stop,tls-creds=tls0: TLS negotiation required before option 7 (go)
Did you forget a valid tls-creds?
server reported: Option 0x7 not permitted before TLS

And with luck, someone grepping for that error message will find this
commit message and figure out their command line mistake.  Sadly, the
only mention of file.tls-creds in our docs relates to an --image-opts
use of PSK encryption with qemu-img as the client, rather than x509
certificate encryption with qemu-kvm as the client.

CC: Tingting Mao <timao@redhat.com>
CC: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190907172055.26870-1-eblake@redhat.com>
[eblake: squash in iotest 233 fix]
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
4 years agoqapi: Assert .visit() and .check_clash() run only after .check()
Markus Armbruster [Sat, 14 Sep 2019 15:35:06 +0000 (17:35 +0200)]
qapi: Assert .visit() and .check_clash() run only after .check()

Easy since the previous commit provides .checked.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-20-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqapi: Fix excessive QAPISchemaEntity.check() recursion
Markus Armbruster [Sat, 14 Sep 2019 15:35:05 +0000 (17:35 +0200)]
qapi: Fix excessive QAPISchemaEntity.check() recursion

Entity checking goes back to commit ac88219a6c "qapi: New QAPISchema
intermediate representation", v2.5.0.  It's designed to work as
follows: QAPISchema.check() calls .check() for all the schema's
entities.  An entity's .check() recurses into another entity's
.check() only if the C struct generated for the former contains the C
struct generated for the latter (pointers don't count).  This is used
to detect "object contains itself".

There are two instances of this:

* An object's C struct contains its base's C struct

  QAPISchemaObjectType.check() calls self.base.check()

* An object's C struct contains its variants' C structs

  QAPISchemaObjectTypeVariants().check calls v.type.check().  Since
  commit b807a1e1e3 "qapi: Check for QAPI collisions involving variant
  members", v2.6.0.

Thus, only object types can participate in recursion.

QAPISchemaObjectType.check() is made for that: it checks @self when
called the first time, recursing into base and variants, it reports an
"contains itself" error when this recursion reaches an object being
checked, and does nothing it reaches an object that has been checked
already.

The other .check() may safely assume they get called exactly once.

Sadly, this design has since eroded:

* QAPISchemaCommand.check() and QAPISchemaEvent.check() call
  .args_type.check().  Since commit c818408e44 "qapi: Implement boxed
  types for commands/events", v2.7.0.  Harmless, since args_type can
  only be an object type.

* QAPISchemaEntity.check() calls ._ifcond.check() when inheriting the
  condition from another type.  Since commit 4fca21c1b0 qapi: leave
  the ifcond attribute undefined until check(), v3.0.0.  This makes
  simple union wrapper types recurse into the wrapped type (nothing
  else uses this condition inheritance).  The .check() of types used
  as simple union branch type get called multiple times.

* QAPISchemaObjectType.check() calls its super type's .check()
  *before* the conditional handling multiple calls.  Also since commit
  4fca21c1b0.  QAPISchemaObjectType.check()'s guard against multiple
  checking doesn't protect QAPISchemaEntity.check().

* QAPISchemaArrayType.check() calls .element_type.check().  Also since
  commit 4fca21c1b0.  The .check() of types used as array element
  types get called multiple times.

  Commit 56a4689582 "qapi: Fix array first used in a different module"
  (v4.0.0) added more code relying on this .element_type.check().

The absence of explosions suggests the .check() involved happen to be
effectively idempotent.

Fix the unwanted recursion anyway:

* QAPISchemaCommand.check() and QAPISchemaEvent.check() calling
  .args_type.check() is unnecessary.  Delete the calls.

* Fix QAPISchemaObjectType.check() to call its super type's .check()
  after the conditional handling multiple calls.

* A QAPISchemaEntity's .ifcond becomes valid at .check().  This is due
  to arrays and simple unions.

  Most types get ifcond and info passed to their constructor.

  Array types don't: they get it from their element type, which
  becomes known only in .element_type.check().

  The implicit wrapper object types for simple union branches don't:
  they get it from the wrapped type, which might be an array.

  Ditch the idea to set .ifcond in .check().  Instead, turn it into a
  property and compute it on demand.  Safe because it's only used
  after the schema has been checked.

  Most types simply return the ifcond passed to their constructor.

  Array types forward to their .element_type instead, and the wrapper
  types forward to the wrapped type.

* A QAPISchemaEntity's .module becomes valid at .check().  This is
  because computing it needs info and schema.fname, and because array
  types get it from their element type instead.

  Make it a property just like .ifcond.

Additionally, have QAPISchemaEntity.check() assert it gets called at
most once, so the design invariant will stick this time.  Neglecting
that was entirely my fault.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-19-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Commit message tidied up]

4 years agoqapi: Fix to .check() empty structs just once
Markus Armbruster [Sat, 14 Sep 2019 15:35:04 +0000 (17:35 +0200)]
qapi: Fix to .check() empty structs just once

QAPISchemaObjectType.check() does nothing for types that have been
checked already.  Except the "has been checked" predicate is broken
for empty types: self.members is [] then, which isn't true.  The bug
is harmless, but fix it anyway: use self.member is not None instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-18-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqapi: Delete useless check_exprs() code for simple union kind
Markus Armbruster [Sat, 14 Sep 2019 15:35:03 +0000 (17:35 +0200)]
qapi: Delete useless check_exprs() code for simple union kind

Commit bceae7697f "qapi script: support enum type as discriminator in
union" made check_exprs() add the implicit enum types of simple unions
to global @enum_types.  I'm not sure it was needed even then.  It's
certainly not needed now.  Delete it.

discriminator_find_enum_define() and add_name() parameter @implicit
are now dead.  Bury them.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-17-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqapi: Clean up around check_known_keys()
Markus Armbruster [Sat, 14 Sep 2019 15:35:02 +0000 (17:35 +0200)]
qapi: Clean up around check_known_keys()

All callers pass a dict argument to @keys, except check_keys() passes
a dict's .keys().  Drop .keys() there, and rename parameter @keys to
@value.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-16-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqapi: Simplify check_keys()
Markus Armbruster [Sat, 14 Sep 2019 15:35:01 +0000 (17:35 +0200)]
qapi: Simplify check_keys()

check_keys() parameter expr_elem expects a dictionary with keys 'expr'
and 'info'.  Passing the two values separately is simpler, so do that.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-15-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqapi: Normalize 'if' in check_exprs(), like other sugar
Markus Armbruster [Sat, 14 Sep 2019 15:35:00 +0000 (17:35 +0200)]
qapi: Normalize 'if' in check_exprs(), like other sugar

We normalize shorthand to longhand forms in check_expr(): enumeration
values with normalize_enum(), feature values with
normalize_features(), struct members, union branches and alternate
branches with normalize_members().  If conditions are an exception: we
normalize them in QAPISchemaEntity.check() and
QAPISchemaMember.__init(), with listify_cond().  The idea goes back to
commit 2cbc94376e "qapi: pass 'if' condition into QAPISchemaEntity
objects", v3.0.0.

Normalize in check_expr() instead, with new helper normalize_if().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-14-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqapi: Fix missing 'if' checks in struct, union, alternate 'data'
Markus Armbruster [Sat, 14 Sep 2019 15:34:59 +0000 (17:34 +0200)]
qapi: Fix missing 'if' checks in struct, union, alternate 'data'

Commit 87adbbffd4..3e270dcacc "qapi: Add 'if' to (implicit
struct|union|alternate) members" (v4.0.0) neglected test coverage, and
promptly failed to check the conditions.  Review fail.

Recent commit "tests/qapi-schema: Demonstrate insufficient 'if'
checking" added test coverage, demonstrating the bug.  Fix it by add
the missing check_if().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-13-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqapi: Reject blank 'if' conditions in addition to empty ones
Markus Armbruster [Sat, 14 Sep 2019 15:34:58 +0000 (17:34 +0200)]
qapi: Reject blank 'if' conditions in addition to empty ones

"'if': 'COND'" generates "#if COND".  We reject empty COND because it
won't compile.  Blank COND won't compile any better, so reject that,
too.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-12-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqapi: Fix broken discriminator error messages
Markus Armbruster [Sat, 14 Sep 2019 15:34:57 +0000 (17:34 +0200)]
qapi: Fix broken discriminator error messages

check_union() checks the discriminator exists in base and makes sense.
Two error messages mention the base.  These are broken for anonymous
bases, as demonstrated by tests flat-union-invalid-discriminator and
flat-union-invalid-if-discriminator.err.  The third one doesn't
bother.

First broken when commit ac4338f8eb "qapi: Allow anonymous base for
flat union" (v2.6.0) neglected to adjust the "not a member of base"
error message.  Commit ccadd6bcba "qapi: Add 'if' to implicit struct
members" (v4.0.0) then cloned the flawed error message.

Dumb them down not to mention the base.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-11-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqapi: Remove null from schema language
Markus Armbruster [Sat, 14 Sep 2019 15:34:56 +0000 (17:34 +0200)]
qapi: Remove null from schema language

We represent the parse tree as OrderedDict.  We fetch optional dict
members with .get().  So far, so good.

We represent null literals as None.  .get() returns None both for
"absent" and for "present, value is the null literal".  Uh-oh.

Test features-if-invalid exposes this bug: "'if': null" is
misinterpreted as absent "if".

We added null to the schema language to "allow [...] an explicit
default value" (commit e53188ada5 "qapi: Allow true, false and null in
schema json", v2.4.0).  Hasn't happened; null is still unused except
as generic invalid value in tests/.

To fix, we'd have to replace .get() by something more careful, or
represent null differently.  Feasible, but we got more and bigger fish
to fry right now.  Remove the null literal from the schema language.
Replace null in tests by another invalid value.

Test features-if-invalid now behaves as it should.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-10-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqapi: Improve reporting of lexical errors
Markus Armbruster [Sat, 14 Sep 2019 15:34:55 +0000 (17:34 +0200)]
qapi: Improve reporting of lexical errors

Show text up to next structural character, whitespace, or quote
character instead of just the first character.

Forgotten quotes now get reported like "Stray 'command'" instead of
"Stray 'c'".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-9-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agoqapi: Use quotes more consistently in frontend error messages
Markus Armbruster [Sat, 14 Sep 2019 15:34:54 +0000 (17:34 +0200)]
qapi: Use quotes more consistently in frontend error messages

Consistently enclose error messages in double quotes.  Use single
quotes within, except for one case of "'".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-8-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agotests/qapi-schema: Demonstrate suboptimal lexical errors
Markus Armbruster [Sat, 14 Sep 2019 15:34:53 +0000 (17:34 +0200)]
tests/qapi-schema: Demonstrate suboptimal lexical errors

The error message for forgotten quotes around a name shows just the
name's first character, which isn't as nice as it could be.  Same for
attempting to use a number.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-7-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agotests/qapi-schema: Demonstrate insufficient 'if' checking
Markus Armbruster [Sat, 14 Sep 2019 15:34:52 +0000 (17:34 +0200)]
tests/qapi-schema: Demonstrate insufficient 'if' checking

Cover invalid 'if' in struct members, features, union and alternate
branches.  Four out of four are broken.  Mark FIXME.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-6-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Comment typo fixed]

4 years agotests/qapi-schema: Demonstrate broken discriminator errors
Markus Armbruster [Sat, 14 Sep 2019 15:34:51 +0000 (17:34 +0200)]
tests/qapi-schema: Demonstrate broken discriminator errors

When the union definition's base is an object, some error messages
show it as an OrderedDict.  Oops.  Mark FIXME.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-5-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agotests/qapi-schema: Demonstrate misleading optional tag error
Markus Armbruster [Sat, 14 Sep 2019 15:34:50 +0000 (17:34 +0200)]
tests/qapi-schema: Demonstrate misleading optional tag error

Test flat-union-optional-discriminator declares its union tag as
'*switch': 'Enum', and points to it with 'discriminator': '*switch'.
This gets rejected as "discriminator of flat union 'MyUnion' uses
invalid name '*switch'".  Correct; member 'discriminator' doesn't
accept a '*' prefix.

However, this merely tests name validity checking, which we already
cover elsewhere.  More interesting is testing the valid name 'switch'.
This reports "discriminator 'switch' is not a member of base struct
'Base'", which is misleading.

Copy the existing 'discriminator': '*switch' test to
flat-union-discriminator-bad-name, and rewrite its comment.  Change
flat-union-optional-discriminator to test 'discriminator': 'switch',
and mark it FIXME.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-4-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agotests/qapi-schema: Delete two redundant tests
Markus Armbruster [Sat, 14 Sep 2019 15:34:49 +0000 (17:34 +0200)]
tests/qapi-schema: Delete two redundant tests

Tests duplicate-key and double-data test the same thing.  The former
predates the latter, and it has a better name.  Delete the latter, and
tweak the former's comment.

Tests include-format-err and include-extra-junk test the same thing.
The former predates the latter, but the latter has a better name and a
comment.  Delete the former.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-3-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
4 years agotests/qapi-schema: Cover unknown pragma
Markus Armbruster [Sat, 14 Sep 2019 15:34:48 +0000 (17:34 +0200)]
tests/qapi-schema: Cover unknown pragma

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190914153506.2151-2-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>