qemu/tests/qtest
Alex Bennée 5b4f72f5e8 tests/qtest: properly initialise the vring used idx
Eric noticed while attempting to enable the vhost-user-blk-test for
Aarch64 that that things didn't work unless he put in a dummy
guest_malloc() at the start of the test. Without it
qvirtio_wait_used_elem() would assert when it reads a junk value for
idx resulting in:

  qvirtqueue_get_buf: idx:2401 last_idx:0
  qvirtqueue_get_buf: 0x7ffcb6d3fe74, (nil)
  qvirtio_wait_used_elem: 3000000/0
  ERROR:../../tests/qtest/libqos/virtio.c:226:qvirtio_wait_used_elem: assertion failed (got_desc_idx == desc_idx): (50331648 == 0)
  Bail out! ERROR:../../tests/qtest/libqos/virtio.c:226:qvirtio_wait_used_elem: assertion failed (got_desc_idx == desc_idx): (50331648 == 0)

What was actually happening is the guest_malloc() effectively pushed
the allocation of the vring into the next page which just happened to
have clear memory. After much tedious tracing of the code I could see
that qvring_init() does attempt initialise a bunch of the vring
structures but skips the vring->used.idx value. It is probably not
wise to assume guest memory is zeroed anyway. Once the ring is
properly initialised the hack is no longer needed to get things
working.

Thanks-to: John Snow <jsnow@redhat.com> for helping debug
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20220406173356.1891500-1-alex.bennee@linaro.org>
Tested-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
2022-04-20 09:01:21 +02:00
..
fuzz Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
libqos tests/qtest: properly initialise the vring used idx 2022-04-20 09:01:21 +02:00
ac97-test.c
acpi-utils.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
acpi-utils.h
adm1272-test.c tests/qtest: add tests for ADM1272 device model 2021-07-08 14:41:59 -05:00
ahci-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
am53c974-test.c qtest/am53c974-test: add test for reset before transfer 2021-11-19 10:14:30 +01:00
arm-cpu-features.c tests: arm-cpu-features: use qtest_has_kvm() API 2021-10-20 04:37:55 -04:00
aspeed_hace-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
aspeed_smc-test.c
bios-tables-test-allowed-diff.h tests/acpi: i386: update FACP table differences 2022-03-06 16:06:16 -05:00
bios-tables-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
boot-order-test.c tests/qtest/boot-order-test: Check whether machines are available 2021-12-22 08:13:05 +01:00
boot-sector.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
boot-sector.h
boot-serial-test.c tests/qtest/boot-serial-test: Silence the warning about deprecated sga device 2021-12-22 08:13:05 +01:00
cdrom-test.c hw/i386: Add the possibility to disable the 'isapc' machine 2022-02-04 09:07:43 -05:00
cmsdk-apb-dualtimer-test.c
cmsdk-apb-timer-test.c
cmsdk-apb-watchdog-test.c
cpu-plug-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
dbus-display-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
dbus-vmstate-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
device-introspect-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
device-plug-test.c tests/x86: Use 'pc' machine type for hotplug tests 2022-02-21 10:13:23 +01:00
display-vga-test.c
drive_del-test.c tests/x86: Use 'pc' machine type for hotplug tests 2022-02-21 10:13:23 +01:00
ds1338-test.c
e1000-test.c
e1000e-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
eepro100-test.c
emc141x-test.c sensor: Move hardware sensors from misc to a sensor directory 2021-06-17 07:10:32 -05:00
endianness-test.c tests/qtest: Enable more tests for the "mipsel" target 2022-04-20 08:54:39 +02:00
erst-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
es1370-test.c
fdc-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
fuzz-e1000e-test.c
fuzz-lsi53c895a-test.c tests/qtest: Move the fuzz tests to x86 only 2022-04-20 08:59:04 +02:00
fuzz-megasas-test.c tests/qtest: Move the fuzz tests to x86 only 2022-04-20 08:59:04 +02:00
fuzz-sb16-test.c tests/qtest: Move the fuzz tests to x86 only 2022-04-20 08:59:04 +02:00
fuzz-sdcard-test.c tests/qtest: Move the fuzz tests to x86 only 2022-04-20 08:59:04 +02:00
fuzz-virtio-scsi-test.c tests/qtest: Move the fuzz tests to x86 only 2022-04-20 08:59:04 +02:00
fuzz-xlnx-dp-test.c hw/display/xlnx_dp: fix an out-of-bounds read in xlnx_dp_read 2021-08-31 14:34:36 +02:00
fw_cfg-test.c
hd-geo-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
hexloader-test.c
i440fx-test.c tests/x86: Use 'pc' machine type for old hardware tests 2022-02-21 10:13:23 +01:00
i82801b11-test.c
ide-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
intel-hda-test.c tests/qtest/intel-hda-test: Add reproducer for issue #542 2022-03-21 10:25:21 +01:00
ioh3420-test.c
ipmi-bt-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
ipmi-kcs-test.c tests: Avoid side effects inside g_assert() arguments 2021-05-14 12:28:01 +02:00
ipoctal232-test.c
isl_pmbus_vr-test.c hw/sensor: add Renesas raa228000 device 2022-03-08 18:46:48 +01:00
ivshmem-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
libqtest-single.h Replace GCC_FMT_ATTR with G_GNUC_PRINTF 2022-03-22 14:40:51 +04:00
libqtest.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
lpc-ich9-test.c
lsm303dlhc-mag-test.c hw/sensor: Add lsm303dlhc magnetometer device 2022-02-08 10:56:29 +00:00
m48t59-test.c
machine-none-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
max34451-test.c tests/qtest: add tests for MAX34451 device model 2021-07-08 14:42:00 -05:00
megasas-test.c
meson.build tests/qtest: Move the fuzz tests to x86 only 2022-04-20 08:59:04 +02:00
microbit-test.c
migration-helpers.c
migration-helpers.h Replace GCC_FMT_ATTR with G_GNUC_PRINTF 2022-03-22 14:40:51 +04:00
migration-test.c tests: Pass in MigrateStart** into test_migrate_start() 2022-03-02 18:20:45 +00:00
modules-test.c
ne2000-test.c
npcm7xx_adc-test.c
npcm7xx_emc-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
npcm7xx_gpio-test.c
npcm7xx_pwm-test.c tests/qtest/npcm7xx_pwm-test.c: Avoid g_assert_true() for non-test assertions 2021-05-14 12:28:01 +02:00
npcm7xx_rng-test.c include: move C/util-related declarations to cutils.h 2022-04-06 14:31:43 +02:00
npcm7xx_sdhci-test.c tests/qtest: add qtests for npcm7xx sdhci 2022-03-02 19:27:36 +00:00
npcm7xx_smbus-test.c sensor: Move hardware sensors from misc to a sensor directory 2021-06-17 07:10:32 -05:00
npcm7xx_timer-test.c
npcm7xx_watchdog_timer-test.c
numa-test.c qtest/numa-test: Use detailed -smp CLIs in test_def_cpu_split 2021-10-01 15:27:56 +02:00
nvme-test.c tests/qtest/nvme-test: add mmio read test 2021-07-26 21:09:39 +02:00
pca9552-test.c
pci-test.c
pcnet-test.c
pflash-cfi02-test.c tests/qtest/pflash-cfi02-test: Avoid potential integer overflow 2021-06-03 16:43:27 +01:00
pnv-xscom-test.c
prom-env-test.c tests/qtest: Add a function to check whether a machine is available 2021-12-15 08:08:59 +01:00
pvpanic-pci-test.c
pvpanic-test.c
pxe-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
q35-test.c
qmp-cmd-test.c qapi: introduce x-query-opcount QMP command 2021-11-02 15:57:20 +00:00
qmp-test.c
qom-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
qos-test.c
rtas-test.c spapr: Implement Open Firmware client interface 2021-07-09 10:38:19 +10:00
rtc-test.c tests/qtest/rtc-test: Remove pointless NULL check 2021-05-14 12:28:01 +02:00
rtl8139-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
sdhci-test.c
spapr-phb-test.c
sse-timer-test.c
tco-test.c
test-arm-mptimer.c
test-filter-mirror.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
test-filter-redirector.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
test-hmp.c
test-netfilter.c tests/qtest: Make the filter tests independent from a specific NIC 2021-12-22 08:13:05 +01:00
test-x86-cpuid-compat.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
tmp105-test.c sensor: Move hardware sensors from misc to a sensor directory 2021-06-17 07:10:32 -05:00
tpm-crb-swtpm-test.c
tpm-crb-test.c tests: Add tpm_version field to TPMTestState and fill it 2021-08-31 17:33:11 -04:00
tpm-emu.c tests: Use QMP to check whether a TPM device model is available 2021-08-31 17:33:12 -04:00
tpm-emu.h tests: Use QMP to check whether a TPM device model is available 2021-08-31 17:33:12 -04:00
tpm-tests.c tests/qtest/tpm-tests: Remove unnecessary NULL checks 2021-06-03 16:43:27 +01:00
tpm-tests.h
tpm-tis-device-swtpm-test.c
tpm-tis-device-test.c tests: Add tpm_version field to TPMTestState and fill it 2021-08-31 17:33:11 -04:00
tpm-tis-swtpm-test.c
tpm-tis-test.c tests: Add tpm_version field to TPMTestState and fill it 2021-08-31 17:33:11 -04:00
tpm-tis-util.c tests: Rename TestState to TPMTestState 2021-08-31 17:33:10 -04:00
tpm-tis-util.h
tpm-util.c tests/qtest/tpm-util.c: Free memory with correct free function 2021-05-14 12:28:01 +02:00
tpm-util.h
tulip-test.c
usb-hcd-ehci-test.c
usb-hcd-ohci-test.c
usb-hcd-uhci-test.c
usb-hcd-xhci-test.c
vhost-user-blk-test.c Replace config-time define HOST_WORDS_BIGENDIAN 2022-04-06 10:50:37 +02:00
vhost-user-test.c tests/qtest/vhost-user-test.c: Use vhostforce=on 2022-02-21 10:13:23 +01:00
virtio-9p-test.c 9pfs: Use g_new() & friends where that makes obvious sense 2022-03-21 15:44:44 +01:00
virtio-blk-test.c Replace config-time define HOST_WORDS_BIGENDIAN 2022-04-06 10:50:37 +02:00
virtio-ccw-test.c
virtio-iommu-test.c tests/qtest/virtio-iommu-test: Check bypass config 2022-03-06 05:08:23 -05:00
virtio-net-failover.c tests/qtest: failover: fix infinite loop 2022-03-29 16:40:05 +01:00
virtio-net-test.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
virtio-rng-test.c
virtio-scsi-test.c tests/qtest/virtio-scsi-test: add unmap large LBA with 4k blocks test 2021-06-04 13:47:08 +02:00
virtio-serial-test.c
virtio-test.c
vmgenid-test.c
vmxnet3-test.c
wdt_ib700-test.c
xlnx-can-test.c