Revert "qtest: Fix crash if SIGABRT during qtest_init()"

It turns out there are test cases that use multiple libqtest instances.
We cannot use a global qtest instance in the SIGABRT handler.

This reverts commit cb201b4872f16dfbce63f8648b2584631e2e965f.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel.a@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
qtest: Keep list of qtest instances for SIGABRT handler

Keep track of active qtest instances so we can kill them when the test
aborts.  This ensures no QEMU processes are left running after test
failure.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel.a@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
tests: Remove unsupported tests for MinGW

test_timer_schedule and test_source_timer_schedule don't compile for MinGW
because some functions are not implemented for MinGW (qemu_pipe,
aio_set_fd_handler).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
tests: Skip POSIX-only tests on Windows

test-rfifolock and test-vmstate only build on POSIX hosts.  Exclude them
if building for Windows.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Andreas Färber <afaerber@suse.de>
tests: Correctly skip qtest on non-POSIX hosts

qtest test cases only work on POSIX hosts.  The following line only
defines dependencies for qtest binaries on POSIX hosts:

  check-qtest-$(CONFIG_POSIX)=$(foreach TARGET,$(TARGETS),$(check-qtest-$(TARGET)-y))

But the QTEST_TARGETS definition earlier in the Makefile fails to check
CONFIG_POSIX.  This causes make targets to be generated for qtest test
cases even though we don't know how to build the binaries.

The following error message is printed when trying to run gtester on a
binary that was never built:

  GLib-WARNING **: Failed to execute test binary: tests/endianness-test.exe: Failed to execute child process "tests/endianness-test.exe" (No such file or directory)

This patch makes QTEST_TARGETS empty on non-POSIX hosts.  This prevents
the targets from being generated.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
nvme: Permit zero-length block devices

It may not be sensible for normal use cases, but it allows to use
/dev/null in QTest.

Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
tests: Add nvme qtest

Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
tests: Add virtio-9p qtest

Make it conditional to 9p availability.
Create a temporary directory to share.

Signed-off-by: Andreas Färber <afaerber@suse.de>
tests: Add pvpanic qtest

Signed-off-by: Andreas Färber <afaerber@suse.de>
qtest: Factor out qtest_qmp_receive()

Signed-off-by: Andreas Färber <afaerber@suse.de>
pvpanic-test: Assert pause event

Signed-off-by: Andreas Färber <afaerber@suse.de>
tests: Add i82801b11 qtest

Signed-off-by: Andreas Färber <afaerber@suse.de>
tmp105: Read temperature in milli-celsius

Right now, the temperature property must be written in milli-celsius,
but it reads back the value in 8.8 fixed point.  Fix this by letting the
property read back the original value (possibly rounded).  Also simplify
the code that does the conversion.

Before:

    (QEMU) qom-set path=/machine/peripheral/sensor property=temperature value=20000
    {u'return': {}}
    (QEMU) qom-get path=sensor property=temperature
    {u'return': 5120}

After:

    (QEMU) qom-set path=/machine/peripheral/sensor property=temperature value=20000
    {u'return': {}}
    (QEMU) qom-get path=sensor property=temperature
    {u'return': 20000}

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
tmp105-test: Wrap simple building blocks for testing

The next patches will add more reads and writes.  Add a simple testing
API for this.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
tmp105-test: Add a second sensor and test that one

This will make it easier to reach the device under test via QOM.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
tmp105-test: Test QOM property and precision

This adds a regression test for commit
efdf6a56a7c73753dd135ed085a223a119b5d805 (tmp105: Read temperature in
milli-celsius).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
tests: Add ivshmem qtest

Note that it launches two instances to as sharing memory is the purpose
of Nahanni/ivshmem.

Cc: Cam Macdonell <cam@cs.ualberta.ca>
Signed-off-by: Andreas Färber <afaerber@suse.de>
tests: Add ac97 qtest

Signed-off-by: Andreas Färber <afaerber@suse.de>
tests: Add es1370 qtest

Signed-off-by: Andreas Färber <afaerber@suse.de>
tests: Add intel-hda qtests

Test both the ich6 and the ich9 version (cf. q35 config) and all the
codecs.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>