aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.include471
-rw-r--r--tests/acceptance/avocado_qemu/__init__.py3
-rw-r--r--tests/acceptance/boot_linux_console.py13
-rw-r--r--tests/acceptance/machine_rx_gdbsim.py4
-rw-r--r--tests/acceptance/replay_kernel.py1
-rwxr-xr-xtests/data/acpi/rebuild-expected-aml.sh2
-rw-r--r--tests/docker/dockerfiles/debian-amd64.docker4
-rwxr-xr-xtests/docker/test-static24
-rw-r--r--tests/fp/Makefile600
-rw-r--r--tests/fp/fp-test.c2
-rw-r--r--tests/fp/meson.build636
-rw-r--r--tests/fp/wrap.c.inc (renamed from tests/fp/wrap.inc.c)0
-rw-r--r--tests/meson.build18
-rwxr-xr-xtests/multiboot/run_test.sh2
-rw-r--r--tests/plugin/Makefile46
-rw-r--r--tests/plugin/meson.build7
-rw-r--r--tests/qapi-schema/doc-good.json2
-rw-r--r--tests/qapi-schema/include/sub-module.json1
-rw-r--r--tests/qapi-schema/meson.build225
-rw-r--r--tests/qapi-schema/qapi-schema-test.json1
-rw-r--r--tests/qapi-schema/sub-sub-module.json1
-rw-r--r--tests/qemu-iotests/031.out8
-rw-r--r--tests/qemu-iotests/036.out4
-rw-r--r--tests/qemu-iotests/049.out102
-rw-r--r--tests/qemu-iotests/060.out3
-rwxr-xr-xtests/qemu-iotests/0616
-rw-r--r--tests/qemu-iotests/061.out25
-rwxr-xr-xtests/qemu-iotests/06512
-rw-r--r--tests/qemu-iotests/082.out39
-rw-r--r--tests/qemu-iotests/085.out38
-rw-r--r--tests/qemu-iotests/144.out4
-rwxr-xr-xtests/qemu-iotests/16964
-rw-r--r--tests/qemu-iotests/169.out4
-rw-r--r--tests/qemu-iotests/182.out2
-rw-r--r--tests/qemu-iotests/185.out8
-rwxr-xr-xtests/qemu-iotests/1982
-rw-r--r--tests/qemu-iotests/206.out6
-rw-r--r--tests/qemu-iotests/242.out5
-rw-r--r--tests/qemu-iotests/255.out8
-rwxr-xr-xtests/qemu-iotests/26476
-rw-r--r--tests/qemu-iotests/264.out2
-rwxr-xr-xtests/qemu-iotests/271901
-rw-r--r--tests/qemu-iotests/271.out726
-rw-r--r--tests/qemu-iotests/274.out49
-rw-r--r--tests/qemu-iotests/280.out2
-rw-r--r--tests/qemu-iotests/291.out2
-rwxr-xr-xtests/qemu-iotests/300593
-rw-r--r--tests/qemu-iotests/300.out5
-rwxr-xr-xtests/qemu-iotests/302127
-rw-r--r--tests/qemu-iotests/302.out32
-rwxr-xr-xtests/qemu-iotests/30363
-rw-r--r--tests/qemu-iotests/303.out158
-rwxr-xr-xtests/qemu-iotests/30460
-rw-r--r--tests/qemu-iotests/304.out2
-rwxr-xr-xtests/qemu-iotests/check6
-rw-r--r--tests/qemu-iotests/common.filter1
-rw-r--r--tests/qemu-iotests/group5
-rw-r--r--tests/qemu-iotests/iotests.py52
-rw-r--r--tests/qemu-iotests/meson.build10
-rwxr-xr-xtests/qemu-iotests/qcow2.py18
-rw-r--r--tests/qemu-iotests/qcow2_format.py215
-rw-r--r--tests/qtest/Makefile.include332
-rw-r--r--tests/qtest/ac97-test.c2
-rw-r--r--tests/qtest/acpi-utils.h2
-rw-r--r--tests/qtest/ahci-test.c2
-rw-r--r--tests/qtest/arm-cpu-features.c2
-rw-r--r--tests/qtest/bios-tables-test.c2
-rw-r--r--tests/qtest/boot-order-test.c2
-rw-r--r--tests/qtest/boot-sector.c2
-rw-r--r--tests/qtest/boot-sector.h2
-rw-r--r--tests/qtest/boot-serial-test.c2
-rw-r--r--tests/qtest/cdrom-test.c2
-rw-r--r--tests/qtest/dbus-vmstate-test.c2
-rw-r--r--tests/qtest/device-introspect-test.c2
-rw-r--r--tests/qtest/device-plug-test.c2
-rw-r--r--tests/qtest/drive_del-test.c2
-rw-r--r--tests/qtest/ds1338-test.c2
-rw-r--r--tests/qtest/e1000-test.c2
-rw-r--r--tests/qtest/eepro100-test.c2
-rw-r--r--tests/qtest/endianness-test.c2
-rw-r--r--tests/qtest/es1370-test.c2
-rw-r--r--tests/qtest/fuzz/Makefile.include39
-rw-r--r--tests/qtest/fuzz/fuzz.c2
-rw-r--r--tests/qtest/fuzz/fuzz.h2
-rw-r--r--tests/qtest/fuzz/i440fx_fuzz.c6
-rw-r--r--tests/qtest/fuzz/meson.build35
-rw-r--r--tests/qtest/fuzz/qos_fuzz.c2
-rw-r--r--tests/qtest/fuzz/qtest_wrappers.c2
-rw-r--r--tests/qtest/fuzz/virtio_net_fuzz.c5
-rw-r--r--tests/qtest/fuzz/virtio_scsi_fuzz.c8
-rw-r--r--tests/qtest/fw_cfg-test.c2
-rw-r--r--tests/qtest/hd-geo-test.c2
-rw-r--r--tests/qtest/hexloader-test.c2
-rw-r--r--tests/qtest/ide-test.c2
-rw-r--r--tests/qtest/ipoctal232-test.c2
-rw-r--r--tests/qtest/ivshmem-test.c2
-rw-r--r--tests/qtest/libqos/aarch64-xlnx-zcu102-machine.c4
-rw-r--r--tests/qtest/libqos/ahci.c6
-rw-r--r--tests/qtest/libqos/ahci.h6
-rw-r--r--tests/qtest/libqos/arm-imx25-pdk-machine.c6
-rw-r--r--tests/qtest/libqos/arm-n800-machine.c6
-rw-r--r--tests/qtest/libqos/arm-raspi2-machine.c4
-rw-r--r--tests/qtest/libqos/arm-sabrelite-machine.c4
-rw-r--r--tests/qtest/libqos/arm-smdkc210-machine.c4
-rw-r--r--tests/qtest/libqos/arm-virt-machine.c6
-rw-r--r--tests/qtest/libqos/arm-xilinx-zynq-a9-machine.c4
-rw-r--r--tests/qtest/libqos/e1000e.c6
-rw-r--r--tests/qtest/libqos/e1000e.h2
-rw-r--r--tests/qtest/libqos/fw_cfg.c2
-rw-r--r--tests/qtest/libqos/i2c-imx.c2
-rw-r--r--tests/qtest/libqos/i2c-omap.c2
-rw-r--r--tests/qtest/libqos/i2c.c2
-rw-r--r--tests/qtest/libqos/i2c.h2
-rw-r--r--tests/qtest/libqos/libqos-pc.c6
-rw-r--r--tests/qtest/libqos/libqos-pc.h2
-rw-r--r--tests/qtest/libqos/libqos-spapr.c6
-rw-r--r--tests/qtest/libqos/libqos-spapr.h2
-rw-r--r--tests/qtest/libqos/libqos.c4
-rw-r--r--tests/qtest/libqos/libqos.h4
-rw-r--r--tests/qtest/libqos/libqtest.h (renamed from tests/qtest/libqtest.h)0
-rw-r--r--tests/qtest/libqos/malloc-pc.c4
-rw-r--r--tests/qtest/libqos/malloc-pc.h2
-rw-r--r--tests/qtest/libqos/malloc-spapr.c2
-rw-r--r--tests/qtest/libqos/malloc-spapr.h2
-rw-r--r--tests/qtest/libqos/malloc.c2
-rw-r--r--tests/qtest/libqos/meson.build57
-rw-r--r--tests/qtest/libqos/pci-pc.c2
-rw-r--r--tests/qtest/libqos/pci-pc.h6
-rw-r--r--tests/qtest/libqos/pci-spapr.c6
-rw-r--r--tests/qtest/libqos/pci-spapr.h6
-rw-r--r--tests/qtest/libqos/pci.c4
-rw-r--r--tests/qtest/libqos/pci.h2
-rw-r--r--tests/qtest/libqos/ppc64_pseries-machine.c4
-rw-r--r--tests/qtest/libqos/qgraph.c4
-rw-r--r--tests/qtest/libqos/qgraph.h8
-rw-r--r--tests/qtest/libqos/qgraph_internal.h4
-rw-r--r--tests/qtest/libqos/qos_external.c8
-rw-r--r--tests/qtest/libqos/qos_external.h4
-rw-r--r--tests/qtest/libqos/rtas.c2
-rw-r--r--tests/qtest/libqos/rtas.h2
-rw-r--r--tests/qtest/libqos/sdhci.c2
-rw-r--r--tests/qtest/libqos/sdhci.h2
-rw-r--r--tests/qtest/libqos/tpci200.c4
-rw-r--r--tests/qtest/libqos/usb.c2
-rw-r--r--tests/qtest/libqos/usb.h2
-rw-r--r--tests/qtest/libqos/virtio-9p.c4
-rw-r--r--tests/qtest/libqos/virtio-9p.h6
-rw-r--r--tests/qtest/libqos/virtio-balloon.c4
-rw-r--r--tests/qtest/libqos/virtio-balloon.h6
-rw-r--r--tests/qtest/libqos/virtio-blk.c4
-rw-r--r--tests/qtest/libqos/virtio-blk.h6
-rw-r--r--tests/qtest/libqos/virtio-mmio.c8
-rw-r--r--tests/qtest/libqos/virtio-mmio.h4
-rw-r--r--tests/qtest/libqos/virtio-net.c4
-rw-r--r--tests/qtest/libqos/virtio-net.h6
-rw-r--r--tests/qtest/libqos/virtio-pci.c14
-rw-r--r--tests/qtest/libqos/virtio-pci.h6
-rw-r--r--tests/qtest/libqos/virtio-rng.c4
-rw-r--r--tests/qtest/libqos/virtio-rng.h6
-rw-r--r--tests/qtest/libqos/virtio-scsi.c4
-rw-r--r--tests/qtest/libqos/virtio-scsi.h6
-rw-r--r--tests/qtest/libqos/virtio-serial.c4
-rw-r--r--tests/qtest/libqos/virtio-serial.h6
-rw-r--r--tests/qtest/libqos/virtio.c2
-rw-r--r--tests/qtest/libqos/virtio.h2
-rw-r--r--tests/qtest/libqos/x86_64_pc-machine.c2
-rw-r--r--tests/qtest/libqtest-single.h2
-rw-r--r--tests/qtest/libqtest.c2
-rw-r--r--tests/qtest/m48t59-test.c2
-rw-r--r--tests/qtest/machine-none-test.c2
-rw-r--r--tests/qtest/megasas-test.c2
-rw-r--r--tests/qtest/meson.build257
-rw-r--r--tests/qtest/microbit-test.c2
-rw-r--r--tests/qtest/migration-helpers.h2
-rw-r--r--tests/qtest/migration-test.c4
-rw-r--r--tests/qtest/modules-test.c2
-rw-r--r--tests/qtest/ne2000-test.c2
-rw-r--r--tests/qtest/numa-test.c2
-rw-r--r--tests/qtest/nvme-test.c2
-rw-r--r--tests/qtest/pca9552-test.c2
-rw-r--r--tests/qtest/pci-test.c2
-rw-r--r--tests/qtest/pcnet-test.c2
-rw-r--r--tests/qtest/pflash-cfi02-test.c2
-rw-r--r--tests/qtest/pnv-xscom-test.c2
-rw-r--r--tests/qtest/prom-env-test.c2
-rw-r--r--tests/qtest/pvpanic-test.c2
-rw-r--r--tests/qtest/pxe-test.c2
-rw-r--r--tests/qtest/q35-test.c2
-rw-r--r--tests/qtest/qmp-cmd-test.c2
-rw-r--r--tests/qtest/qmp-test.c2
-rw-r--r--tests/qtest/qom-test.c2
-rw-r--r--tests/qtest/rtas-test.c4
-rw-r--r--tests/qtest/sdhci-test.c2
-rw-r--r--tests/qtest/spapr-phb-test.c2
-rw-r--r--tests/qtest/tco-test.c2
-rw-r--r--tests/qtest/test-filter-mirror.c2
-rw-r--r--tests/qtest/test-filter-redirector.c2
-rw-r--r--tests/qtest/test-hmp.c2
-rw-r--r--tests/qtest/tpm-crb-swtpm-test.c2
-rw-r--r--tests/qtest/tpm-tis-device-swtpm-test.c2
-rw-r--r--tests/qtest/tpm-tis-swtpm-test.c2
-rw-r--r--tests/qtest/tpm-util.c2
-rw-r--r--tests/qtest/tulip-test.c2
-rw-r--r--tests/qtest/virtio-9p-test.c108
-rw-r--r--tests/qtest/virtio-rng-test.c2
-rw-r--r--tests/qtest/virtio-test.c2
-rw-r--r--tests/qtest/vmgenid-test.c2
-rw-r--r--tests/qtest/vmxnet3-test.c2
-rw-r--r--tests/qtest/wdt_ib700-test.c2
-rw-r--r--tests/tcg/aarch64/Makefile.target2
-rw-r--r--tests/tcg/aarch64/pauth-5.c33
-rwxr-xr-xtests/tcg/configure.sh4
-rw-r--r--tests/tcg/xtensa/fpu.h142
-rw-r--r--tests/tcg/xtensa/macros.inc10
-rw-r--r--tests/tcg/xtensa/test_dfp0_arith.S162
-rw-r--r--tests/tcg/xtensa/test_fp0_arith.S282
-rw-r--r--tests/tcg/xtensa/test_fp0_conv.S299
-rw-r--r--tests/tcg/xtensa/test_fp0_div.S82
-rw-r--r--tests/tcg/xtensa/test_fp0_sqrt.S76
-rw-r--r--tests/tcg/xtensa/test_fp1.S62
-rw-r--r--tests/tcg/xtensa/test_lsc.S170
-rw-r--r--tests/test-char.c2
-rw-r--r--tests/test-qga.c10
-rw-r--r--tests/test-qgraph.c5
-rw-r--r--tests/test-util-sockets.c4
-rw-r--r--tests/vm/Makefile.include8
-rwxr-xr-xtests/vm/freebsd2
-rwxr-xr-xtests/vm/netbsd2
-rwxr-xr-xtests/vm/openbsd2
229 files changed, 5917 insertions, 2227 deletions
diff --git a/tests/Makefile.include b/tests/Makefile.include
index c7e4646ded..9ac8f5b86a 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -109,6 +109,7 @@ check-unit-y += tests/test-qht$(EXESUF)
check-unit-y += tests/test-qht-par$(EXESUF)
check-unit-y += tests/test-bitops$(EXESUF)
check-unit-y += tests/test-bitcnt$(EXESUF)
+check-unit-y += tests/test-qgraph$(EXESUF)
check-unit-y += tests/check-qom-interface$(EXESUF)
check-unit-y += tests/check-qom-proplist$(EXESUF)
check-unit-y += tests/test-qemu-opts$(EXESUF)
@@ -129,7 +130,7 @@ ifndef CONFIG_TSAN
# https://github.com/google/sanitizers/issues/1116
check-unit-$(CONFIG_SOFTMMU) += tests/test-char$(EXESUF)
check-unit-$(CONFIG_SOFTMMU) += tests/test-qdev-global-props$(EXESUF)
-ifneq (,$(findstring qemu-ga,$(TOOLS)))
+ifeq ($(CONFIG_GUEST_AGENT),y)
check-unit-$(call land,$(CONFIG_LINUX),$(CONFIG_VIRTIO_SERIAL)) += tests/test-qga$(EXESUF)
endif
endif
@@ -159,203 +160,6 @@ check-unit-y += tests/test-uuid$(EXESUF)
check-unit-y += tests/ptimer-test$(EXESUF)
check-unit-y += tests/test-qapi-util$(EXESUF)
-check-block-$(call land,$(CONFIG_POSIX),$(CONFIG_SOFTMMU)) += tests/check-block.sh
-
-qapi-schema += alternate-any.json
-qapi-schema += alternate-array.json
-qapi-schema += alternate-base.json
-qapi-schema += alternate-branch-if-invalid.json
-qapi-schema += alternate-clash.json
-qapi-schema += alternate-conflict-dict.json
-qapi-schema += alternate-conflict-enum-bool.json
-qapi-schema += alternate-conflict-enum-int.json
-qapi-schema += alternate-conflict-string.json
-qapi-schema += alternate-conflict-bool-string.json
-qapi-schema += alternate-conflict-num-string.json
-qapi-schema += alternate-empty.json
-qapi-schema += alternate-invalid-dict.json
-qapi-schema += alternate-nested.json
-qapi-schema += alternate-unknown.json
-qapi-schema += args-alternate.json
-qapi-schema += args-any.json
-qapi-schema += args-array-empty.json
-qapi-schema += args-array-unknown.json
-qapi-schema += args-bad-boxed.json
-qapi-schema += args-boxed-anon.json
-qapi-schema += args-boxed-string.json
-qapi-schema += args-int.json
-qapi-schema += args-invalid.json
-qapi-schema += args-member-array-bad.json
-qapi-schema += args-member-case.json
-qapi-schema += args-member-unknown.json
-qapi-schema += args-name-clash.json
-qapi-schema += args-union.json
-qapi-schema += args-unknown.json
-qapi-schema += bad-base.json
-qapi-schema += bad-data.json
-qapi-schema += bad-ident.json
-qapi-schema += bad-if.json
-qapi-schema += bad-if-empty.json
-qapi-schema += bad-if-empty-list.json
-qapi-schema += bad-if-list.json
-qapi-schema += bad-type-bool.json
-qapi-schema += bad-type-dict.json
-qapi-schema += bad-type-int.json
-qapi-schema += base-cycle-direct.json
-qapi-schema += base-cycle-indirect.json
-qapi-schema += command-int.json
-qapi-schema += comments.json
-qapi-schema += doc-bad-alternate-member.json
-qapi-schema += doc-bad-boxed-command-arg.json
-qapi-schema += doc-bad-command-arg.json
-qapi-schema += doc-bad-enum-member.json
-qapi-schema += doc-bad-event-arg.json
-qapi-schema += doc-bad-feature.json
-qapi-schema += doc-bad-section.json
-qapi-schema += doc-bad-symbol.json
-qapi-schema += doc-bad-union-member.json
-qapi-schema += doc-before-include.json
-qapi-schema += doc-before-pragma.json
-qapi-schema += doc-duplicated-arg.json
-qapi-schema += doc-duplicated-return.json
-qapi-schema += doc-duplicated-since.json
-qapi-schema += doc-empty-arg.json
-qapi-schema += doc-empty-section.json
-qapi-schema += doc-empty-symbol.json
-qapi-schema += doc-good.json
-qapi-schema += doc-interleaved-section.json
-qapi-schema += doc-invalid-end.json
-qapi-schema += doc-invalid-end2.json
-qapi-schema += doc-invalid-return.json
-qapi-schema += doc-invalid-section.json
-qapi-schema += doc-invalid-start.json
-qapi-schema += doc-missing-colon.json
-qapi-schema += doc-missing-expr.json
-qapi-schema += doc-missing-space.json
-qapi-schema += doc-missing.json
-qapi-schema += doc-no-symbol.json
-qapi-schema += doc-undoc-feature.json
-qapi-schema += double-type.json
-qapi-schema += duplicate-key.json
-qapi-schema += empty.json
-qapi-schema += enum-bad-member.json
-qapi-schema += enum-bad-name.json
-qapi-schema += enum-bad-prefix.json
-qapi-schema += enum-clash-member.json
-qapi-schema += enum-dict-member-unknown.json
-qapi-schema += enum-if-invalid.json
-qapi-schema += enum-int-member.json
-qapi-schema += enum-member-case.json
-qapi-schema += enum-missing-data.json
-qapi-schema += enum-wrong-data.json
-qapi-schema += event-boxed-empty.json
-qapi-schema += event-case.json
-qapi-schema += event-member-invalid-dict.json
-qapi-schema += event-nest-struct.json
-qapi-schema += features-bad-type.json
-qapi-schema += features-deprecated-type.json
-qapi-schema += features-duplicate-name.json
-qapi-schema += features-if-invalid.json
-qapi-schema += features-missing-name.json
-qapi-schema += features-name-bad-type.json
-qapi-schema += features-no-list.json
-qapi-schema += features-unknown-key.json
-qapi-schema += flat-union-array-branch.json
-qapi-schema += flat-union-bad-base.json
-qapi-schema += flat-union-bad-discriminator.json
-qapi-schema += flat-union-base-any.json
-qapi-schema += flat-union-base-union.json
-qapi-schema += flat-union-clash-member.json
-qapi-schema += flat-union-discriminator-bad-name.json
-qapi-schema += flat-union-empty.json
-qapi-schema += flat-union-inline.json
-qapi-schema += flat-union-inline-invalid-dict.json
-qapi-schema += flat-union-int-branch.json
-qapi-schema += flat-union-invalid-branch-key.json
-qapi-schema += flat-union-invalid-discriminator.json
-qapi-schema += flat-union-invalid-if-discriminator.json
-qapi-schema += flat-union-no-base.json
-qapi-schema += flat-union-optional-discriminator.json
-qapi-schema += flat-union-string-discriminator.json
-qapi-schema += funny-char.json
-qapi-schema += funny-word.json
-qapi-schema += ident-with-escape.json
-qapi-schema += include-before-err.json
-qapi-schema += include-cycle.json
-qapi-schema += include-extra-junk.json
-qapi-schema += include-nested-err.json
-qapi-schema += include-no-file.json
-qapi-schema += include-non-file.json
-qapi-schema += include-repetition.json
-qapi-schema += include-self-cycle.json
-qapi-schema += include-simple.json
-qapi-schema += indented-expr.json
-qapi-schema += leading-comma-list.json
-qapi-schema += leading-comma-object.json
-qapi-schema += missing-colon.json
-qapi-schema += missing-comma-list.json
-qapi-schema += missing-comma-object.json
-qapi-schema += missing-type.json
-qapi-schema += nested-struct-data.json
-qapi-schema += nested-struct-data-invalid-dict.json
-qapi-schema += non-objects.json
-qapi-schema += oob-test.json
-qapi-schema += allow-preconfig-test.json
-qapi-schema += pragma-doc-required-crap.json
-qapi-schema += pragma-extra-junk.json
-qapi-schema += pragma-name-case-whitelist-crap.json
-qapi-schema += pragma-non-dict.json
-qapi-schema += pragma-unknown.json
-qapi-schema += pragma-returns-whitelist-crap.json
-qapi-schema += qapi-schema-test.json
-qapi-schema += quoted-structural-chars.json
-qapi-schema += redefined-builtin.json
-qapi-schema += redefined-command.json
-qapi-schema += redefined-event.json
-qapi-schema += redefined-type.json
-qapi-schema += reserved-command-q.json
-qapi-schema += reserved-enum-q.json
-qapi-schema += reserved-member-has.json
-qapi-schema += reserved-member-q.json
-qapi-schema += reserved-member-u.json
-qapi-schema += reserved-member-underscore.json
-qapi-schema += reserved-type-kind.json
-qapi-schema += reserved-type-list.json
-qapi-schema += returns-alternate.json
-qapi-schema += returns-array-bad.json
-qapi-schema += returns-dict.json
-qapi-schema += returns-unknown.json
-qapi-schema += returns-whitelist.json
-qapi-schema += string-code-point-31.json
-qapi-schema += string-code-point-127.json
-qapi-schema += struct-base-clash-deep.json
-qapi-schema += struct-base-clash.json
-qapi-schema += struct-data-invalid.json
-qapi-schema += struct-member-if-invalid.json
-qapi-schema += struct-member-invalid-dict.json
-qapi-schema += struct-member-invalid.json
-qapi-schema += trailing-comma-list.json
-qapi-schema += trailing-comma-object.json
-qapi-schema += type-bypass-bad-gen.json
-qapi-schema += unclosed-list.json
-qapi-schema += unclosed-object.json
-qapi-schema += unclosed-string.json
-qapi-schema += union-base-empty.json
-qapi-schema += union-base-no-discriminator.json
-qapi-schema += union-branch-case.json
-qapi-schema += union-branch-if-invalid.json
-qapi-schema += union-branch-invalid-dict.json
-qapi-schema += union-clash-branches.json
-qapi-schema += union-empty.json
-qapi-schema += union-invalid-base.json
-qapi-schema += union-optional-branch.json
-qapi-schema += union-unknown.json
-qapi-schema += unknown-escape.json
-qapi-schema += unknown-expr-key.json
-
-
-check-qapi-schema-y := $(addprefix tests/qapi-schema/, $(qapi-schema))
-
generated-files-y += tests/test-qapi-types.h
generated-files-y += tests/include/test-qapi-types-sub-module.h
generated-files-y += tests/test-qapi-types-sub-sub-module.h
@@ -421,7 +225,8 @@ tests/test-iov$(EXESUF): tests/test-iov.o $(test-util-obj-y)
tests/test-hbitmap$(EXESUF): tests/test-hbitmap.o $(test-util-obj-y) $(test-crypto-obj-y)
tests/test-bitmap$(EXESUF): tests/test-bitmap.o $(test-util-obj-y)
tests/test-x86-cpuid$(EXESUF): tests/test-x86-cpuid.o
-tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/xbzrle.o migration/page_cache.o $(test-util-obj-y)
+tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/libmigration.fa $(test-util-obj-y) \
+ $(test-io-obj-y)
tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.o $(test-util-obj-y)
tests/test-int128$(EXESUF): tests/test-int128.o
tests/rcutorture$(EXESUF): tests/rcutorture.o $(test-util-obj-y)
@@ -437,22 +242,9 @@ tests/test-bufferiszero$(EXESUF): tests/test-bufferiszero.o $(test-util-obj-y)
tests/atomic_add-bench$(EXESUF): tests/atomic_add-bench.o $(test-util-obj-y)
tests/atomic64-bench$(EXESUF): tests/atomic64-bench.o $(test-util-obj-y)
-tests/fp/%:
- $(MAKE) -C $(dir $@) $(notdir $@)
-
-tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \
- hw/core/qdev.o hw/core/qdev-properties.o hw/core/hotplug.o\
- hw/core/bus.o \
- hw/core/resettable.o \
- hw/core/irq.o \
- hw/core/fw-path-provider.o \
- hw/core/reset.o \
- hw/core/vmstate-if.o \
- hw/core/clock.o hw/core/qdev-clock.o \
+tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o hw/core/libhwcore.fa \
$(test-qapi-obj-y)
-tests/test-vmstate$(EXESUF): tests/test-vmstate.o \
- migration/vmstate.o migration/vmstate-types.o migration/qemu-file.o \
- migration/qemu-file-channel.o migration/qjson.o \
+tests/test-vmstate$(EXESUF): tests/test-vmstate.o migration/libmigration.fa \
$(test-io-obj-y)
tests/test-timed-average$(EXESUF): tests/test-timed-average.o $(test-util-obj-y)
tests/test-base64$(EXESUF): tests/test-base64.o $(test-util-obj-y)
@@ -504,26 +296,6 @@ tests/test-qapi-gen-timestamp: \
@rm -f tests/test-qapi-doc.texi
@>$@
-tests/qapi-schema/doc-good.test.texi: $(SRC_PATH)/tests/qapi-schema/doc-good.json $(qapi-py)
- $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
- -o tests/qapi-schema -p "doc-good-" $<, \
- "GEN","$@")
- @mv tests/qapi-schema/doc-good-qapi-doc.texi $@
- @rm -f tests/qapi-schema/doc-good-qapi-*.[ch] tests/qapi-schema/doc-good-qmp-*.[ch]
-
-tests/qtest/dbus-vmstate1.h tests/qtest/dbus-vmstate1.c: tests/qtest/dbus-vmstate1-gen-timestamp ;
-tests/qtest/dbus-vmstate1-gen-timestamp: $(SRC_PATH)/tests/qtest/dbus-vmstate1.xml
- $(call quiet-command,$(GDBUS_CODEGEN) $< \
- --interface-prefix org.qemu --generate-c-code tests/qtest/dbus-vmstate1, \
- "GEN","$(@:%-timestamp=%)")
- @>$@
-
-tests/qtest/dbus-vmstate-test.o-cflags := -DSRCDIR="$(SRC_PATH)"
-tests/qtest/dbus-vmstate1.o-cflags := $(GIO_CFLAGS)
-tests/qtest/dbus-vmstate1.o-libs := $(GIO_LIBS)
-
-tests/qtest/dbus-vmstate-test.o: tests/qtest/dbus-vmstate1.h
-
tests/test-string-output-visitor$(EXESUF): tests/test-string-output-visitor.o $(test-qapi-obj-y)
tests/test-string-input-visitor$(EXESUF): tests/test-string-input-visitor.o $(test-qapi-obj-y)
tests/test-qmp-event$(EXESUF): tests/test-qmp-event.o $(test-qapi-obj-y) tests/test-qapi-emit-events.o tests/test-qapi-events.o
@@ -538,6 +310,7 @@ tests/test-shift128$(EXESUF): tests/test-shift128.o $(test-util-obj-y)
tests/test-mul64$(EXESUF): tests/test-mul64.o $(test-util-obj-y)
tests/test-bitops$(EXESUF): tests/test-bitops.o $(test-util-obj-y)
tests/test-bitcnt$(EXESUF): tests/test-bitcnt.o $(test-util-obj-y)
+tests/test-qgraph$(EXESUF): tests/test-qgraph.o tests/qtest/libqos/qgraph.o $(test-util-obj-y)
tests/test-crypto-hash$(EXESUF): tests/test-crypto-hash.o $(test-crypto-obj-y)
tests/benchmark-crypto-hash$(EXESUF): tests/benchmark-crypto-hash.o $(test-crypto-obj-y)
tests/test-crypto-hmac$(EXESUF): tests/test-crypto-hmac.o $(test-crypto-obj-y)
@@ -601,10 +374,8 @@ tests/migration/initrd-stress.img: tests/migration/stress$(EXESUF)
rm $(INITRD_WORK_DIR)/init
rmdir $(INITRD_WORK_DIR)
-include $(SRC_PATH)/tests/qtest/Makefile.include
-
-tests/test-qga$(EXESUF): qemu-ga$(EXESUF)
-tests/test-qga$(EXESUF): tests/test-qga.o $(qtest-obj-y)
+tests/test-qga$(EXESUF): qga/qemu-ga$(EXESUF)
+tests/test-qga$(EXESUF): tests/test-qga.o tests/qtest/libqtest.o $(test-util-obj-y)
tests/vhost-user-bridge$(EXESUF): tests/vhost-user-bridge.o $(test-util-obj-y) libvhost-user.a
tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o
@@ -645,14 +416,6 @@ define do_test_tap
"TAP","$@")
endef
-.PHONY: $(patsubst %, check-qtest-%, $(QTEST_TARGETS))
-$(patsubst %, check-qtest-%, $(QTEST_TARGETS)): check-qtest-%: %-softmmu/all $(check-qtest-y)
- $(call do_test_human,$(check-qtest-$*-y:%=tests/qtest/%$(EXESUF)) $(check-qtest-generic-y:%=tests/qtest/%$(EXESUF)), \
- QTEST_QEMU_BINARY=$*-softmmu/qemu-system-$* \
- QTEST_QEMU_IMG=qemu-img$(EXESUF))
-
-build-qtest: $(patsubst %, %-softmmu/all, $(QTEST_TARGETS)) $(check-qtest-y)
-
build-unit: $(check-unit-y)
check-unit: $(check-unit-y)
@@ -663,179 +426,9 @@ check-speed: $(check-speed-y)
# gtester tests with TAP output
-$(patsubst %, check-report-qtest-%.tap, $(QTEST_TARGETS)): check-report-qtest-%.tap: %-softmmu/all $(check-qtest-y)
- $(call do_test_tap, $(check-qtest-$*-y:%=tests/qtest/%$(EXESUF)) $(check-qtest-generic-y:%=tests/qtest/%$(EXESUF)), \
- QTEST_QEMU_BINARY=$*-softmmu/qemu-system-$* \
- QTEST_QEMU_IMG=qemu-img$(EXESUF))
-
check-report-unit.tap: $(check-unit-y)
$(call do_test_tap,$^)
-# Reports and overall runs
-
-check-report.tap: $(patsubst %,check-report-qtest-%.tap, $(QTEST_TARGETS)) check-report-unit.tap
- $(call quiet-command, cat $^ | scripts/tap-merge.pl >$@,"GEN","$@")
-
-# FPU Emulation tests (aka softfloat)
-#
-# As we still have some places that need fixing the rules are a little
-# more complex than they need to be and have to override some of the
-# generic Makefile expansions. Once we are cleanly passing all
-# the tests we can simplify the make syntax.
-
-FP_TEST_BIN=$(BUILD_DIR)/tests/fp/fp-test
-
-# the build dir is created by configure
-$(FP_TEST_BIN): config-host.h $(test-util-obj-y)
- $(call quiet-command, \
- $(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" $(notdir $@), \
- "BUILD", "$(notdir $@)")
-
-# The full test suite can take a bit of time, default to a quick run
-# "-l 2 -r all" can take more than a day for some operations and is best
-# run manually
-FP_TL=-l 1 -r all
-
-# $1 = tests, $2 = description, $3 = test flags
-test-softfloat = $(call quiet-command, \
- cd $(BUILD_DIR)/tests/fp && \
- ./fp-test -s $(if $3,$3,$(FP_TL)) $1 > $2.out 2>&1 || \
- (cat $2.out && exit 1;), \
- "FLOAT TEST", $2)
-
-# Conversion Routines: Float to Float
-# FIXME: f32_to_f128 (broken), f64_to_f128 (broken)
-# FIXME: f128_to_f32(broken), f128_to_f64 (broken)
-# FIXME: f128_to_extF80 (broken)
-check-softfloat-conv-f2f: $(FP_TEST_BIN)
- $(call test-softfloat, \
- f16_to_f32 f16_to_f64 \
- f16_to_extF80 f16_to_f128 \
- f32_to_f16 f32_to_f64 \
- f32_to_extF80 \
- f64_to_f16 f64_to_f32 \
- extF80_to_f16 extF80_to_f32 \
- extF80_to_f64 extF80_to_f128 \
- f128_to_f16, \
- float-to-float)
-
-# Conversion Routines: Int and Uint to Float
-# FIXME: i32_to_extF80 (broken), i64_to_extF80 (broken)
-# ui32_to_f128 (not implemented)
-check-softfloat-conv-to-float: $(FP_TEST_BIN)
- $(call test-softfloat, \
- i32_to_f16 i64_to_f16 \
- i32_to_f32 i64_to_f32 \
- i32_to_f64 i64_to_f64 \
- i32_to_f128 i64_to_f128, int-to-float)
- $(call test-softfloat, \
- ui32_to_f16 ui64_to_f16 \
- ui32_to_f32 ui64_to_f32 \
- ui32_to_f64 ui64_to_f64 \
- ui32_to_extF80 ui64_to_extF80 \
- ui64_to_f128, uint-to-float)
-
-# Conversion Routines: Float to integers
-# FIXME: extF80_roundToInt (broken)
-check-softfloat-conv-to-int: $(FP_TEST_BIN)
- $(call test-softfloat, \
- f16_to_i32 f16_to_i32_r_minMag \
- f32_to_i32 f32_to_i32_r_minMag \
- f64_to_i32 f64_to_i32_r_minMag \
- extF80_to_i32 extF80_to_i32_r_minMag \
- f128_to_i32 f128_to_i32_r_minMag \
- f16_to_i64 f16_to_i64_r_minMag \
- f32_to_i64 f32_to_i64_r_minMag \
- f64_to_i64 f64_to_i64_r_minMag \
- extF80_to_i64 extF80_to_i64_r_minMag \
- f128_to_i64 f128_to_i64_r_minMag, \
- float-to-int)
- $(call test-softfloat, \
- f16_to_ui32 f16_to_ui32_r_minMag \
- f32_to_ui32 f32_to_ui32_r_minMag \
- f64_to_ui32 f64_to_ui32_r_minMag \
- extF80_to_ui32 extF80_to_ui32_r_minMag \
- f128_to_ui32 f128_to_ui32_r_minMag \
- f16_to_ui64 f16_to_ui64_r_minMag \
- f32_to_ui64 f32_to_ui64_r_minMag \
- f64_to_ui64 f64_to_ui64_r_minMag \
- extF80_to_ui64 extF80_to_ui64_r_minMag \
- f128_to_ui64 f128_to_ui64_r_minMag, \
- float-to-uint)
- $(call test-softfloat, \
- f16_roundToInt f32_roundToInt \
- f64_roundToInt f128_roundToInt, \
- round-to-integer)
-
-.PHONY: check-softfloat-conv
-check-softfloat-conv: check-softfloat-conv-f2f
-check-softfloat-conv: check-softfloat-conv-to-float
-check-softfloat-conv: check-softfloat-conv-to-int
-
-# Generic rule for all float operations
-#
-# Some patterns are overridden due to broken or missing tests.
-# Hopefully these can be removed over time.
-
-check-softfloat-%: $(FP_TEST_BIN)
- $(call test-softfloat, f16_$* f32_$* f64_$* extF80_$* f128_$*, $*)
-
-# Float Compare routines
-SF_COMPARE_OPS=eq eq_signaling le le_quiet lt_quiet
-SF_COMPARE_RULES=$(patsubst %,check-softfloat-%, $(SF_COMPARE_OPS))
-
-# FIXME: extF80_lt_quiet (broken)
-check-softfloat-lt_quiet: $(FP_TEST_BIN)
- $(call test-softfloat, \
- f16_lt_quiet f32_lt_quiet f64_lt_quiet \
- f128_lt_quiet, \
- lt_quiet)
-
-.PHONY: check-softfloat-compare
-check-softfloat-compare: $(SF_COMPARE_RULES)
-
-# Math Operations
-
-# FIXME: extF80_mulAdd (missing)
-check-softfloat-mulAdd: $(FP_TEST_BIN)
- $(call test-softfloat, \
- f16_mulAdd f32_mulAdd f64_mulAdd f128_mulAdd, \
- mulAdd,-l 1)
-
-# FIXME: extF80_rem (broken)
-check-softfloat-rem: $(FP_TEST_BIN)
- $(call test-softfloat, \
- f16_rem f32_rem f64_rem f128_rem, \
- rem)
-
-SF_MATH_OPS=add sub mul mulAdd div rem sqrt
-SF_MATH_RULES=$(patsubst %,check-softfloat-%, $(SF_MATH_OPS))
-
-.PHONY: check-softfloat-ops
-check-softfloat-ops: $(SF_MATH_RULES)
-
-# Finally a generic rule to test all of softfoat. If TCG isnt't
-# enabled we define a null operation which skips the tests.
-
-.PHONY: check-softfloat
-ifeq ($(CONFIG_TCG),y)
-build-softfloat: $(FP_TEST_BIN)
-check-softfloat: build-softfloat check-softfloat-conv check-softfloat-compare check-softfloat-ops
-else
-build-softfloat check-softfloat:
- $(call quiet-command, /bin/true, "FLOAT TEST", \
- "SKIPPED for non-TCG builds")
-endif
-
-# Plugins
-ifeq ($(CONFIG_PLUGIN),y)
-.PHONY: plugins
-plugins:
- $(call quiet-command,\
- $(MAKE) $(SUBDIR_MAKEFLAGS) -C tests/plugin V="$(V)", \
- "BUILD", "plugins")
-endif
-
# Per guest TCG tests
BUILD_TCG_TARGET_RULES=$(patsubst %,build-tcg-tests-%, $(TARGET_DIRS))
@@ -853,7 +446,7 @@ build-tcg-tests-%: $(if $(CONFIG_PLUGIN),plugins)
V="$(V)" TARGET="$*" guest-tests, \
"BUILD", "TCG tests for $*")
-run-tcg-tests-%: build-tcg-tests-% %/all
+run-tcg-tests-%: build-tcg-tests-% all
$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
SRC_PATH=$(SRC_PATH) SPEED="$(SPEED)" \
@@ -875,32 +468,6 @@ check-tcg: $(RUN_TCG_TARGET_RULES)
.PHONY: clean-tcg
clean-tcg: $(CLEAN_TCG_TARGET_RULES)
-# Other tests
-
-QEMU_IOTESTS_HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = tests/qemu-iotests/socket_scm_helper$(EXESUF)
-
-.PHONY: check-tests/check-block.sh
-check-tests/check-block.sh: tests/check-block.sh qemu-img$(EXESUF) \
- qemu-io$(EXESUF) qemu-nbd$(EXESUF) $(QEMU_IOTESTS_HELPERS-y) \
- $(patsubst %,%/all,$(filter %-softmmu,$(TARGET_DIRS)))
- @$<
-
-.PHONY: check-tests/qapi-schema/frontend
-check-tests/qapi-schema/frontend: $(addprefix $(SRC_PATH)/, $(check-qapi-schema-y))
- $(call quiet-command, PYTHONPATH=$(SRC_PATH)/scripts \
- PYTHONIOENCODING=utf-8 $(PYTHON) $(SRC_PATH)/tests/qapi-schema/test-qapi.py $^, \
- TEST, check-qapi-schema)
-
-.PHONY: check-tests/qapi-schema/doc-good.texi
-check-tests/qapi-schema/doc-good.texi: tests/qapi-schema/doc-good.test.texi
- @diff -u $(SRC_PATH)/tests/qapi-schema/doc-good.texi $<
-
-.PHONY: check-decodetree
-check-decodetree:
- $(call quiet-command, \
- cd $(SRC_PATH)/tests/decode && \
- ./check.sh "$(PYTHON)" "$(SRC_PATH)/scripts/decodetree.py", \
- TEST, decodetree.py)
# Python venv for running tests
@@ -955,31 +522,21 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images
# Consolidated targets
-.PHONY: check-block check-qapi-schema check-qtest check-unit check check-clean get-vm-images
-check-qapi-schema: check-tests/qapi-schema/frontend check-tests/qapi-schema/doc-good.texi
-check-qtest: $(patsubst %,check-qtest-%, $(QTEST_TARGETS))
-ifeq ($(CONFIG_TOOLS),y)
-check-block: $(patsubst %,check-%, $(check-block-y))
-endif
-check-build: build-unit build-softfloat build-qtest
+.PHONY: check-block check-unit check check-clean get-vm-images
+check-block:
+check-build: build-unit
check-clean:
rm -rf $(check-unit-y) tests/*.o tests/*/*.o $(QEMU_IOTESTS_HELPERS-y)
- rm -rf $(sort $(foreach target,$(SYSEMU_TARGET_LIST), $(check-qtest-$(target)-y:%=tests/qtest/%$(EXESUF))) $(check-qtest-generic-y:%=tests/qtest/%$(EXESUF)))
rm -f tests/test-qapi-gen-timestamp
- rm -f tests/qtest/dbus-vmstate1-gen-timestamp
rm -rf $(TESTS_VENV_DIR) $(TESTS_RESULTS_DIR)
-check: check-block check-qapi-schema check-unit check-softfloat check-qtest check-decodetree
+check: check-unit
clean: check-clean
# Build the help program automatically
-all: $(QEMU_IOTESTS_HELPERS-y)
-
-include $(wildcard tests/*.d)
--include $(wildcard tests/qtest/*.d)
--include $(wildcard tests/qtest/libqos/*.d)
endif
diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
index 77d1c1d9ff..db9c0f5d79 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -57,8 +57,7 @@ def pick_default_qemu_bin(arch=None):
# qemu binary path does not match arch for powerpc, handle it
if 'ppc64le' in arch:
arch = 'ppc64'
- qemu_bin_relative_path = os.path.join("%s-softmmu" % arch,
- "qemu-system-%s" % arch)
+ qemu_bin_relative_path = "./qemu-system-%s" % arch
if is_readable_executable_file(qemu_bin_relative_path):
return qemu_bin_relative_path
diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index 73cc69c499..aaa781a581 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -335,15 +335,14 @@ class BootLinuxConsole(LinuxKernelTest):
:avocado: tags=device:pl011
:avocado: tags=device:arm_gicv3
"""
- kernel_url = ('http://ports.ubuntu.com/ubuntu-ports/dists/'
- 'bionic-updates/main/installer-arm64/current/images/'
- 'netboot/ubuntu-installer/arm64/linux')
+ images_url = ('http://ports.ubuntu.com/ubuntu-ports/dists/'
+ 'bionic-updates/main/installer-arm64/'
+ '20101020ubuntu543.15/images/')
+ kernel_url = images_url + 'netboot/ubuntu-installer/arm64/linux'
kernel_hash = '5bfc54cf7ed8157d93f6e5b0241e727b6dc22c50'
kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
- initrd_url = ('http://ports.ubuntu.com/ubuntu-ports/dists/'
- 'bionic-updates/main/installer-arm64/current/images/'
- 'netboot/ubuntu-installer/arm64/initrd.gz')
+ initrd_url = images_url + 'netboot/ubuntu-installer/arm64/initrd.gz'
initrd_hash = 'd385d3e88d53e2004c5d43cbe668b458a094f772'
initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash)
@@ -822,7 +821,7 @@ class BootLinuxConsole(LinuxKernelTest):
:avocado: tags=machine:clipper
"""
kernel_url = ('http://archive.debian.org/debian/dists/lenny/main/'
- 'installer-alpha/current/images/cdrom/vmlinuz')
+ 'installer-alpha/20090123lenny10/images/cdrom/vmlinuz')
kernel_hash = '3a943149335529e2ed3e74d0d787b85fb5671ba3'
kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
diff --git a/tests/acceptance/machine_rx_gdbsim.py b/tests/acceptance/machine_rx_gdbsim.py
index bff63e421d..0c72506028 100644
--- a/tests/acceptance/machine_rx_gdbsim.py
+++ b/tests/acceptance/machine_rx_gdbsim.py
@@ -8,6 +8,9 @@
# This work is licensed under the terms of the GNU GPL, version 2 or
# later. See the COPYING file in the top-level directory.
+import os
+
+from avocado import skipIf
from avocado_qemu import Test
from avocado_qemu import exec_command_and_wait_for_pattern
from avocado_qemu import wait_for_console_pattern
@@ -42,6 +45,7 @@ class RxGdbSimMachine(Test):
# FIXME limit baudrate on chardev, else we type too fast
#exec_command_and_wait_for_pattern(self, 'version', gcc_version)
+ @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
def test_linux_sash(self):
"""
Boots a Linux kernel and checks that the console is operational.
diff --git a/tests/acceptance/replay_kernel.py b/tests/acceptance/replay_kernel.py
index 62d2db8c64..b79fc8daf8 100644
--- a/tests/acceptance/replay_kernel.py
+++ b/tests/acceptance/replay_kernel.py
@@ -126,6 +126,7 @@ class ReplayKernel(LinuxKernelTest):
self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=1)
+ @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
def test_arm_cubieboard_initrd(self):
"""
:avocado: tags=arch:arm
diff --git a/tests/data/acpi/rebuild-expected-aml.sh b/tests/data/acpi/rebuild-expected-aml.sh
index 76cd797d1e..fc78770544 100755
--- a/tests/data/acpi/rebuild-expected-aml.sh
+++ b/tests/data/acpi/rebuild-expected-aml.sh
@@ -12,7 +12,7 @@
# This work is licensed under the terms of the GNU GPLv2.
# See the COPYING.LIB file in the top-level directory.
-qemu_bins="x86_64-softmmu/qemu-system-x86_64 aarch64-softmmu/qemu-system-aarch64"
+qemu_bins="./qemu-system-x86_64 ./qemu-system-aarch64"
if [ ! -e "tests/qtest/bios-tables-test" ]; then
echo "Test: bios-tables-test is required! Run make check before this script."
diff --git a/tests/docker/dockerfiles/debian-amd64.docker b/tests/docker/dockerfiles/debian-amd64.docker
index 8fdfd6a6b0..d2500dcff1 100644
--- a/tests/docker/dockerfiles/debian-amd64.docker
+++ b/tests/docker/dockerfiles/debian-amd64.docker
@@ -20,7 +20,9 @@ RUN apt update && \
librdmacm-dev \
libsasl2-dev \
libsnappy-dev \
- libvte-dev
+ libvte-dev \
+ netcat-openbsd \
+ python3-venv
# virgl
RUN apt update && \
diff --git a/tests/docker/test-static b/tests/docker/test-static
new file mode 100755
index 0000000000..372ef6fac7
--- /dev/null
+++ b/tests/docker/test-static
@@ -0,0 +1,24 @@
+#!/bin/bash -e
+#
+# Compile QEMU user mode emulators as static binaries on Linux.
+#
+# Copyright (c) 2020 Red Hat Inc.
+#
+# Authors:
+# Paolo Bonzini <pbonzini@redhat.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2
+# or (at your option) any later version. See the COPYING file in
+# the top-level directory.
+
+. common.rc
+
+cd "$BUILD_DIR"
+
+build_qemu \
+ --disable-system \
+ --disable-tools \
+ --disable-guest-agent \
+ --disable-docs \
+ --static
+install_qemu
diff --git a/tests/fp/Makefile b/tests/fp/Makefile
deleted file mode 100644
index 56768ecfd2..0000000000
--- a/tests/fp/Makefile
+++ /dev/null
@@ -1,600 +0,0 @@
-BUILD_DIR := $(CURDIR)/../..
-
-include $(BUILD_DIR)/config-host.mak
-include $(SRC_PATH)/rules.mak
-
-SOFTFLOAT_DIR := $(SRC_PATH)/tests/fp/berkeley-softfloat-3
-TESTFLOAT_DIR := $(SRC_PATH)/tests/fp/berkeley-testfloat-3
-
-SF_SOURCE_DIR := $(SOFTFLOAT_DIR)/source
-SF_INCLUDE_DIR := $(SOFTFLOAT_DIR)/source/include
-# we could use any specialize here, it doesn't matter
-SF_SPECIALIZE := 8086-SSE
-SF_SPECIALIZE_DIR := $(SF_SOURCE_DIR)/$(SF_SPECIALIZE)
-
-TF_SOURCE_DIR := $(TESTFLOAT_DIR)/source
-
-$(call set-vpath, $(SRC_PATH)/fpu $(SRC_PATH)/tests/fp)
-
-LIBQEMUUTIL := $(BUILD_DIR)/libqemuutil.a
-
-# Use this variable to be clear when we pull in our own implementation
-# We build the object with a default rule thanks to the vpath above
-QEMU_SOFTFLOAT_OBJ := softfloat.o
-
-QEMU_INCLUDES += -I$(SRC_PATH)/tests/fp
-QEMU_INCLUDES += -I$(SF_INCLUDE_DIR)
-QEMU_INCLUDES += -I$(SF_SPECIALIZE_DIR)
-QEMU_INCLUDES += -I$(TF_SOURCE_DIR)
-
-# work around TARGET_* poisoning
-QEMU_CFLAGS += -DHW_POISON_H
-# define a target to match testfloat's implementation-defined choices, such as
-# whether to raise the invalid flag when dealing with NaNs in muladd.
-QEMU_CFLAGS += -DTARGET_ARM
-
-# capstone has a platform.h file that clashes with softfloat's
-QEMU_CFLAGS := $(filter-out %capstone, $(QEMU_CFLAGS))
-
-# softfloat defines
-SF_OPTS :=
-SF_OPTS += -DSOFTFLOAT_ROUND_ODD
-SF_OPTS += -DINLINE_LEVEL=5
-SF_OPTS += -DSOFTFLOAT_FAST_DIV32TO16
-SF_OPTS += -DSOFTFLOAT_FAST_DIV64TO32
-SF_OPTS += -DSOFTFLOAT_FAST_INT64
-QEMU_CFLAGS += $(SF_OPTS)
-
-# silence the build of softfloat objects
-SF_CFLAGS += -Wno-missing-prototypes
-SF_CFLAGS += -Wno-redundant-decls
-SF_CFLAGS += -Wno-return-type
-SF_CFLAGS += -Wno-error
-
-# testfloat defines
-TF_OPTS :=
-TF_OPTS += -DFLOAT16
-TF_OPTS += -DFLOAT64
-TF_OPTS += -DEXTFLOAT80
-TF_OPTS += -DFLOAT128
-TF_OPTS += -DFLOAT_ROUND_ODD
-TF_OPTS += -DLONG_DOUBLE_IS_EXTFLOAT80
-QEMU_CFLAGS += $(TF_OPTS)
-
-# silence the build of testfloat objects
-TF_CFLAGS :=
-TF_CFLAGS += -Wno-strict-prototypes
-TF_CFLAGS += -Wno-unknown-pragmas
-TF_CFLAGS += -Wno-uninitialized
-TF_CFLAGS += -Wno-missing-prototypes
-TF_CFLAGS += -Wno-return-type
-TF_CFLAGS += -Wno-unused-function
-TF_CFLAGS += -Wno-error
-
-# softfloat objects
-SF_OBJS_PRIMITIVES :=
-SF_OBJS_PRIMITIVES += s_eq128.o
-SF_OBJS_PRIMITIVES += s_le128.o
-SF_OBJS_PRIMITIVES += s_lt128.o
-SF_OBJS_PRIMITIVES += s_shortShiftLeft128.o
-SF_OBJS_PRIMITIVES += s_shortShiftRight128.o
-SF_OBJS_PRIMITIVES += s_shortShiftRightJam64.o
-SF_OBJS_PRIMITIVES += s_shortShiftRightJam64Extra.o
-SF_OBJS_PRIMITIVES += s_shortShiftRightJam128.o
-SF_OBJS_PRIMITIVES += s_shortShiftRightJam128Extra.o
-SF_OBJS_PRIMITIVES += s_shiftRightJam32.o
-SF_OBJS_PRIMITIVES += s_shiftRightJam64.o
-SF_OBJS_PRIMITIVES += s_shiftRightJam64Extra.o
-SF_OBJS_PRIMITIVES += s_shiftRightJam128.o
-SF_OBJS_PRIMITIVES += s_shiftRightJam128Extra.o
-SF_OBJS_PRIMITIVES += s_shiftRightJam256M.o
-SF_OBJS_PRIMITIVES += s_countLeadingZeros8.o
-SF_OBJS_PRIMITIVES += s_countLeadingZeros16.o
-SF_OBJS_PRIMITIVES += s_countLeadingZeros32.o
-SF_OBJS_PRIMITIVES += s_countLeadingZeros64.o
-SF_OBJS_PRIMITIVES += s_add128.o
-SF_OBJS_PRIMITIVES += s_add256M.o
-SF_OBJS_PRIMITIVES += s_sub128.o
-SF_OBJS_PRIMITIVES += s_sub256M.o
-SF_OBJS_PRIMITIVES += s_mul64ByShifted32To128.o
-SF_OBJS_PRIMITIVES += s_mul64To128.o
-SF_OBJS_PRIMITIVES += s_mul128By32.o
-SF_OBJS_PRIMITIVES += s_mul128To256M.o
-SF_OBJS_PRIMITIVES += s_approxRecip_1Ks.o
-SF_OBJS_PRIMITIVES += s_approxRecip32_1.o
-SF_OBJS_PRIMITIVES += s_approxRecipSqrt_1Ks.o
-SF_OBJS_PRIMITIVES += s_approxRecipSqrt32_1.o
-
-SF_OBJS_SPECIALIZE :=
-SF_OBJS_SPECIALIZE += softfloat_raiseFlags.o
-SF_OBJS_SPECIALIZE += s_f16UIToCommonNaN.o
-SF_OBJS_SPECIALIZE += s_commonNaNToF16UI.o
-SF_OBJS_SPECIALIZE += s_propagateNaNF16UI.o
-SF_OBJS_SPECIALIZE += s_f32UIToCommonNaN.o
-SF_OBJS_SPECIALIZE += s_commonNaNToF32UI.o
-SF_OBJS_SPECIALIZE += s_propagateNaNF32UI.o
-SF_OBJS_SPECIALIZE += s_f64UIToCommonNaN.o
-SF_OBJS_SPECIALIZE += s_commonNaNToF64UI.o
-SF_OBJS_SPECIALIZE += s_propagateNaNF64UI.o
-SF_OBJS_SPECIALIZE += extF80M_isSignalingNaN.o
-SF_OBJS_SPECIALIZE += s_extF80UIToCommonNaN.o
-SF_OBJS_SPECIALIZE += s_commonNaNToExtF80UI.o
-SF_OBJS_SPECIALIZE += s_propagateNaNExtF80UI.o
-SF_OBJS_SPECIALIZE += f128M_isSignalingNaN.o
-SF_OBJS_SPECIALIZE += s_f128UIToCommonNaN.o
-SF_OBJS_SPECIALIZE += s_commonNaNToF128UI.o
-SF_OBJS_SPECIALIZE += s_propagateNaNF128UI.o
-
-SF_OBJS_OTHERS :=
-SF_OBJS_OTHERS += s_roundToUI32.o
-SF_OBJS_OTHERS += s_roundToUI64.o
-SF_OBJS_OTHERS += s_roundToI32.o
-SF_OBJS_OTHERS += s_roundToI64.o
-SF_OBJS_OTHERS += s_normSubnormalF16Sig.o
-SF_OBJS_OTHERS += s_roundPackToF16.o
-SF_OBJS_OTHERS += s_normRoundPackToF16.o
-SF_OBJS_OTHERS += s_addMagsF16.o
-SF_OBJS_OTHERS += s_subMagsF16.o
-SF_OBJS_OTHERS += s_mulAddF16.o
-SF_OBJS_OTHERS += s_normSubnormalF32Sig.o
-SF_OBJS_OTHERS += s_roundPackToF32.o
-SF_OBJS_OTHERS += s_normRoundPackToF32.o
-SF_OBJS_OTHERS += s_addMagsF32.o
-SF_OBJS_OTHERS += s_subMagsF32.o
-SF_OBJS_OTHERS += s_mulAddF32.o
-SF_OBJS_OTHERS += s_normSubnormalF64Sig.o
-SF_OBJS_OTHERS += s_roundPackToF64.o
-SF_OBJS_OTHERS += s_normRoundPackToF64.o
-SF_OBJS_OTHERS += s_addMagsF64.o
-SF_OBJS_OTHERS += s_subMagsF64.o
-SF_OBJS_OTHERS += s_mulAddF64.o
-SF_OBJS_OTHERS += s_normSubnormalExtF80Sig.o
-SF_OBJS_OTHERS += s_roundPackToExtF80.o
-SF_OBJS_OTHERS += s_normRoundPackToExtF80.o
-SF_OBJS_OTHERS += s_addMagsExtF80.o
-SF_OBJS_OTHERS += s_subMagsExtF80.o
-SF_OBJS_OTHERS += s_normSubnormalF128Sig.o
-SF_OBJS_OTHERS += s_roundPackToF128.o
-SF_OBJS_OTHERS += s_normRoundPackToF128.o
-SF_OBJS_OTHERS += s_addMagsF128.o
-SF_OBJS_OTHERS += s_subMagsF128.o
-SF_OBJS_OTHERS += s_mulAddF128.o
-SF_OBJS_OTHERS += softfloat_state.o
-SF_OBJS_OTHERS += ui32_to_f16.o
-SF_OBJS_OTHERS += ui32_to_f32.o
-SF_OBJS_OTHERS += ui32_to_f64.o
-SF_OBJS_OTHERS += ui32_to_extF80.o
-SF_OBJS_OTHERS += ui32_to_extF80M.o
-SF_OBJS_OTHERS += ui32_to_f128.o
-SF_OBJS_OTHERS += ui32_to_f128M.o
-SF_OBJS_OTHERS += ui64_to_f16.o
-SF_OBJS_OTHERS += ui64_to_f32.o
-SF_OBJS_OTHERS += ui64_to_f64.o
-SF_OBJS_OTHERS += ui64_to_extF80.o
-SF_OBJS_OTHERS += ui64_to_extF80M.o
-SF_OBJS_OTHERS += ui64_to_f128.o
-SF_OBJS_OTHERS += ui64_to_f128M.o
-SF_OBJS_OTHERS += i32_to_f16.o
-SF_OBJS_OTHERS += i32_to_f32.o
-SF_OBJS_OTHERS += i32_to_f64.o
-SF_OBJS_OTHERS += i32_to_extF80.o
-SF_OBJS_OTHERS += i32_to_extF80M.o
-SF_OBJS_OTHERS += i32_to_f128.o
-SF_OBJS_OTHERS += i32_to_f128M.o
-SF_OBJS_OTHERS += i64_to_f16.o
-SF_OBJS_OTHERS += i64_to_f32.o
-SF_OBJS_OTHERS += i64_to_f64.o
-SF_OBJS_OTHERS += i64_to_extF80.o
-SF_OBJS_OTHERS += i64_to_extF80M.o
-SF_OBJS_OTHERS += i64_to_f128.o
-SF_OBJS_OTHERS += i64_to_f128M.o
-SF_OBJS_OTHERS += f16_to_ui32.o
-SF_OBJS_OTHERS += f16_to_ui64.o
-SF_OBJS_OTHERS += f16_to_i32.o
-SF_OBJS_OTHERS += f16_to_i64.o
-SF_OBJS_OTHERS += f16_to_ui32_r_minMag.o
-SF_OBJS_OTHERS += f16_to_ui64_r_minMag.o
-SF_OBJS_OTHERS += f16_to_i32_r_minMag.o
-SF_OBJS_OTHERS += f16_to_i64_r_minMag.o
-SF_OBJS_OTHERS += f16_to_f32.o
-SF_OBJS_OTHERS += f16_to_f64.o
-SF_OBJS_OTHERS += f16_to_extF80.o
-SF_OBJS_OTHERS += f16_to_extF80M.o
-SF_OBJS_OTHERS += f16_to_f128.o
-SF_OBJS_OTHERS += f16_to_f128M.o
-SF_OBJS_OTHERS += f16_roundToInt.o
-SF_OBJS_OTHERS += f16_add.o
-SF_OBJS_OTHERS += f16_sub.o
-SF_OBJS_OTHERS += f16_mul.o
-SF_OBJS_OTHERS += f16_mulAdd.o
-SF_OBJS_OTHERS += f16_div.o
-SF_OBJS_OTHERS += f16_rem.o
-SF_OBJS_OTHERS += f16_sqrt.o
-SF_OBJS_OTHERS += f16_eq.o
-SF_OBJS_OTHERS += f16_le.o
-SF_OBJS_OTHERS += f16_lt.o
-SF_OBJS_OTHERS += f16_eq_signaling.o
-SF_OBJS_OTHERS += f16_le_quiet.o
-SF_OBJS_OTHERS += f16_lt_quiet.o
-SF_OBJS_OTHERS += f16_isSignalingNaN.o
-SF_OBJS_OTHERS += f32_to_ui32.o
-SF_OBJS_OTHERS += f32_to_ui64.o
-SF_OBJS_OTHERS += f32_to_i32.o
-SF_OBJS_OTHERS += f32_to_i64.o
-SF_OBJS_OTHERS += f32_to_ui32_r_minMag.o
-SF_OBJS_OTHERS += f32_to_ui64_r_minMag.o
-SF_OBJS_OTHERS += f32_to_i32_r_minMag.o
-SF_OBJS_OTHERS += f32_to_i64_r_minMag.o
-SF_OBJS_OTHERS += f32_to_f16.o
-SF_OBJS_OTHERS += f32_to_f64.o
-SF_OBJS_OTHERS += f32_to_extF80.o
-SF_OBJS_OTHERS += f32_to_extF80M.o
-SF_OBJS_OTHERS += f32_to_f128.o
-SF_OBJS_OTHERS += f32_to_f128M.o
-SF_OBJS_OTHERS += f32_roundToInt.o
-SF_OBJS_OTHERS += f32_add.o
-SF_OBJS_OTHERS += f32_sub.o
-SF_OBJS_OTHERS += f32_mul.o
-SF_OBJS_OTHERS += f32_mulAdd.o
-SF_OBJS_OTHERS += f32_div.o
-SF_OBJS_OTHERS += f32_rem.o
-SF_OBJS_OTHERS += f32_sqrt.o
-SF_OBJS_OTHERS += f32_eq.o
-SF_OBJS_OTHERS += f32_le.o
-SF_OBJS_OTHERS += f32_lt.o
-SF_OBJS_OTHERS += f32_eq_signaling.o
-SF_OBJS_OTHERS += f32_le_quiet.o
-SF_OBJS_OTHERS += f32_lt_quiet.o
-SF_OBJS_OTHERS += f32_isSignalingNaN.o
-SF_OBJS_OTHERS += f64_to_ui32.o
-SF_OBJS_OTHERS += f64_to_ui64.o
-SF_OBJS_OTHERS += f64_to_i32.o
-SF_OBJS_OTHERS += f64_to_i64.o
-SF_OBJS_OTHERS += f64_to_ui32_r_minMag.o
-SF_OBJS_OTHERS += f64_to_ui64_r_minMag.o
-SF_OBJS_OTHERS += f64_to_i32_r_minMag.o
-SF_OBJS_OTHERS += f64_to_i64_r_minMag.o
-SF_OBJS_OTHERS += f64_to_f16.o
-SF_OBJS_OTHERS += f64_to_f32.o
-SF_OBJS_OTHERS += f64_to_extF80.o
-SF_OBJS_OTHERS += f64_to_extF80M.o
-SF_OBJS_OTHERS += f64_to_f128.o
-SF_OBJS_OTHERS += f64_to_f128M.o
-SF_OBJS_OTHERS += f64_roundToInt.o
-SF_OBJS_OTHERS += f64_add.o
-SF_OBJS_OTHERS += f64_sub.o
-SF_OBJS_OTHERS += f64_mul.o
-SF_OBJS_OTHERS += f64_mulAdd.o
-SF_OBJS_OTHERS += f64_div.o
-SF_OBJS_OTHERS += f64_rem.o
-SF_OBJS_OTHERS += f64_sqrt.o
-SF_OBJS_OTHERS += f64_eq.o
-SF_OBJS_OTHERS += f64_le.o
-SF_OBJS_OTHERS += f64_lt.o
-SF_OBJS_OTHERS += f64_eq_signaling.o
-SF_OBJS_OTHERS += f64_le_quiet.o
-SF_OBJS_OTHERS += f64_lt_quiet.o
-SF_OBJS_OTHERS += f64_isSignalingNaN.o
-SF_OBJS_OTHERS += extF80_to_ui32.o
-SF_OBJS_OTHERS += extF80_to_ui64.o
-SF_OBJS_OTHERS += extF80_to_i32.o
-SF_OBJS_OTHERS += extF80_to_i64.o
-SF_OBJS_OTHERS += extF80_to_ui32_r_minMag.o
-SF_OBJS_OTHERS += extF80_to_ui64_r_minMag.o
-SF_OBJS_OTHERS += extF80_to_i32_r_minMag.o
-SF_OBJS_OTHERS += extF80_to_i64_r_minMag.o
-SF_OBJS_OTHERS += extF80_to_f16.o
-SF_OBJS_OTHERS += extF80_to_f32.o
-SF_OBJS_OTHERS += extF80_to_f64.o
-SF_OBJS_OTHERS += extF80_to_f128.o
-SF_OBJS_OTHERS += extF80_roundToInt.o
-SF_OBJS_OTHERS += extF80_add.o
-SF_OBJS_OTHERS += extF80_sub.o
-SF_OBJS_OTHERS += extF80_mul.o
-SF_OBJS_OTHERS += extF80_div.o
-SF_OBJS_OTHERS += extF80_rem.o
-SF_OBJS_OTHERS += extF80_sqrt.o
-SF_OBJS_OTHERS += extF80_eq.o
-SF_OBJS_OTHERS += extF80_le.o
-SF_OBJS_OTHERS += extF80_lt.o
-SF_OBJS_OTHERS += extF80_eq_signaling.o
-SF_OBJS_OTHERS += extF80_le_quiet.o
-SF_OBJS_OTHERS += extF80_lt_quiet.o
-SF_OBJS_OTHERS += extF80_isSignalingNaN.o
-SF_OBJS_OTHERS += extF80M_to_ui32.o
-SF_OBJS_OTHERS += extF80M_to_ui64.o
-SF_OBJS_OTHERS += extF80M_to_i32.o
-SF_OBJS_OTHERS += extF80M_to_i64.o
-SF_OBJS_OTHERS += extF80M_to_ui32_r_minMag.o
-SF_OBJS_OTHERS += extF80M_to_ui64_r_minMag.o
-SF_OBJS_OTHERS += extF80M_to_i32_r_minMag.o
-SF_OBJS_OTHERS += extF80M_to_i64_r_minMag.o
-SF_OBJS_OTHERS += extF80M_to_f16.o
-SF_OBJS_OTHERS += extF80M_to_f32.o
-SF_OBJS_OTHERS += extF80M_to_f64.o
-SF_OBJS_OTHERS += extF80M_to_f128M.o
-SF_OBJS_OTHERS += extF80M_roundToInt.o
-SF_OBJS_OTHERS += extF80M_add.o
-SF_OBJS_OTHERS += extF80M_sub.o
-SF_OBJS_OTHERS += extF80M_mul.o
-SF_OBJS_OTHERS += extF80M_div.o
-SF_OBJS_OTHERS += extF80M_rem.o
-SF_OBJS_OTHERS += extF80M_sqrt.o
-SF_OBJS_OTHERS += extF80M_eq.o
-SF_OBJS_OTHERS += extF80M_le.o
-SF_OBJS_OTHERS += extF80M_lt.o
-SF_OBJS_OTHERS += extF80M_eq_signaling.o
-SF_OBJS_OTHERS += extF80M_le_quiet.o
-SF_OBJS_OTHERS += extF80M_lt_quiet.o
-SF_OBJS_OTHERS += f128_to_ui32.o
-SF_OBJS_OTHERS += f128_to_ui64.o
-SF_OBJS_OTHERS += f128_to_i32.o
-SF_OBJS_OTHERS += f128_to_i64.o
-SF_OBJS_OTHERS += f128_to_ui32_r_minMag.o
-SF_OBJS_OTHERS += f128_to_ui64_r_minMag.o
-SF_OBJS_OTHERS += f128_to_i32_r_minMag.o
-SF_OBJS_OTHERS += f128_to_i64_r_minMag.o
-SF_OBJS_OTHERS += f128_to_f16.o
-SF_OBJS_OTHERS += f128_to_f32.o
-SF_OBJS_OTHERS += f128_to_extF80.o
-SF_OBJS_OTHERS += f128_to_f64.o
-SF_OBJS_OTHERS += f128_roundToInt.o
-SF_OBJS_OTHERS += f128_add.o
-SF_OBJS_OTHERS += f128_sub.o
-SF_OBJS_OTHERS += f128_mul.o
-SF_OBJS_OTHERS += f128_mulAdd.o
-SF_OBJS_OTHERS += f128_div.o
-SF_OBJS_OTHERS += f128_rem.o
-SF_OBJS_OTHERS += f128_sqrt.o
-SF_OBJS_OTHERS += f128_eq.o
-SF_OBJS_OTHERS += f128_le.o
-SF_OBJS_OTHERS += f128_lt.o
-SF_OBJS_OTHERS += f128_eq_signaling.o
-SF_OBJS_OTHERS += f128_le_quiet.o
-SF_OBJS_OTHERS += f128_lt_quiet.o
-SF_OBJS_OTHERS += f128_isSignalingNaN.o
-SF_OBJS_OTHERS += f128M_to_ui32.o
-SF_OBJS_OTHERS += f128M_to_ui64.o
-SF_OBJS_OTHERS += f128M_to_i32.o
-SF_OBJS_OTHERS += f128M_to_i64.o
-SF_OBJS_OTHERS += f128M_to_ui32_r_minMag.o
-SF_OBJS_OTHERS += f128M_to_ui64_r_minMag.o
-SF_OBJS_OTHERS += f128M_to_i32_r_minMag.o
-SF_OBJS_OTHERS += f128M_to_i64_r_minMag.o
-SF_OBJS_OTHERS += f128M_to_f16.o
-SF_OBJS_OTHERS += f128M_to_f32.o
-SF_OBJS_OTHERS += f128M_to_extF80M.o
-SF_OBJS_OTHERS += f128M_to_f64.o
-SF_OBJS_OTHERS += f128M_roundToInt.o
-SF_OBJS_OTHERS += f128M_add.o
-SF_OBJS_OTHERS += f128M_sub.o
-SF_OBJS_OTHERS += f128M_mul.o
-SF_OBJS_OTHERS += f128M_mulAdd.o
-SF_OBJS_OTHERS += f128M_div.o
-SF_OBJS_OTHERS += f128M_rem.o
-SF_OBJS_OTHERS += f128M_sqrt.o
-SF_OBJS_OTHERS += f128M_eq.o
-SF_OBJS_OTHERS += f128M_le.o
-SF_OBJS_OTHERS += f128M_lt.o
-SF_OBJS_OTHERS += f128M_eq_signaling.o
-SF_OBJS_OTHERS += f128M_le_quiet.o
-SF_OBJS_OTHERS += f128M_lt_quiet.o
-
-SF_OBJS_ALL_NOSPEC :=
-SF_OBJS_ALL_NOSPEC += $(SF_OBJS_PRIMITIVES)
-SF_OBJS_ALL_NOSPEC += $(SF_OBJS_OTHERS)
-
-SF_OBJS_ALL :=
-SF_OBJS_ALL += $(SF_OBJS_ALL_NOSPEC)
-SF_OBJS_ALL += $(SF_OBJS_SPECIALIZE)
-
-# testfloat objects
-TF_OBJS_GENCASES :=
-TF_OBJS_GENCASES += genCases_ui32.o
-TF_OBJS_GENCASES += genCases_ui64.o
-TF_OBJS_GENCASES += genCases_i32.o
-TF_OBJS_GENCASES += genCases_i64.o
-TF_OBJS_GENCASES += genCases_f16.o
-TF_OBJS_GENCASES += genCases_f32.o
-TF_OBJS_GENCASES += genCases_f64.o
-TF_OBJS_GENCASES += genCases_extF80.o
-TF_OBJS_GENCASES += genCases_f128.o
-
-TF_OBJS_WRITECASE :=
-TF_OBJS_WRITECASE += writeCase_a_ui32.o
-TF_OBJS_WRITECASE += writeCase_a_ui64.o
-TF_OBJS_WRITECASE += writeCase_a_f16.o
-TF_OBJS_WRITECASE += writeCase_ab_f16.o
-TF_OBJS_WRITECASE += writeCase_abc_f16.o
-TF_OBJS_WRITECASE += writeCase_a_f32.o
-TF_OBJS_WRITECASE += writeCase_ab_f32.o
-TF_OBJS_WRITECASE += writeCase_abc_f32.o
-TF_OBJS_WRITECASE += writeCase_a_f64.o
-TF_OBJS_WRITECASE += writeCase_ab_f64.o
-TF_OBJS_WRITECASE += writeCase_abc_f64.o
-TF_OBJS_WRITECASE += writeCase_a_extF80M.o
-TF_OBJS_WRITECASE += writeCase_ab_extF80M.o
-TF_OBJS_WRITECASE += writeCase_a_f128M.o
-TF_OBJS_WRITECASE += writeCase_ab_f128M.o
-TF_OBJS_WRITECASE += writeCase_abc_f128M.o
-TF_OBJS_WRITECASE += writeCase_z_bool.o
-TF_OBJS_WRITECASE += writeCase_z_ui32.o
-TF_OBJS_WRITECASE += writeCase_z_ui64.o
-TF_OBJS_WRITECASE += writeCase_z_f16.o
-TF_OBJS_WRITECASE += writeCase_z_f32.o
-TF_OBJS_WRITECASE += writeCase_z_f64.o
-TF_OBJS_WRITECASE += writeCase_z_extF80M.o
-TF_OBJS_WRITECASE += writeCase_z_f128M.o
-
-TF_OBJS_TEST :=
-TF_OBJS_TEST += test_a_ui32_z_f16.o
-TF_OBJS_TEST += test_a_ui32_z_f32.o
-TF_OBJS_TEST += test_a_ui32_z_f64.o
-TF_OBJS_TEST += test_a_ui32_z_extF80.o
-TF_OBJS_TEST += test_a_ui32_z_f128.o
-TF_OBJS_TEST += test_a_ui64_z_f16.o
-TF_OBJS_TEST += test_a_ui64_z_f32.o
-TF_OBJS_TEST += test_a_ui64_z_f64.o
-TF_OBJS_TEST += test_a_ui64_z_extF80.o
-TF_OBJS_TEST += test_a_ui64_z_f128.o
-TF_OBJS_TEST += test_a_i32_z_f16.o
-TF_OBJS_TEST += test_a_i32_z_f32.o
-TF_OBJS_TEST += test_a_i32_z_f64.o
-TF_OBJS_TEST += test_a_i32_z_extF80.o
-TF_OBJS_TEST += test_a_i32_z_f128.o
-TF_OBJS_TEST += test_a_i64_z_f16.o
-TF_OBJS_TEST += test_a_i64_z_f32.o
-TF_OBJS_TEST += test_a_i64_z_f64.o
-TF_OBJS_TEST += test_a_i64_z_extF80.o
-TF_OBJS_TEST += test_a_i64_z_f128.o
-TF_OBJS_TEST += test_a_f16_z_ui32_rx.o
-TF_OBJS_TEST += test_a_f16_z_ui64_rx.o
-TF_OBJS_TEST += test_a_f16_z_i32_rx.o
-TF_OBJS_TEST += test_a_f16_z_i64_rx.o
-TF_OBJS_TEST += test_a_f16_z_ui32_x.o
-TF_OBJS_TEST += test_a_f16_z_ui64_x.o
-TF_OBJS_TEST += test_a_f16_z_i32_x.o
-TF_OBJS_TEST += test_a_f16_z_i64_x.o
-TF_OBJS_TEST += test_a_f16_z_f32.o
-TF_OBJS_TEST += test_a_f16_z_f64.o
-TF_OBJS_TEST += test_a_f16_z_extF80.o
-TF_OBJS_TEST += test_a_f16_z_f128.o
-TF_OBJS_TEST += test_az_f16.o
-TF_OBJS_TEST += test_az_f16_rx.o
-TF_OBJS_TEST += test_abz_f16.o
-TF_OBJS_TEST += test_abcz_f16.o
-TF_OBJS_TEST += test_ab_f16_z_bool.o
-TF_OBJS_TEST += test_a_f32_z_ui32_rx.o
-TF_OBJS_TEST += test_a_f32_z_ui64_rx.o
-TF_OBJS_TEST += test_a_f32_z_i32_rx.o
-TF_OBJS_TEST += test_a_f32_z_i64_rx.o
-TF_OBJS_TEST += test_a_f32_z_ui32_x.o
-TF_OBJS_TEST += test_a_f32_z_ui64_x.o
-TF_OBJS_TEST += test_a_f32_z_i32_x.o
-TF_OBJS_TEST += test_a_f32_z_i64_x.o
-TF_OBJS_TEST += test_a_f32_z_f16.o
-TF_OBJS_TEST += test_a_f32_z_f64.o
-TF_OBJS_TEST += test_a_f32_z_extF80.o
-TF_OBJS_TEST += test_a_f32_z_f128.o
-TF_OBJS_TEST += test_az_f32.o
-TF_OBJS_TEST += test_az_f32_rx.o
-TF_OBJS_TEST += test_abz_f32.o
-TF_OBJS_TEST += test_abcz_f32.o
-TF_OBJS_TEST += test_ab_f32_z_bool.o
-TF_OBJS_TEST += test_a_f64_z_ui32_rx.o
-TF_OBJS_TEST += test_a_f64_z_ui64_rx.o
-TF_OBJS_TEST += test_a_f64_z_i32_rx.o
-TF_OBJS_TEST += test_a_f64_z_i64_rx.o
-TF_OBJS_TEST += test_a_f64_z_ui32_x.o
-TF_OBJS_TEST += test_a_f64_z_ui64_x.o
-TF_OBJS_TEST += test_a_f64_z_i32_x.o
-TF_OBJS_TEST += test_a_f64_z_i64_x.o
-TF_OBJS_TEST += test_a_f64_z_f16.o
-TF_OBJS_TEST += test_a_f64_z_f32.o
-TF_OBJS_TEST += test_a_f64_z_extF80.o
-TF_OBJS_TEST += test_a_f64_z_f128.o
-TF_OBJS_TEST += test_az_f64.o
-TF_OBJS_TEST += test_az_f64_rx.o
-TF_OBJS_TEST += test_abz_f64.o
-TF_OBJS_TEST += test_abcz_f64.o
-TF_OBJS_TEST += test_ab_f64_z_bool.o
-TF_OBJS_TEST += test_a_extF80_z_ui32_rx.o
-TF_OBJS_TEST += test_a_extF80_z_ui64_rx.o
-TF_OBJS_TEST += test_a_extF80_z_i32_rx.o
-TF_OBJS_TEST += test_a_extF80_z_i64_rx.o
-TF_OBJS_TEST += test_a_extF80_z_ui32_x.o
-TF_OBJS_TEST += test_a_extF80_z_ui64_x.o
-TF_OBJS_TEST += test_a_extF80_z_i32_x.o
-TF_OBJS_TEST += test_a_extF80_z_i64_x.o
-TF_OBJS_TEST += test_a_extF80_z_f16.o
-TF_OBJS_TEST += test_a_extF80_z_f32.o
-TF_OBJS_TEST += test_a_extF80_z_f64.o
-TF_OBJS_TEST += test_a_extF80_z_f128.o
-TF_OBJS_TEST += test_az_extF80.o
-TF_OBJS_TEST += test_az_extF80_rx.o
-TF_OBJS_TEST += test_abz_extF80.o
-TF_OBJS_TEST += test_ab_extF80_z_bool.o
-TF_OBJS_TEST += test_a_f128_z_ui32_rx.o
-TF_OBJS_TEST += test_a_f128_z_ui64_rx.o
-TF_OBJS_TEST += test_a_f128_z_i32_rx.o
-TF_OBJS_TEST += test_a_f128_z_i64_rx.o
-TF_OBJS_TEST += test_a_f128_z_ui32_x.o
-TF_OBJS_TEST += test_a_f128_z_ui64_x.o
-TF_OBJS_TEST += test_a_f128_z_i32_x.o
-TF_OBJS_TEST += test_a_f128_z_i64_x.o
-TF_OBJS_TEST += test_a_f128_z_f16.o
-TF_OBJS_TEST += test_a_f128_z_f32.o
-TF_OBJS_TEST += test_a_f128_z_f64.o
-TF_OBJS_TEST += test_a_f128_z_extF80.o
-TF_OBJS_TEST += test_az_f128.o
-TF_OBJS_TEST += test_az_f128_rx.o
-TF_OBJS_TEST += test_abz_f128.o
-TF_OBJS_TEST += test_abcz_f128.o
-TF_OBJS_TEST += test_ab_f128_z_bool.o
-
-TF_OBJS_LIB :=
-TF_OBJS_LIB += uint128_inline.o
-TF_OBJS_LIB += uint128.o
-TF_OBJS_LIB += fail.o
-TF_OBJS_LIB += functions_common.o
-TF_OBJS_LIB += functionInfos.o
-TF_OBJS_LIB += standardFunctionInfos.o
-TF_OBJS_LIB += random.o
-TF_OBJS_LIB += genCases_common.o
-TF_OBJS_LIB += $(TF_OBJS_GENCASES)
-TF_OBJS_LIB += genCases_writeTestsTotal.o
-TF_OBJS_LIB += verCases_inline.o
-TF_OBJS_LIB += verCases_common.o
-TF_OBJS_LIB += verCases_writeFunctionName.o
-TF_OBJS_LIB += readHex.o
-TF_OBJS_LIB += writeHex.o
-TF_OBJS_LIB += $(TF_OBJS_WRITECASE)
-TF_OBJS_LIB += testLoops_common.o
-TF_OBJS_LIB += $(TF_OBJS_TEST)
-
-BINARIES := fp-test$(EXESUF) fp-bench$(EXESUF)
-
-# We require artefacts from the main build including config-host.h
-# because platform.h includes it. Rather than re-invoking the main
-# build we just error out if things aren't there.
-$(LIBQEMUUTIL) $(BUILD_DIR)/config-host.h:
- $(error $@ missing, re-run parent build)
-
-all: $(BUILD_DIR)/config-host.h $(BINARIES)
-
-# libtestfloat.a depends on libsoftfloat.a, so specify it first
-FP_TEST_LIBS := libtestfloat.a libsoftfloat.a $(LIBQEMUUTIL)
-
-fp-test$(EXESUF): fp-test.o slowfloat.o $(QEMU_SOFTFLOAT_OBJ) $(FP_TEST_LIBS)
-
-# Custom rule to build with SF_CFLAGS
-SF_BUILD = $(call quiet-command,$(CC) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \
- $(QEMU_CFLAGS) $(SF_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) \
- $($@-cflags) -c -o $@ $<,"CC","$(TARGET_DIR)$@")
-
-$(SF_OBJS_ALL_NOSPEC): %.o: $(SF_SOURCE_DIR)/%.c
- $(SF_BUILD)
-$(SF_OBJS_SPECIALIZE): %.o: $(SF_SPECIALIZE_DIR)/%.c
- $(SF_BUILD)
-
-libsoftfloat.a: $(SF_OBJS_ALL)
-
-# Custom rule to build with TF_CFLAGS
-$(TF_OBJS_LIB) slowfloat.o: %.o: $(TF_SOURCE_DIR)/%.c
- $(call quiet-command,$(CC) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \
- $(QEMU_CFLAGS) $(TF_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) \
- $($@-cflags) -c -o $@ $<,"CC","$(TARGET_DIR)$@")
-
-libtestfloat.a: $(TF_OBJS_LIB)
-
-fp-bench$(EXESUF): fp-bench.o $(QEMU_SOFTFLOAT_OBJ) $(LIBQEMUUTIL)
-
-clean:
- rm -f *.o *.d $(BINARIES)
- rm -f *.gcno *.gcda *.gcov
- rm -f fp-test$(EXESUF)
- rm -f fp-bench$(EXESUF)
- rm -f libsoftfloat.a
- rm -f libtestfloat.a
-
--include $(wildcard *.d)
diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c
index 43ef9628c4..06ffebd6db 100644
--- a/tests/fp/fp-test.c
+++ b/tests/fp/fp-test.c
@@ -116,7 +116,7 @@ static void usage_complete(int argc, char *argv[])
}
/* keep wrappers separate but do not bother defining headers for all of them */
-#include "wrap.inc.c"
+#include "wrap.c.inc"
static void not_implemented(void)
{
diff --git a/tests/fp/meson.build b/tests/fp/meson.build
new file mode 100644
index 0000000000..8779a17aab
--- /dev/null
+++ b/tests/fp/meson.build
@@ -0,0 +1,636 @@
+# There are namespace pollution issues on Windows, due to osdep.h
+# bringing in Windows headers that define a FLOAT128 type.
+if targetos == 'windows'
+ subdir_done()
+endif
+
+fpcflags = [
+ # softfloat defines
+ '-DSOFTFLOAT_ROUND_ODD',
+ '-DINLINE_LEVEL=5',
+ '-DSOFTFLOAT_FAST_DIV32TO16',
+ '-DSOFTFLOAT_FAST_DIV64TO32',
+ '-DSOFTFLOAT_FAST_INT64',
+ # testfloat defines
+ '-DFLOAT16',
+ '-DFLOAT64',
+ '-DEXTFLOAT80',
+ '-DFLOAT128',
+ '-DFLOAT_ROUND_ODD',
+ '-DLONG_DOUBLE_IS_EXTFLOAT80',
+]
+
+sfdir = 'berkeley-softfloat-3/source'
+sfspedir = sfdir / '8086-SSE'
+tfdir = 'berkeley-testfloat-3/source'
+
+sfinc = include_directories(sfdir / 'include', sfspedir)
+
+tfcflags = [
+ '-Wno-strict-prototypes',
+ '-Wno-unknown-pragmas',
+ '-Wno-uninitialized',
+ '-Wno-missing-prototypes',
+ '-Wno-return-type',
+ '-Wno-unused-function',
+ '-Wno-error',
+]
+
+tfgencases = [
+ tfdir / 'genCases_ui32.c',
+ tfdir / 'genCases_ui64.c',
+ tfdir / 'genCases_i32.c',
+ tfdir / 'genCases_i64.c',
+ tfdir / 'genCases_f16.c',
+ tfdir / 'genCases_f32.c',
+ tfdir / 'genCases_f64.c',
+ tfdir / 'genCases_extF80.c',
+ tfdir / 'genCases_f128.c',
+]
+
+tfwritecase = [
+ tfdir / 'writeCase_a_ui32.c',
+ tfdir / 'writeCase_a_ui64.c',
+ tfdir / 'writeCase_a_f16.c',
+ tfdir / 'writeCase_ab_f16.c',
+ tfdir / 'writeCase_abc_f16.c',
+ tfdir / 'writeCase_a_f32.c',
+ tfdir / 'writeCase_ab_f32.c',
+ tfdir / 'writeCase_abc_f32.c',
+ tfdir / 'writeCase_a_f64.c',
+ tfdir / 'writeCase_ab_f64.c',
+ tfdir / 'writeCase_abc_f64.c',
+ tfdir / 'writeCase_a_extF80M.c',
+ tfdir / 'writeCase_ab_extF80M.c',
+ tfdir / 'writeCase_a_f128M.c',
+ tfdir / 'writeCase_ab_f128M.c',
+ tfdir / 'writeCase_abc_f128M.c',
+ tfdir / 'writeCase_z_bool.c',
+ tfdir / 'writeCase_z_ui32.c',
+ tfdir / 'writeCase_z_ui64.c',
+ tfdir / 'writeCase_z_f16.c',
+ tfdir / 'writeCase_z_f32.c',
+ tfdir / 'writeCase_z_f64.c',
+ tfdir / 'writeCase_z_extF80M.c',
+ tfdir / 'writeCase_z_f128M.c',
+]
+
+tftest = [
+ tfdir / 'test_a_ui32_z_f16.c',
+ tfdir / 'test_a_ui32_z_f32.c',
+ tfdir / 'test_a_ui32_z_f64.c',
+ tfdir / 'test_a_ui32_z_extF80.c',
+ tfdir / 'test_a_ui32_z_f128.c',
+ tfdir / 'test_a_ui64_z_f16.c',
+ tfdir / 'test_a_ui64_z_f32.c',
+ tfdir / 'test_a_ui64_z_f64.c',
+ tfdir / 'test_a_ui64_z_extF80.c',
+ tfdir / 'test_a_ui64_z_f128.c',
+ tfdir / 'test_a_i32_z_f16.c',
+ tfdir / 'test_a_i32_z_f32.c',
+ tfdir / 'test_a_i32_z_f64.c',
+ tfdir / 'test_a_i32_z_extF80.c',
+ tfdir / 'test_a_i32_z_f128.c',
+ tfdir / 'test_a_i64_z_f16.c',
+ tfdir / 'test_a_i64_z_f32.c',
+ tfdir / 'test_a_i64_z_f64.c',
+ tfdir / 'test_a_i64_z_extF80.c',
+ tfdir / 'test_a_i64_z_f128.c',
+ tfdir / 'test_a_f16_z_ui32_rx.c',
+ tfdir / 'test_a_f16_z_ui64_rx.c',
+ tfdir / 'test_a_f16_z_i32_rx.c',
+ tfdir / 'test_a_f16_z_i64_rx.c',
+ tfdir / 'test_a_f16_z_ui32_x.c',
+ tfdir / 'test_a_f16_z_ui64_x.c',
+ tfdir / 'test_a_f16_z_i32_x.c',
+ tfdir / 'test_a_f16_z_i64_x.c',
+ tfdir / 'test_a_f16_z_f32.c',
+ tfdir / 'test_a_f16_z_f64.c',
+ tfdir / 'test_a_f16_z_extF80.c',
+ tfdir / 'test_a_f16_z_f128.c',
+ tfdir / 'test_az_f16.c',
+ tfdir / 'test_az_f16_rx.c',
+ tfdir / 'test_abz_f16.c',
+ tfdir / 'test_abcz_f16.c',
+ tfdir / 'test_ab_f16_z_bool.c',
+ tfdir / 'test_a_f32_z_ui32_rx.c',
+ tfdir / 'test_a_f32_z_ui64_rx.c',
+ tfdir / 'test_a_f32_z_i32_rx.c',
+ tfdir / 'test_a_f32_z_i64_rx.c',
+ tfdir / 'test_a_f32_z_ui32_x.c',
+ tfdir / 'test_a_f32_z_ui64_x.c',
+ tfdir / 'test_a_f32_z_i32_x.c',
+ tfdir / 'test_a_f32_z_i64_x.c',
+ tfdir / 'test_a_f32_z_f16.c',
+ tfdir / 'test_a_f32_z_f64.c',
+ tfdir / 'test_a_f32_z_extF80.c',
+ tfdir / 'test_a_f32_z_f128.c',
+ tfdir / 'test_az_f32.c',
+ tfdir / 'test_az_f32_rx.c',
+ tfdir / 'test_abz_f32.c',
+ tfdir / 'test_abcz_f32.c',
+ tfdir / 'test_ab_f32_z_bool.c',
+ tfdir / 'test_a_f64_z_ui32_rx.c',
+ tfdir / 'test_a_f64_z_ui64_rx.c',
+ tfdir / 'test_a_f64_z_i32_rx.c',
+ tfdir / 'test_a_f64_z_i64_rx.c',
+ tfdir / 'test_a_f64_z_ui32_x.c',
+ tfdir / 'test_a_f64_z_ui64_x.c',
+ tfdir / 'test_a_f64_z_i32_x.c',
+ tfdir / 'test_a_f64_z_i64_x.c',
+ tfdir / 'test_a_f64_z_f16.c',
+ tfdir / 'test_a_f64_z_f32.c',
+ tfdir / 'test_a_f64_z_extF80.c',
+ tfdir / 'test_a_f64_z_f128.c',
+ tfdir / 'test_az_f64.c',
+ tfdir / 'test_az_f64_rx.c',
+ tfdir / 'test_abz_f64.c',
+ tfdir / 'test_abcz_f64.c',
+ tfdir / 'test_ab_f64_z_bool.c',
+ tfdir / 'test_a_extF80_z_ui32_rx.c',
+ tfdir / 'test_a_extF80_z_ui64_rx.c',
+ tfdir / 'test_a_extF80_z_i32_rx.c',
+ tfdir / 'test_a_extF80_z_i64_rx.c',
+ tfdir / 'test_a_extF80_z_ui32_x.c',
+ tfdir / 'test_a_extF80_z_ui64_x.c',
+ tfdir / 'test_a_extF80_z_i32_x.c',
+ tfdir / 'test_a_extF80_z_i64_x.c',
+ tfdir / 'test_a_extF80_z_f16.c',
+ tfdir / 'test_a_extF80_z_f32.c',
+ tfdir / 'test_a_extF80_z_f64.c',
+ tfdir / 'test_a_extF80_z_f128.c',
+ tfdir / 'test_az_extF80.c',
+ tfdir / 'test_az_extF80_rx.c',
+ tfdir / 'test_abz_extF80.c',
+ tfdir / 'test_ab_extF80_z_bool.c',
+ tfdir / 'test_a_f128_z_ui32_rx.c',
+ tfdir / 'test_a_f128_z_ui64_rx.c',
+ tfdir / 'test_a_f128_z_i32_rx.c',
+ tfdir / 'test_a_f128_z_i64_rx.c',
+ tfdir / 'test_a_f128_z_ui32_x.c',
+ tfdir / 'test_a_f128_z_ui64_x.c',
+ tfdir / 'test_a_f128_z_i32_x.c',
+ tfdir / 'test_a_f128_z_i64_x.c',
+ tfdir / 'test_a_f128_z_f16.c',
+ tfdir / 'test_a_f128_z_f32.c',
+ tfdir / 'test_a_f128_z_f64.c',
+ tfdir / 'test_a_f128_z_extF80.c',
+ tfdir / 'test_az_f128.c',
+ tfdir / 'test_az_f128_rx.c',
+ tfdir / 'test_abz_f128.c',
+ tfdir / 'test_abcz_f128.c',
+ tfdir / 'test_ab_f128_z_bool.c',
+]
+
+libtestfloat = static_library(
+ 'testfloat',
+ files(
+ tfdir / 'uint128_inline.c',
+ tfdir / 'uint128.c',
+ tfdir / 'fail.c',
+ tfdir / 'functions_common.c',
+ tfdir / 'functionInfos.c',
+ tfdir / 'standardFunctionInfos.c',
+ tfdir / 'random.c',
+ tfdir / 'genCases_common.c',
+ tfgencases,
+ tfdir / 'genCases_writeTestsTotal.c',
+ tfdir / 'verCases_inline.c',
+ tfdir / 'verCases_common.c',
+ tfdir / 'verCases_writeFunctionName.c',
+ tfdir / 'readHex.c',
+ tfdir / 'writeHex.c',
+ tfwritecase,
+ tfdir / 'testLoops_common.c',
+ tftest,
+ ),
+ include_directories: sfinc,
+ c_args: tfcflags + fpcflags,
+)
+
+sfcflags = [
+ '-Wno-missing-prototypes',
+ '-Wno-redundant-decls',
+ '-Wno-return-type',
+ '-Wno-error',
+]
+
+libsoftfloat = static_library(
+ 'softfloat',
+ files(
+ # primitives
+ sfdir / 's_eq128.c',
+ sfdir / 's_le128.c',
+ sfdir / 's_lt128.c',
+ sfdir / 's_shortShiftLeft128.c',
+ sfdir / 's_shortShiftRight128.c',
+ sfdir / 's_shortShiftRightJam64.c',
+ sfdir / 's_shortShiftRightJam64Extra.c',
+ sfdir / 's_shortShiftRightJam128.c',
+ sfdir / 's_shortShiftRightJam128Extra.c',
+ sfdir / 's_shiftRightJam32.c',
+ sfdir / 's_shiftRightJam64.c',
+ sfdir / 's_shiftRightJam64Extra.c',
+ sfdir / 's_shiftRightJam128.c',
+ sfdir / 's_shiftRightJam128Extra.c',
+ sfdir / 's_shiftRightJam256M.c',
+ sfdir / 's_countLeadingZeros8.c',
+ sfdir / 's_countLeadingZeros16.c',
+ sfdir / 's_countLeadingZeros32.c',
+ sfdir / 's_countLeadingZeros64.c',
+ sfdir / 's_add128.c',
+ sfdir / 's_add256M.c',
+ sfdir / 's_sub128.c',
+ sfdir / 's_sub256M.c',
+ sfdir / 's_mul64ByShifted32To128.c',
+ sfdir / 's_mul64To128.c',
+ sfdir / 's_mul128By32.c',
+ sfdir / 's_mul128To256M.c',
+ sfdir / 's_approxRecip_1Ks.c',
+ sfdir / 's_approxRecip32_1.c',
+ sfdir / 's_approxRecipSqrt_1Ks.c',
+ sfdir / 's_approxRecipSqrt32_1.c',
+ # others
+ sfdir / 's_roundToUI32.c',
+ sfdir / 's_roundToUI64.c',
+ sfdir / 's_roundToI32.c',
+ sfdir / 's_roundToI64.c',
+ sfdir / 's_normSubnormalF16Sig.c',
+ sfdir / 's_roundPackToF16.c',
+ sfdir / 's_normRoundPackToF16.c',
+ sfdir / 's_addMagsF16.c',
+ sfdir / 's_subMagsF16.c',
+ sfdir / 's_mulAddF16.c',
+ sfdir / 's_normSubnormalF32Sig.c',
+ sfdir / 's_roundPackToF32.c',
+ sfdir / 's_normRoundPackToF32.c',
+ sfdir / 's_addMagsF32.c',
+ sfdir / 's_subMagsF32.c',
+ sfdir / 's_mulAddF32.c',
+ sfdir / 's_normSubnormalF64Sig.c',
+ sfdir / 's_roundPackToF64.c',
+ sfdir / 's_normRoundPackToF64.c',
+ sfdir / 's_addMagsF64.c',
+ sfdir / 's_subMagsF64.c',
+ sfdir / 's_mulAddF64.c',
+ sfdir / 's_normSubnormalExtF80Sig.c',
+ sfdir / 's_roundPackToExtF80.c',
+ sfdir / 's_normRoundPackToExtF80.c',
+ sfdir / 's_addMagsExtF80.c',
+ sfdir / 's_subMagsExtF80.c',
+ sfdir / 's_normSubnormalF128Sig.c',
+ sfdir / 's_roundPackToF128.c',
+ sfdir / 's_normRoundPackToF128.c',
+ sfdir / 's_addMagsF128.c',
+ sfdir / 's_subMagsF128.c',
+ sfdir / 's_mulAddF128.c',
+ sfdir / 'softfloat_state.c',
+ sfdir / 'ui32_to_f16.c',
+ sfdir / 'ui32_to_f32.c',
+ sfdir / 'ui32_to_f64.c',
+ sfdir / 'ui32_to_extF80.c',
+ sfdir / 'ui32_to_extF80M.c',
+ sfdir / 'ui32_to_f128.c',
+ sfdir / 'ui32_to_f128M.c',
+ sfdir / 'ui64_to_f16.c',
+ sfdir / 'ui64_to_f32.c',
+ sfdir / 'ui64_to_f64.c',
+ sfdir / 'ui64_to_extF80.c',
+ sfdir / 'ui64_to_extF80M.c',
+ sfdir / 'ui64_to_f128.c',
+ sfdir / 'ui64_to_f128M.c',
+ sfdir / 'i32_to_f16.c',
+ sfdir / 'i32_to_f32.c',
+ sfdir / 'i32_to_f64.c',
+ sfdir / 'i32_to_extF80.c',
+ sfdir / 'i32_to_extF80M.c',
+ sfdir / 'i32_to_f128.c',
+ sfdir / 'i32_to_f128M.c',
+ sfdir / 'i64_to_f16.c',
+ sfdir / 'i64_to_f32.c',
+ sfdir / 'i64_to_f64.c',
+ sfdir / 'i64_to_extF80.c',
+ sfdir / 'i64_to_extF80M.c',
+ sfdir / 'i64_to_f128.c',
+ sfdir / 'i64_to_f128M.c',
+ sfdir / 'f16_to_ui32.c',
+ sfdir / 'f16_to_ui64.c',
+ sfdir / 'f16_to_i32.c',
+ sfdir / 'f16_to_i64.c',
+ sfdir / 'f16_to_ui32_r_minMag.c',
+ sfdir / 'f16_to_ui64_r_minMag.c',
+ sfdir / 'f16_to_i32_r_minMag.c',
+ sfdir / 'f16_to_i64_r_minMag.c',
+ sfdir / 'f16_to_f32.c',
+ sfdir / 'f16_to_f64.c',
+ sfdir / 'f16_to_extF80.c',
+ sfdir / 'f16_to_extF80M.c',
+ sfdir / 'f16_to_f128.c',
+ sfdir / 'f16_to_f128M.c',
+ sfdir / 'f16_roundToInt.c',
+ sfdir / 'f16_add.c',
+ sfdir / 'f16_sub.c',
+ sfdir / 'f16_mul.c',
+ sfdir / 'f16_mulAdd.c',
+ sfdir / 'f16_div.c',
+ sfdir / 'f16_rem.c',
+ sfdir / 'f16_sqrt.c',
+ sfdir / 'f16_eq.c',
+ sfdir / 'f16_le.c',
+ sfdir / 'f16_lt.c',
+ sfdir / 'f16_eq_signaling.c',
+ sfdir / 'f16_le_quiet.c',
+ sfdir / 'f16_lt_quiet.c',
+ sfdir / 'f16_isSignalingNaN.c',
+ sfdir / 'f32_to_ui32.c',
+ sfdir / 'f32_to_ui64.c',
+ sfdir / 'f32_to_i32.c',
+ sfdir / 'f32_to_i64.c',
+ sfdir / 'f32_to_ui32_r_minMag.c',
+ sfdir / 'f32_to_ui64_r_minMag.c',
+ sfdir / 'f32_to_i32_r_minMag.c',
+ sfdir / 'f32_to_i64_r_minMag.c',
+ sfdir / 'f32_to_f16.c',
+ sfdir / 'f32_to_f64.c',
+ sfdir / 'f32_to_extF80.c',
+ sfdir / 'f32_to_extF80M.c',
+ sfdir / 'f32_to_f128.c',
+ sfdir / 'f32_to_f128M.c',
+ sfdir / 'f32_roundToInt.c',
+ sfdir / 'f32_add.c',
+ sfdir / 'f32_sub.c',
+ sfdir / 'f32_mul.c',
+ sfdir / 'f32_mulAdd.c',
+ sfdir / 'f32_div.c',
+ sfdir / 'f32_rem.c',
+ sfdir / 'f32_sqrt.c',
+ sfdir / 'f32_eq.c',
+ sfdir / 'f32_le.c',
+ sfdir / 'f32_lt.c',
+ sfdir / 'f32_eq_signaling.c',
+ sfdir / 'f32_le_quiet.c',
+ sfdir / 'f32_lt_quiet.c',
+ sfdir / 'f32_isSignalingNaN.c',
+ sfdir / 'f64_to_ui32.c',
+ sfdir / 'f64_to_ui64.c',
+ sfdir / 'f64_to_i32.c',
+ sfdir / 'f64_to_i64.c',
+ sfdir / 'f64_to_ui32_r_minMag.c',
+ sfdir / 'f64_to_ui64_r_minMag.c',
+ sfdir / 'f64_to_i32_r_minMag.c',
+ sfdir / 'f64_to_i64_r_minMag.c',
+ sfdir / 'f64_to_f16.c',
+ sfdir / 'f64_to_f32.c',
+ sfdir / 'f64_to_extF80.c',
+ sfdir / 'f64_to_extF80M.c',
+ sfdir / 'f64_to_f128.c',
+ sfdir / 'f64_to_f128M.c',
+ sfdir / 'f64_roundToInt.c',
+ sfdir / 'f64_add.c',
+ sfdir / 'f64_sub.c',
+ sfdir / 'f64_mul.c',
+ sfdir / 'f64_mulAdd.c',
+ sfdir / 'f64_div.c',
+ sfdir / 'f64_rem.c',
+ sfdir / 'f64_sqrt.c',
+ sfdir / 'f64_eq.c',
+ sfdir / 'f64_le.c',
+ sfdir / 'f64_lt.c',
+ sfdir / 'f64_eq_signaling.c',
+ sfdir / 'f64_le_quiet.c',
+ sfdir / 'f64_lt_quiet.c',
+ sfdir / 'f64_isSignalingNaN.c',
+ sfdir / 'extF80_to_ui32.c',
+ sfdir / 'extF80_to_ui64.c',
+ sfdir / 'extF80_to_i32.c',
+ sfdir / 'extF80_to_i64.c',
+ sfdir / 'extF80_to_ui32_r_minMag.c',
+ sfdir / 'extF80_to_ui64_r_minMag.c',
+ sfdir / 'extF80_to_i32_r_minMag.c',
+ sfdir / 'extF80_to_i64_r_minMag.c',
+ sfdir / 'extF80_to_f16.c',
+ sfdir / 'extF80_to_f32.c',
+ sfdir / 'extF80_to_f64.c',
+ sfdir / 'extF80_to_f128.c',
+ sfdir / 'extF80_roundToInt.c',
+ sfdir / 'extF80_add.c',
+ sfdir / 'extF80_sub.c',
+ sfdir / 'extF80_mul.c',
+ sfdir / 'extF80_div.c',
+ sfdir / 'extF80_rem.c',
+ sfdir / 'extF80_sqrt.c',
+ sfdir / 'extF80_eq.c',
+ sfdir / 'extF80_le.c',
+ sfdir / 'extF80_lt.c',
+ sfdir / 'extF80_eq_signaling.c',
+ sfdir / 'extF80_le_quiet.c',
+ sfdir / 'extF80_lt_quiet.c',
+ sfdir / 'extF80_isSignalingNaN.c',
+ sfdir / 'extF80M_to_ui32.c',
+ sfdir / 'extF80M_to_ui64.c',
+ sfdir / 'extF80M_to_i32.c',
+ sfdir / 'extF80M_to_i64.c',
+ sfdir / 'extF80M_to_ui32_r_minMag.c',
+ sfdir / 'extF80M_to_ui64_r_minMag.c',
+ sfdir / 'extF80M_to_i32_r_minMag.c',
+ sfdir / 'extF80M_to_i64_r_minMag.c',
+ sfdir / 'extF80M_to_f16.c',
+ sfdir / 'extF80M_to_f32.c',
+ sfdir / 'extF80M_to_f64.c',
+ sfdir / 'extF80M_to_f128M.c',
+ sfdir / 'extF80M_roundToInt.c',
+ sfdir / 'extF80M_add.c',
+ sfdir / 'extF80M_sub.c',
+ sfdir / 'extF80M_mul.c',
+ sfdir / 'extF80M_div.c',
+ sfdir / 'extF80M_rem.c',
+ sfdir / 'extF80M_sqrt.c',
+ sfdir / 'extF80M_eq.c',
+ sfdir / 'extF80M_le.c',
+ sfdir / 'extF80M_lt.c',
+ sfdir / 'extF80M_eq_signaling.c',
+ sfdir / 'extF80M_le_quiet.c',
+ sfdir / 'extF80M_lt_quiet.c',
+ sfdir / 'f128_to_ui32.c',
+ sfdir / 'f128_to_ui64.c',
+ sfdir / 'f128_to_i32.c',
+ sfdir / 'f128_to_i64.c',
+ sfdir / 'f128_to_ui32_r_minMag.c',
+ sfdir / 'f128_to_ui64_r_minMag.c',
+ sfdir / 'f128_to_i32_r_minMag.c',
+ sfdir / 'f128_to_i64_r_minMag.c',
+ sfdir / 'f128_to_f16.c',
+ sfdir / 'f128_to_f32.c',
+ sfdir / 'f128_to_extF80.c',
+ sfdir / 'f128_to_f64.c',
+ sfdir / 'f128_roundToInt.c',
+ sfdir / 'f128_add.c',
+ sfdir / 'f128_sub.c',
+ sfdir / 'f128_mul.c',
+ sfdir / 'f128_mulAdd.c',
+ sfdir / 'f128_div.c',
+ sfdir / 'f128_rem.c',
+ sfdir / 'f128_sqrt.c',
+ sfdir / 'f128_eq.c',
+ sfdir / 'f128_le.c',
+ sfdir / 'f128_lt.c',
+ sfdir / 'f128_eq_signaling.c',
+ sfdir / 'f128_le_quiet.c',
+ sfdir / 'f128_lt_quiet.c',
+ sfdir / 'f128_isSignalingNaN.c',
+ sfdir / 'f128M_to_ui32.c',
+ sfdir / 'f128M_to_ui64.c',
+ sfdir / 'f128M_to_i32.c',
+ sfdir / 'f128M_to_i64.c',
+ sfdir / 'f128M_to_ui32_r_minMag.c',
+ sfdir / 'f128M_to_ui64_r_minMag.c',
+ sfdir / 'f128M_to_i32_r_minMag.c',
+ sfdir / 'f128M_to_i64_r_minMag.c',
+ sfdir / 'f128M_to_f16.c',
+ sfdir / 'f128M_to_f32.c',
+ sfdir / 'f128M_to_extF80M.c',
+ sfdir / 'f128M_to_f64.c',
+ sfdir / 'f128M_roundToInt.c',
+ sfdir / 'f128M_add.c',
+ sfdir / 'f128M_sub.c',
+ sfdir / 'f128M_mul.c',
+ sfdir / 'f128M_mulAdd.c',
+ sfdir / 'f128M_div.c',
+ sfdir / 'f128M_rem.c',
+ sfdir / 'f128M_sqrt.c',
+ sfdir / 'f128M_eq.c',
+ sfdir / 'f128M_le.c',
+ sfdir / 'f128M_lt.c',
+ sfdir / 'f128M_eq_signaling.c',
+ sfdir / 'f128M_le_quiet.c',
+ sfdir / 'f128M_lt_quiet.c',
+ # spe
+ sfspedir / 'softfloat_raiseFlags.c',
+ sfspedir / 's_f16UIToCommonNaN.c',
+ sfspedir / 's_commonNaNToF16UI.c',
+ sfspedir / 's_propagateNaNF16UI.c',
+ sfspedir / 's_f32UIToCommonNaN.c',
+ sfspedir / 's_commonNaNToF32UI.c',
+ sfspedir / 's_propagateNaNF32UI.c',
+ sfspedir / 's_f64UIToCommonNaN.c',
+ sfspedir / 's_commonNaNToF64UI.c',
+ sfspedir / 's_propagateNaNF64UI.c',
+ sfspedir / 'extF80M_isSignalingNaN.c',
+ sfspedir / 's_extF80UIToCommonNaN.c',
+ sfspedir / 's_commonNaNToExtF80UI.c',
+ sfspedir / 's_propagateNaNExtF80UI.c',
+ sfspedir / 'f128M_isSignalingNaN.c',
+ sfspedir / 's_f128UIToCommonNaN.c',
+ sfspedir / 's_commonNaNToF128UI.c',
+ sfspedir / 's_propagateNaNF128UI.c',
+ ),
+ include_directories: sfinc,
+ c_args: sfcflags + fpcflags,
+)
+
+fpcflags += [
+ # work around TARGET_* poisoning
+ '-DHW_POISON_H',
+ # define a target to match testfloat's implementation-defined choices, such as
+ # whether to raise the invalid flag when dealing with NaNs in muladd.
+ '-DTARGET_ARM',
+ # FIXME: uiZ may be used uninitialized in this function
+ '-Wno-uninitialized',
+]
+
+fptest = executable(
+ 'fp-test',
+ ['fp-test.c', tfdir / 'slowfloat.c', '../../fpu/softfloat.c'],
+ build_by_default: false,
+ link_with: [libtestfloat, libsoftfloat],
+ dependencies: [qemuutil],
+ include_directories: [sfinc, include_directories(tfdir)],
+ c_args: fpcflags,
+)
+softfloat_conv_tests = {
+ 'float-to-float': 'f16_to_f32 f16_to_f64 f16_to_extF80 f16_to_f128 ' +
+ 'f32_to_f16 f32_to_f64 f32_to_extF80 ' +
+ 'f64_to_f16 f64_to_f32 ' +
+ 'extF80_to_f16 extF80_to_f32 ' +
+ 'extF80_to_f64 extF80_to_f128 ' +
+ 'f128_to_f16',
+ 'int-to-float': 'i32_to_f16 i64_to_f16 i32_to_f32 i64_to_f32 ' +
+ 'i32_to_f64 i64_to_f64 i32_to_f128 i64_to_f128',
+ 'uint-to-float': 'ui32_to_f16 ui64_to_f16 ui32_to_f32 ui64_to_f32 ' +
+ 'ui32_to_f64 ui64_to_f64 ui64_to_f128 ' +
+ 'ui32_to_extF80 ui64_to_extF80',
+ 'float-to-int': 'f16_to_i32 f16_to_i32_r_minMag ' +
+ 'f32_to_i32 f32_to_i32_r_minMag ' +
+ 'f64_to_i32 f64_to_i32_r_minMag ' +
+ 'extF80_to_i32 extF80_to_i32_r_minMag ' +
+ 'f128_to_i32 f128_to_i32_r_minMag ' +
+ 'f16_to_i64 f16_to_i64_r_minMag ' +
+ 'f32_to_i64 f32_to_i64_r_minMag ' +
+ 'f64_to_i64 f64_to_i64_r_minMag ' +
+ 'extF80_to_i64 extF80_to_i64_r_minMag ' +
+ 'f128_to_i64 f128_to_i64_r_minMag',
+ 'float-to-uint': 'f16_to_ui32 f16_to_ui32_r_minMag ' +
+ 'f32_to_ui32 f32_to_ui32_r_minMag ' +
+ 'f64_to_ui32 f64_to_ui32_r_minMag ' +
+ 'extF80_to_ui32 extF80_to_ui32_r_minMag ' +
+ 'f128_to_ui32 f128_to_ui32_r_minMag ' +
+ 'f16_to_ui64 f16_to_ui64_r_minMag ' +
+ 'f32_to_ui64 f32_to_ui64_r_minMag ' +
+ 'f64_to_ui64 f64_to_ui64_r_minMag ' +
+ 'extF80_to_ui64 extF80_to_ui64_r_minMag ' +
+ 'f128_to_ui64 f128_to_ui64_r_minMag',
+ 'round-to-integer': 'f16_roundToInt f32_roundToInt ' +
+ 'f64_roundToInt f128_roundToInt'
+}
+softfloat_tests = {
+ 'eq_signaling' : 'compare',
+ 'le' : 'compare',
+ 'le_quiet' : 'compare',
+ 'lt_quiet' : 'compare',
+ 'add': 'ops',
+ 'sub': 'ops',
+ 'mul': 'ops',
+ 'div': 'ops',
+ 'rem': 'ops',
+ 'sqrt': 'ops'
+}
+# The full test suite can take a bit of time, default to a quick run
+# "-l 2 -r all" can take more than a day for some operations and is best
+# run manually
+fptest_args = ['-s', '-l', '1']
+fptest_rounding_args = ['-r', 'all']
+
+# Conversion Routines:
+# FIXME: i32_to_extF80 (broken), i64_to_extF80 (broken)
+# extF80_roundToInt (broken)
+foreach k, v : softfloat_conv_tests
+ test('fp-test:' + k, fptest,
+ args: fptest_args + fptest_rounding_args + v.split(),
+ suite: ['softfloat', 'softfloat-conv'])
+endforeach
+
+# FIXME: extF80_{lt_quiet, rem} (broken),
+# extF80_{mulAdd} (missing)
+foreach k, v : softfloat_tests
+ extF80_broken = ['lt_quiet', 'rem'].contains(k)
+ test('fp-test:' + k, fptest,
+ args: fptest_args + fptest_rounding_args +
+ ['f16_' + k, 'f32_' + k, 'f64_' + k, 'f128_' + k] +
+ (extF80_broken ? [] : ['extF80_' + k]),
+ suite: ['softfloat', 'softfloat-' + v])
+endforeach
+test('fp-test:mulAdd', fptest,
+ # no fptest_rounding_args
+ args: fptest_args +
+ ['f16_mulAdd', 'f32_mulAdd', 'f64_mulAdd', 'f128_mulAdd'],
+ suite: ['softfloat-slow', 'softfloat-ops-slow'], timeout: 60)
+
+fpbench = executable(
+ 'fp-bench',
+ ['fp-bench.c', '../../fpu/softfloat.c'],
+ build_by_default: false,
+ link_with: [libtestfloat, libsoftfloat],
+ dependencies: [qemuutil],
+ include_directories: [sfinc, include_directories(tfdir)],
+ c_args: fpcflags,
+)
diff --git a/tests/fp/wrap.inc.c b/tests/fp/wrap.c.inc
index 0cbd20013e..0cbd20013e 100644
--- a/tests/fp/wrap.inc.c
+++ b/tests/fp/wrap.c.inc
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000000..fe2c6d8e6b
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,18 @@
+if have_system and 'CONFIG_POSIX' in config_host
+ subdir('qemu-iotests')
+endif
+
+test('decodetree', sh,
+ args: [ files('decode/check.sh'), config_host['PYTHON'], files('../scripts/decodetree.py') ],
+ workdir: meson.current_source_dir() / 'decode',
+ suite: 'decodetree')
+
+if 'CONFIG_TCG' in config_host
+ subdir('fp')
+ if 'CONFIG_PLUGIN' in config_host
+ subdir('plugin')
+ endif
+endif
+
+subdir('qapi-schema')
+subdir('qtest')
diff --git a/tests/multiboot/run_test.sh b/tests/multiboot/run_test.sh
index 98df91e6af..f968bf797e 100755
--- a/tests/multiboot/run_test.sh
+++ b/tests/multiboot/run_test.sh
@@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
-QEMU=${QEMU:-"../../x86_64-softmmu/qemu-system-x86_64"}
+QEMU=${QEMU:-"../../qemu-system-x86_64"}
run_qemu() {
local kernel=$1
diff --git a/tests/plugin/Makefile b/tests/plugin/Makefile
deleted file mode 100644
index e9348fde4a..0000000000
--- a/tests/plugin/Makefile
+++ /dev/null
@@ -1,46 +0,0 @@
-# -*- Mode: makefile -*-
-#
-# This Makefile example is fairly independent from the main makefile
-# so users can take and adapt it for their build. We only really
-# include config-host.mak so we don't have to repeat probing for
-# cflags that the main configure has already done for us.
-#
-
-BUILD_DIR := $(CURDIR)/../..
-
-include $(BUILD_DIR)/config-host.mak
-
-VPATH += $(SRC_PATH)/tests/plugin
-
-NAMES :=
-NAMES += bb
-NAMES += empty
-NAMES += insn
-NAMES += mem
-NAMES += hotblocks
-NAMES += howvec
-NAMES += hotpages
-NAMES += lockstep
-
-SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES)))
-
-# The main QEMU uses Glib extensively so it's perfectly fine to use it
-# in plugins (which many example do).
-CFLAGS = $(GLIB_CFLAGS)
-CFLAGS += -fPIC
-CFLAGS += $(if $(findstring no-psabi,$(QEMU_CFLAGS)),-Wpsabi)
-CFLAGS += -I$(SRC_PATH)/include/qemu
-
-all: $(SONAMES)
-
-%.o: %.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-lib%.so: %.o
- $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDLIBS)
-
-clean:
- rm -f *.o *.so *.d
- rm -Rf .libs
-
-.PHONY: all clean
diff --git a/tests/plugin/meson.build b/tests/plugin/meson.build
new file mode 100644
index 0000000000..dbbdcbaa67
--- /dev/null
+++ b/tests/plugin/meson.build
@@ -0,0 +1,7 @@
+t = []
+foreach i : ['bb', 'empty', 'insn', 'mem', 'hotblocks', 'howvec', 'hotpages', 'lockstep']
+ t += shared_module(i, files(i + '.c'),
+ include_directories: '../../include/qemu',
+ dependencies: glib)
+endforeach
+alias_target('plugins', t)
diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.json
index ddd89d1233..9da72a1f55 100644
--- a/tests/qapi-schema/doc-good.json
+++ b/tests/qapi-schema/doc-good.json
@@ -1,4 +1,6 @@
# -*- Mode: Python -*-
+# vim: filetype=python
+#
# Positive QAPI doc comment tests
{ 'pragma': { 'doc-required': true } }
diff --git a/tests/qapi-schema/include/sub-module.json b/tests/qapi-schema/include/sub-module.json
index afdb267228..b9f7b9bb56 100644
--- a/tests/qapi-schema/include/sub-module.json
+++ b/tests/qapi-schema/include/sub-module.json
@@ -1,4 +1,5 @@
# *-*- Mode: Python -*-*
+# vim: filetype=python
# Sub-module of ../qapi-schema-test.json
diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build
new file mode 100644
index 0000000000..c87d141417
--- /dev/null
+++ b/tests/qapi-schema/meson.build
@@ -0,0 +1,225 @@
+test_env = environment()
+test_env.set('PYTHONPATH', meson.source_root() / 'scripts')
+test_env.set('PYTHONIOENCODING', 'utf-8')
+
+schemas = [
+ 'alternate-any.json',
+ 'alternate-array.json',
+ 'alternate-base.json',
+ 'alternate-branch-if-invalid.json',
+ 'alternate-clash.json',
+ 'alternate-conflict-dict.json',
+ 'alternate-conflict-enum-bool.json',
+ 'alternate-conflict-enum-int.json',
+ 'alternate-conflict-string.json',
+ 'alternate-conflict-bool-string.json',
+ 'alternate-conflict-num-string.json',
+ 'alternate-empty.json',
+ 'alternate-invalid-dict.json',
+ 'alternate-nested.json',
+ 'alternate-unknown.json',
+ 'args-alternate.json',
+ 'args-any.json',
+ 'args-array-empty.json',
+ 'args-array-unknown.json',
+ 'args-bad-boxed.json',
+ 'args-boxed-anon.json',
+ 'args-boxed-string.json',
+ 'args-int.json',
+ 'args-invalid.json',
+ 'args-member-array-bad.json',
+ 'args-member-case.json',
+ 'args-member-unknown.json',
+ 'args-name-clash.json',
+ 'args-union.json',
+ 'args-unknown.json',
+ 'bad-base.json',
+ 'bad-data.json',
+ 'bad-ident.json',
+ 'bad-if.json',
+ 'bad-if-empty.json',
+ 'bad-if-empty-list.json',
+ 'bad-if-list.json',
+ 'bad-type-bool.json',
+ 'bad-type-dict.json',
+ 'bad-type-int.json',
+ 'base-cycle-direct.json',
+ 'base-cycle-indirect.json',
+ 'command-int.json',
+ 'comments.json',
+ 'doc-bad-alternate-member.json',
+ 'doc-bad-boxed-command-arg.json',
+ 'doc-bad-command-arg.json',
+ 'doc-bad-enum-member.json',
+ 'doc-bad-event-arg.json',
+ 'doc-bad-feature.json',
+ 'doc-bad-section.json',
+ 'doc-bad-symbol.json',
+ 'doc-bad-union-member.json',
+ 'doc-before-include.json',
+ 'doc-before-pragma.json',
+ 'doc-duplicated-arg.json',
+ 'doc-duplicated-return.json',
+ 'doc-duplicated-since.json',
+ 'doc-empty-arg.json',
+ 'doc-empty-section.json',
+ 'doc-empty-symbol.json',
+ 'doc-good.json',
+ 'doc-interleaved-section.json',
+ 'doc-invalid-end.json',
+ 'doc-invalid-end2.json',
+ 'doc-invalid-return.json',
+ 'doc-invalid-section.json',
+ 'doc-invalid-start.json',
+ 'doc-missing-colon.json',
+ 'doc-missing-expr.json',
+ 'doc-missing-space.json',
+ 'doc-missing.json',
+ 'doc-no-symbol.json',
+ 'doc-undoc-feature.json',
+ 'double-type.json',
+ 'duplicate-key.json',
+ 'empty.json',
+ 'enum-bad-member.json',
+ 'enum-bad-name.json',
+ 'enum-bad-prefix.json',
+ 'enum-clash-member.json',
+ 'enum-dict-member-unknown.json',
+ 'enum-if-invalid.json',
+ 'enum-int-member.json',
+ 'enum-member-case.json',
+ 'enum-missing-data.json',
+ 'enum-wrong-data.json',
+ 'event-boxed-empty.json',
+ 'event-case.json',
+ 'event-member-invalid-dict.json',
+ 'event-nest-struct.json',
+ 'features-bad-type.json',
+ 'features-deprecated-type.json',
+ 'features-duplicate-name.json',
+ 'features-if-invalid.json',
+ 'features-missing-name.json',
+ 'features-name-bad-type.json',
+ 'features-no-list.json',
+ 'features-unknown-key.json',
+ 'flat-union-array-branch.json',
+ 'flat-union-bad-base.json',
+ 'flat-union-bad-discriminator.json',
+ 'flat-union-base-any.json',
+ 'flat-union-base-union.json',
+ 'flat-union-clash-member.json',
+ 'flat-union-discriminator-bad-name.json',
+ 'flat-union-empty.json',
+ 'flat-union-inline.json',
+ 'flat-union-inline-invalid-dict.json',
+ 'flat-union-int-branch.json',
+ 'flat-union-invalid-branch-key.json',
+ 'flat-union-invalid-discriminator.json',
+ 'flat-union-invalid-if-discriminator.json',
+ 'flat-union-no-base.json',
+ 'flat-union-optional-discriminator.json',
+ 'flat-union-string-discriminator.json',
+ 'funny-char.json',
+ 'funny-word.json',
+ 'ident-with-escape.json',
+ 'include-before-err.json',
+ 'include-cycle.json',
+ 'include-extra-junk.json',
+ 'include-nested-err.json',
+ 'include-no-file.json',
+ 'include-non-file.json',
+ 'include-repetition.json',
+ 'include-self-cycle.json',
+ 'include-simple.json',
+ 'indented-expr.json',
+ 'leading-comma-list.json',
+ 'leading-comma-object.json',
+ 'missing-colon.json',
+ 'missing-comma-list.json',
+ 'missing-comma-object.json',
+ 'missing-type.json',
+ 'nested-struct-data.json',
+ 'nested-struct-data-invalid-dict.json',
+ 'non-objects.json',
+ 'oob-test.json',
+ 'allow-preconfig-test.json',
+ 'pragma-doc-required-crap.json',
+ 'pragma-extra-junk.json',
+ 'pragma-name-case-whitelist-crap.json',
+ 'pragma-non-dict.json',
+ 'pragma-unknown.json',
+ 'pragma-returns-whitelist-crap.json',
+ 'qapi-schema-test.json',
+ 'quoted-structural-chars.json',
+ 'redefined-builtin.json',
+ 'redefined-command.json',
+ 'redefined-event.json',
+ 'redefined-type.json',
+ 'reserved-command-q.json',
+ 'reserved-enum-q.json',
+ 'reserved-member-has.json',
+ 'reserved-member-q.json',
+ 'reserved-member-u.json',
+ 'reserved-member-underscore.json',
+ 'reserved-type-kind.json',
+ 'reserved-type-list.json',
+ 'returns-alternate.json',
+ 'returns-array-bad.json',
+ 'returns-dict.json',
+ 'returns-unknown.json',
+ 'returns-whitelist.json',
+ 'string-code-point-31.json',
+ 'string-code-point-127.json',
+ 'struct-base-clash-deep.json',
+ 'struct-base-clash.json',
+ 'struct-data-invalid.json',
+ 'struct-member-if-invalid.json',
+ 'struct-member-invalid-dict.json',
+ 'struct-member-invalid.json',
+ 'trailing-comma-list.json',
+ 'trailing-comma-object.json',
+ 'type-bypass-bad-gen.json',
+ 'unclosed-list.json',
+ 'unclosed-object.json',
+ 'unclosed-string.json',
+ 'union-base-empty.json',
+ 'union-base-no-discriminator.json',
+ 'union-branch-case.json',
+ 'union-branch-if-invalid.json',
+ 'union-branch-invalid-dict.json',
+ 'union-clash-branches.json',
+ 'union-empty.json',
+ 'union-invalid-base.json',
+ 'union-optional-branch.json',
+ 'union-unknown.json',
+ 'unknown-escape.json',
+ 'unknown-expr-key.json',
+]
+
+# Because people may want to use test-qapi.py from the command line, we
+# are not using the "#! /usr/bin/env python3" trick here. See
+# docs/devel/build-system.txt
+test('QAPI schema regression tests', python, args: files('test-qapi.py', schemas),
+ env: test_env, suite: ['qapi-schema', 'qapi-frontend'])
+
+diff = find_program('diff')
+
+qapi_doc = custom_target('QAPI doc',
+ output: ['doc-good-qapi-doc.texi',
+ 'doc-good-qapi-commands.c', 'doc-good-qapi-commands.h',
+ 'doc-good-qapi-emit-events.c', 'doc-good-qapi-emit-events.h',
+ 'doc-good-qapi-events.c', 'doc-good-qapi-events.h',
+ 'doc-good-qapi-init-commands.c', 'doc-good-qapi-init-commands.h',
+ 'doc-good-qapi-introspect.c', 'doc-good-qapi-introspect.h',
+ 'doc-good-qapi-types.c', 'doc-good-qapi-types.h',
+ 'doc-good-qapi-visit.c', 'doc-good-qapi-visit.h' ],
+ input: files('doc-good.json'),
+ command: [ qapi_gen, '-o', meson.current_build_dir(),
+ '-p', 'doc-good-', '@INPUT0@' ],
+ depend_files: qapi_gen_depends)
+
+# "full_path()" needed here to work around
+# https://github.com/mesonbuild/meson/issues/7585
+test('QAPI doc', diff, args: ['-u', files('doc-good.texi'), qapi_doc[0].full_path()],
+ depends: qapi_doc,
+ suite: ['qapi-schema', 'qapi-doc'])
diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
index 6b1f05afa7..3a9f2cbb33 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -1,4 +1,5 @@
# *-*- Mode: Python -*-*
+# vim: filetype=python
# This file is a stress test of supported qapi constructs that must
# parse and compile correctly.
diff --git a/tests/qapi-schema/sub-sub-module.json b/tests/qapi-schema/sub-sub-module.json
index 524ef9b83f..94f36ec0b1 100644
--- a/tests/qapi-schema/sub-sub-module.json
+++ b/tests/qapi-schema/sub-sub-module.json
@@ -1,4 +1,5 @@
# *-*- Mode: Python -*-*
+# vim: filetype=python
# Sub-module of sub-module include/sub-module.json of qapi-schema-test.json
diff --git a/tests/qemu-iotests/031.out b/tests/qemu-iotests/031.out
index 4b21d6a9ba..0054c2ed97 100644
--- a/tests/qemu-iotests/031.out
+++ b/tests/qemu-iotests/031.out
@@ -117,7 +117,7 @@ header_length 112
Header extension:
magic 0x6803f857 (Feature table)
-length 336
+length 384
data <binary>
Header extension:
@@ -150,7 +150,7 @@ header_length 112
Header extension:
magic 0x6803f857 (Feature table)
-length 336
+length 384
data <binary>
Header extension:
@@ -164,7 +164,7 @@ No errors were found on the image.
magic 0x514649fb
version 3
-backing_file_offset 0x210
+backing_file_offset 0x240
backing_file_size 0x17
cluster_bits 16
size 67108864
@@ -188,7 +188,7 @@ data 'host_device'
Header extension:
magic 0x6803f857 (Feature table)
-length 336
+length 384
data <binary>
Header extension:
diff --git a/tests/qemu-iotests/036.out b/tests/qemu-iotests/036.out
index a9bed828e5..1fa7cad28d 100644
--- a/tests/qemu-iotests/036.out
+++ b/tests/qemu-iotests/036.out
@@ -26,7 +26,7 @@ compatible_features []
autoclear_features [63]
Header extension:
magic 0x6803f857 (Feature table)
-length 336
+length 384
data <binary>
@@ -38,7 +38,7 @@ compatible_features []
autoclear_features []
Header extension:
magic 0x6803f857 (Feature table)
-length 336
+length 384
data <binary>
*** done
diff --git a/tests/qemu-iotests/049.out b/tests/qemu-iotests/049.out
index 4c21dc70a5..a7e220830d 100644
--- a/tests/qemu-iotests/049.out
+++ b/tests/qemu-iotests/049.out
@@ -4,90 +4,90 @@ QA output created by 049
== 1. Traditional size parameter ==
qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024b
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 TEST_DIR/t.qcow2 1k
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 TEST_DIR/t.qcow2 1K
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 TEST_DIR/t.qcow2 1M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1048576 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1048576 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 TEST_DIR/t.qcow2 1G
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1073741824 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1073741824 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 TEST_DIR/t.qcow2 1T
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1099511627776 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1099511627776 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024.0
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 TEST_DIR/t.qcow2 1024.0b
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5k
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1536 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1536 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5K
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1536 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1536 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1572864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1572864 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5G
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1610612736 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1610612736 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 TEST_DIR/t.qcow2 1.5T
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1649267441664 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1649267441664 lazy_refcounts=off refcount_bits=16
== 2. Specifying size via -o ==
qemu-img create -f qcow2 -o size=1024 TEST_DIR/t.qcow2
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o size=1024b TEST_DIR/t.qcow2
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o size=1k TEST_DIR/t.qcow2
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o size=1K TEST_DIR/t.qcow2
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o size=1M TEST_DIR/t.qcow2
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1048576 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1048576 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o size=1G TEST_DIR/t.qcow2
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1073741824 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1073741824 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o size=1T TEST_DIR/t.qcow2
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1099511627776 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1099511627776 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o size=1024.0 TEST_DIR/t.qcow2
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o size=1024.0b TEST_DIR/t.qcow2
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1024 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o size=1.5k TEST_DIR/t.qcow2
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1536 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1536 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o size=1.5K TEST_DIR/t.qcow2
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1536 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1536 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o size=1.5M TEST_DIR/t.qcow2
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1572864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1572864 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o size=1.5G TEST_DIR/t.qcow2
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1610612736 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1610612736 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o size=1.5T TEST_DIR/t.qcow2
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1649267441664 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1649267441664 lazy_refcounts=off refcount_bits=16
== 3. Invalid sizes ==
@@ -129,84 +129,84 @@ qemu-img: TEST_DIR/t.qcow2: The image size must be specified only once
== Check correct interpretation of suffixes for cluster size ==
qemu-img create -f qcow2 -o cluster_size=1024 TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1024 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1024 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o cluster_size=1024b TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1024 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1024 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o cluster_size=1k TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1024 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1024 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o cluster_size=1K TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1024 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1024 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o cluster_size=1M TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1048576 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1048576 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o cluster_size=1024.0 TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1024 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1024 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o cluster_size=1024.0b TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1024 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=1024 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o cluster_size=0.5k TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=512 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=512 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o cluster_size=0.5K TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=512 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=512 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o cluster_size=0.5M TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=524288 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=524288 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
== Check compat level option ==
qemu-img create -f qcow2 -o compat=0.10 TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=0.10 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 compat=0.10 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o compat=1.1 TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=1.1 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 compat=1.1 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o compat=0.42 TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=0.42 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 compat=0.42 lazy_refcounts=off refcount_bits=16
qemu-img: TEST_DIR/t.qcow2: Invalid parameter '0.42'
qemu-img create -f qcow2 -o compat=foobar TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=foobar lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 compat=foobar lazy_refcounts=off refcount_bits=16
qemu-img: TEST_DIR/t.qcow2: Invalid parameter 'foobar'
== Check preallocation option ==
qemu-img create -f qcow2 -o preallocation=off TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 preallocation=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off preallocation=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o preallocation=metadata TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 preallocation=metadata compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off preallocation=metadata compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o preallocation=1234 TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 preallocation=1234 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off preallocation=1234 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
qemu-img: TEST_DIR/t.qcow2: Invalid parameter '1234'
== Check encryption option ==
qemu-img create -f qcow2 -o encryption=off TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 encryption=off cluster_size=65536 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 encryption=off cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 --object secret,id=sec0,data=123456 -o encryption=on,encrypt.key-secret=sec0 TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 encryption=on encrypt.key-secret=sec0 cluster_size=65536 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 encryption=on encrypt.key-secret=sec0 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
== Check lazy_refcounts option (only with v3) ==
qemu-img create -f qcow2 -o compat=1.1,lazy_refcounts=off TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=1.1 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 compat=1.1 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o compat=1.1,lazy_refcounts=on TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=1.1 lazy_refcounts=on refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 compat=1.1 lazy_refcounts=on refcount_bits=16
qemu-img create -f qcow2 -o compat=0.10,lazy_refcounts=off TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=0.10 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 compat=0.10 lazy_refcounts=off refcount_bits=16
qemu-img create -f qcow2 -o compat=0.10,lazy_refcounts=on TEST_DIR/t.qcow2 64M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=0.10 lazy_refcounts=on refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 compat=0.10 lazy_refcounts=on refcount_bits=16
qemu-img: TEST_DIR/t.qcow2: Lazy refcounts only supported with compatibility level 1.1 and above (use version=v3 or greater)
*** done
diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out
index e574c38797..b74540bafb 100644
--- a/tests/qemu-iotests/060.out
+++ b/tests/qemu-iotests/060.out
@@ -21,6 +21,7 @@ Format specific information:
lazy refcounts: false
refcount bits: 16
corrupt: true
+ extended l2: false
qemu-io: can't open device TEST_DIR/t.IMGFMT: IMGFMT: Image is corrupt; cannot be opened read/write
no file open, try 'help open'
read 512/512 bytes at offset 0
@@ -320,7 +321,7 @@ discard 65536/65536 bytes at offset 0
qcow2: Marking image as corrupt: Preallocated zero cluster offset 0x2a00 unaligned (guest offset: 0); further corruption events will be suppressed
write failed: Input/output error
--- Repairing ---
-Repairing offset=2a00: Preallocated zero cluster is not properly aligned; L2 entry corrupted.
+Repairing offset=2a00: Preallocated cluster is not properly aligned; L2 entry corrupted.
The following inconsistencies were found and repaired:
0 leaked clusters
diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061
index 08ddbdd10c..5747beb7ed 100755
--- a/tests/qemu-iotests/061
+++ b/tests/qemu-iotests/061
@@ -304,6 +304,12 @@ _img_info --format-specific
_check_test_img
echo
+echo "=== Testing version downgrade with extended L2 entries ==="
+echo
+_make_test_img -o "compat=1.1,extended_l2=on" 64M
+$QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
+
+echo
echo "=== Try changing the external data file ==="
echo
_make_test_img -o "compat=1.1" 64M
diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out
index b2d2dfed04..ee30da2665 100644
--- a/tests/qemu-iotests/061.out
+++ b/tests/qemu-iotests/061.out
@@ -26,7 +26,7 @@ header_length 112
Header extension:
magic 0x6803f857 (Feature table)
-length 336
+length 384
data <binary>
magic 0x514649fb
@@ -84,7 +84,7 @@ header_length 112
Header extension:
magic 0x6803f857 (Feature table)
-length 336
+length 384
data <binary>
magic 0x514649fb
@@ -140,7 +140,7 @@ header_length 112
Header extension:
magic 0x6803f857 (Feature table)
-length 336
+length 384
data <binary>
ERROR cluster 5 refcount=0 reference=1
@@ -195,7 +195,7 @@ header_length 112
Header extension:
magic 0x6803f857 (Feature table)
-length 336
+length 384
data <binary>
magic 0x514649fb
@@ -264,7 +264,7 @@ header_length 112
Header extension:
magic 0x6803f857 (Feature table)
-length 336
+length 384
data <binary>
read 65536/65536 bytes at offset 44040192
@@ -326,7 +326,7 @@ header_length 112
Header extension:
magic 0x6803f857 (Feature table)
-length 336
+length 384
data <binary>
ERROR cluster 5 refcount=0 reference=1
@@ -355,7 +355,7 @@ header_length 112
Header extension:
magic 0x6803f857 (Feature table)
-length 336
+length 384
data <binary>
read 131072/131072 bytes at offset 0
@@ -530,8 +530,14 @@ Format specific information:
data file: TEST_DIR/t.IMGFMT.data
data file raw: false
corrupt: false
+ extended l2: false
No errors were found on the image.
+=== Testing version downgrade with extended L2 entries ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
+qemu-img: Cannot downgrade an image with incompatible features 0x10 set
+
=== Try changing the external data file ===
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
@@ -551,6 +557,7 @@ Format specific information:
data file: foo
data file raw: false
corrupt: false
+ extended l2: false
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'data-file' is required for this image
image: TEST_DIR/t.IMGFMT
@@ -564,6 +571,7 @@ Format specific information:
refcount bits: 16
data file raw: false
corrupt: false
+ extended l2: false
=== Clearing and setting data-file-raw ===
@@ -580,6 +588,7 @@ Format specific information:
data file: TEST_DIR/t.IMGFMT.data
data file raw: true
corrupt: false
+ extended l2: false
No errors were found on the image.
image: TEST_DIR/t.IMGFMT
file format: IMGFMT
@@ -593,6 +602,7 @@ Format specific information:
data file: TEST_DIR/t.IMGFMT.data
data file raw: false
corrupt: false
+ extended l2: false
No errors were found on the image.
qemu-img: data-file-raw cannot be set on existing images
image: TEST_DIR/t.IMGFMT
@@ -607,5 +617,6 @@ Format specific information:
data file: TEST_DIR/t.IMGFMT.data
data file raw: false
corrupt: false
+ extended l2: false
No errors were found on the image.
*** done
diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065
index 18dc488c7a..29a7f7ad60 100755
--- a/tests/qemu-iotests/065
+++ b/tests/qemu-iotests/065
@@ -98,20 +98,20 @@ class TestQCow3NotLazy(TestQemuImgInfo):
img_options = 'compat=1.1,lazy_refcounts=off'
json_compare = { 'compat': '1.1', 'lazy-refcounts': False,
'refcount-bits': 16, 'corrupt': False,
- 'compression-type': 'zlib' }
+ 'compression-type': 'zlib', 'extended-l2': False }
human_compare = [ 'compat: 1.1', 'compression type: zlib',
'lazy refcounts: false', 'refcount bits: 16',
- 'corrupt: false' ]
+ 'corrupt: false', 'extended l2: false' ]
class TestQCow3Lazy(TestQemuImgInfo):
'''Testing a qcow2 version 3 image with lazy refcounts enabled'''
img_options = 'compat=1.1,lazy_refcounts=on'
json_compare = { 'compat': '1.1', 'lazy-refcounts': True,
'refcount-bits': 16, 'corrupt': False,
- 'compression-type': 'zlib' }
+ 'compression-type': 'zlib', 'extended-l2': False }
human_compare = [ 'compat: 1.1', 'compression type: zlib',
'lazy refcounts: true', 'refcount bits: 16',
- 'corrupt: false' ]
+ 'corrupt: false', 'extended l2: false' ]
class TestQCow3NotLazyQMP(TestQMP):
'''Testing a qcow2 version 3 image with lazy refcounts disabled, opening
@@ -120,7 +120,7 @@ class TestQCow3NotLazyQMP(TestQMP):
qemu_options = 'lazy-refcounts=on'
compare = { 'compat': '1.1', 'lazy-refcounts': False,
'refcount-bits': 16, 'corrupt': False,
- 'compression-type': 'zlib' }
+ 'compression-type': 'zlib', 'extended-l2': False }
class TestQCow3LazyQMP(TestQMP):
@@ -130,7 +130,7 @@ class TestQCow3LazyQMP(TestQMP):
qemu_options = 'lazy-refcounts=off'
compare = { 'compat': '1.1', 'lazy-refcounts': True,
'refcount-bits': 16, 'corrupt': False,
- 'compression-type': 'zlib' }
+ 'compression-type': 'zlib', 'extended-l2': False }
TestImageInfoSpecific = None
TestQemuImgInfo = None
diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out
index 1728aff1e0..b70c12c139 100644
--- a/tests/qemu-iotests/082.out
+++ b/tests/qemu-iotests/082.out
@@ -3,14 +3,14 @@ QA output created by 082
=== create: Options specified more than once ===
Testing: create -f foo -f qcow2 TEST_DIR/t.qcow2 128M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16
image: TEST_DIR/t.IMGFMT
file format: IMGFMT
virtual size: 128 MiB (134217728 bytes)
cluster_size: 65536
Testing: create -f qcow2 -o cluster_size=4k -o lazy_refcounts=on TEST_DIR/t.qcow2 128M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=4096 compression_type=zlib size=134217728 lazy_refcounts=on refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=4096 extended_l2=off compression_type=zlib size=134217728 lazy_refcounts=on refcount_bits=16
image: TEST_DIR/t.IMGFMT
file format: IMGFMT
virtual size: 128 MiB (134217728 bytes)
@@ -21,9 +21,10 @@ Format specific information:
lazy refcounts: true
refcount bits: 16
corrupt: false
+ extended l2: false
Testing: create -f qcow2 -o cluster_size=4k -o lazy_refcounts=on -o cluster_size=8k TEST_DIR/t.qcow2 128M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=8192 compression_type=zlib size=134217728 lazy_refcounts=on refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=8192 extended_l2=off compression_type=zlib size=134217728 lazy_refcounts=on refcount_bits=16
image: TEST_DIR/t.IMGFMT
file format: IMGFMT
virtual size: 128 MiB (134217728 bytes)
@@ -34,9 +35,10 @@ Format specific information:
lazy refcounts: true
refcount bits: 16
corrupt: false
+ extended l2: false
Testing: create -f qcow2 -o cluster_size=4k,cluster_size=8k TEST_DIR/t.qcow2 128M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=8192 compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=8192 extended_l2=off compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16
image: TEST_DIR/t.IMGFMT
file format: IMGFMT
virtual size: 128 MiB (134217728 bytes)
@@ -62,6 +64,7 @@ Supported options:
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
+ extended_l2=<bool (on/off)> - Extended L2 tables
extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
@@ -87,6 +90,7 @@ Supported options:
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
+ extended_l2=<bool (on/off)> - Extended L2 tables
extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
@@ -112,6 +116,7 @@ Supported options:
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
+ extended_l2=<bool (on/off)> - Extended L2 tables
extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
@@ -137,6 +142,7 @@ Supported options:
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
+ extended_l2=<bool (on/off)> - Extended L2 tables
extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
@@ -162,6 +168,7 @@ Supported options:
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
+ extended_l2=<bool (on/off)> - Extended L2 tables
extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
@@ -187,6 +194,7 @@ Supported options:
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
+ extended_l2=<bool (on/off)> - Extended L2 tables
extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
@@ -212,6 +220,7 @@ Supported options:
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
+ extended_l2=<bool (on/off)> - Extended L2 tables
extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
@@ -237,6 +246,7 @@ Supported options:
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
+ extended_l2=<bool (on/off)> - Extended L2 tables
extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
@@ -245,10 +255,10 @@ Supported options:
size=<size> - Virtual disk size
Testing: create -f qcow2 -u -o backing_file=TEST_DIR/t.qcow2,,help -F qcow2 TEST_DIR/t.qcow2 128M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/t.qcow2,,help backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/t.qcow2,,help backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
Testing: create -f qcow2 -u -o backing_file=TEST_DIR/t.qcow2,,? -F qcow2 TEST_DIR/t.qcow2 128M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/t.qcow2,,? backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/t.qcow2,,? backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
Testing: create -f qcow2 -o backing_file=TEST_DIR/t.qcow2, -o help TEST_DIR/t.qcow2 128M
qemu-img: Invalid option list: backing_file=TEST_DIR/t.qcow2,
@@ -277,6 +287,7 @@ Supported qcow2 options:
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
+ extended_l2=<bool (on/off)> - Extended L2 tables
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
refcount_bits=<num> - Width of a reference count entry in bits
@@ -298,7 +309,7 @@ qemu-img: Format driver 'bochs' does not support image creation
=== convert: Options specified more than once ===
Testing: create -f qcow2 TEST_DIR/t.qcow2 128M
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16
Testing: convert -f foo -f qcow2 TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
image: TEST_DIR/t.IMGFMT.base
@@ -322,6 +333,7 @@ Format specific information:
lazy refcounts: true
refcount bits: 16
corrupt: false
+ extended l2: false
Testing: convert -O qcow2 -o cluster_size=4k -o lazy_refcounts=on -o cluster_size=8k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
image: TEST_DIR/t.IMGFMT.base
@@ -334,6 +346,7 @@ Format specific information:
lazy refcounts: true
refcount bits: 16
corrupt: false
+ extended l2: false
Testing: convert -O qcow2 -o cluster_size=4k,cluster_size=8k TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.base
image: TEST_DIR/t.IMGFMT.base
@@ -361,6 +374,7 @@ Supported options:
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
+ extended_l2=<bool (on/off)> - Extended L2 tables
extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
@@ -386,6 +400,7 @@ Supported options:
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
+ extended_l2=<bool (on/off)> - Extended L2 tables
extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
@@ -411,6 +426,7 @@ Supported options:
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
+ extended_l2=<bool (on/off)> - Extended L2 tables
extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
@@ -436,6 +452,7 @@ Supported options:
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
+ extended_l2=<bool (on/off)> - Extended L2 tables
extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
@@ -461,6 +478,7 @@ Supported options:
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
+ extended_l2=<bool (on/off)> - Extended L2 tables
extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
@@ -486,6 +504,7 @@ Supported options:
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
+ extended_l2=<bool (on/off)> - Extended L2 tables
extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
@@ -511,6 +530,7 @@ Supported options:
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
+ extended_l2=<bool (on/off)> - Extended L2 tables
extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
@@ -536,6 +556,7 @@ Supported options:
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
+ extended_l2=<bool (on/off)> - Extended L2 tables
extent_size_hint=<size> - Extent size hint for the image file, 0 to disable
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
nocow=<bool (on/off)> - Turn off copy-on-write (valid only on btrfs)
@@ -576,6 +597,7 @@ Supported qcow2 options:
encrypt.ivgen-hash-alg=<str> - Name of IV generator hash algorithm
encrypt.key-secret=<str> - ID of secret providing qcow AES key or LUKS passphrase
encryption=<bool (on/off)> - Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
+ extended_l2=<bool (on/off)> - Extended L2 tables
lazy_refcounts=<bool (on/off)> - Postpone refcount updates
preallocation=<str> - Preallocation mode (allowed values: off, metadata, falloc, full)
refcount_bits=<num> - Width of a reference count entry in bits
@@ -621,6 +643,7 @@ Format specific information:
lazy refcounts: true
refcount bits: 16
corrupt: false
+ extended l2: false
Testing: amend -f qcow2 -o size=130M -o lazy_refcounts=off TEST_DIR/t.qcow2
image: TEST_DIR/t.IMGFMT
@@ -633,6 +656,7 @@ Format specific information:
lazy refcounts: false
refcount bits: 16
corrupt: false
+ extended l2: false
Testing: amend -f qcow2 -o size=8M -o lazy_refcounts=on -o size=132M TEST_DIR/t.qcow2
image: TEST_DIR/t.IMGFMT
@@ -645,6 +669,7 @@ Format specific information:
lazy refcounts: true
refcount bits: 16
corrupt: false
+ extended l2: false
Testing: amend -f qcow2 -o size=4M,size=148M TEST_DIR/t.qcow2
image: TEST_DIR/t.IMGFMT
diff --git a/tests/qemu-iotests/085.out b/tests/qemu-iotests/085.out
index 700658d5a3..7fc44b1c61 100644
--- a/tests/qemu-iotests/085.out
+++ b/tests/qemu-iotests/085.out
@@ -13,7 +13,7 @@ Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=134217728
=== Create a single snapshot on virtio0 ===
{ 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'virtio0', 'snapshot-file':'TEST_DIR/1-snapshot-v0.IMGFMT', 'format': 'IMGFMT' } }
-Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/t.qcow2.1 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/t.qcow2.1 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
{"return": {}}
=== Invalid command - missing device and nodename ===
@@ -30,40 +30,40 @@ Formatting 'TEST_DIR/1-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compress
=== Create several transactional group snapshots ===
{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/2-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/2-snapshot-v1.IMGFMT' } } ] } }
-Formatting 'TEST_DIR/2-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/1-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/2-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/t.qcow2.2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/2-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/1-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/2-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/t.qcow2.2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
{"return": {}}
{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/3-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/3-snapshot-v1.IMGFMT' } } ] } }
-Formatting 'TEST_DIR/3-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/2-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/3-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/2-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/3-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/2-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/3-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/2-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
{"return": {}}
{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/4-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/4-snapshot-v1.IMGFMT' } } ] } }
-Formatting 'TEST_DIR/4-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/3-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/4-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/3-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/4-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/3-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/4-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/3-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
{"return": {}}
{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/5-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/5-snapshot-v1.IMGFMT' } } ] } }
-Formatting 'TEST_DIR/5-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/4-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/5-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/4-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/5-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/4-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/5-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/4-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
{"return": {}}
{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/6-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/6-snapshot-v1.IMGFMT' } } ] } }
-Formatting 'TEST_DIR/6-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/5-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/6-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/5-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/6-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/5-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/6-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/5-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
{"return": {}}
{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/7-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/7-snapshot-v1.IMGFMT' } } ] } }
-Formatting 'TEST_DIR/7-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/6-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/7-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/6-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/7-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/6-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/7-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/6-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
{"return": {}}
{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/8-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/8-snapshot-v1.IMGFMT' } } ] } }
-Formatting 'TEST_DIR/8-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/7-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/8-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/7-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/8-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/7-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/8-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/7-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
{"return": {}}
{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/9-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/9-snapshot-v1.IMGFMT' } } ] } }
-Formatting 'TEST_DIR/9-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/8-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/9-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/8-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/9-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/8-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/9-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/8-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
{"return": {}}
{ 'execute': 'transaction', 'arguments': {'actions': [ { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio0', 'snapshot-file': 'TEST_DIR/10-snapshot-v0.IMGFMT' } }, { 'type': 'blockdev-snapshot-sync', 'data' : { 'device': 'virtio1', 'snapshot-file': 'TEST_DIR/10-snapshot-v1.IMGFMT' } } ] } }
-Formatting 'TEST_DIR/10-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/9-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 backing_file=TEST_DIR/9-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/10-snapshot-v0.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/9-snapshot-v0.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/10-snapshot-v1.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 backing_file=TEST_DIR/9-snapshot-v1.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
{"return": {}}
=== Create a couple of snapshots using blockdev-snapshot ===
diff --git a/tests/qemu-iotests/144.out b/tests/qemu-iotests/144.out
index a2172a1308..13e0c4f5a7 100644
--- a/tests/qemu-iotests/144.out
+++ b/tests/qemu-iotests/144.out
@@ -9,7 +9,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=536870912
{ 'execute': 'qmp_capabilities' }
{"return": {}}
{ 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'virtio0', 'snapshot-file':'TEST_DIR/tmp.IMGFMT', 'format': 'IMGFMT' } }
-Formatting 'TEST_DIR/tmp.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=536870912 backing_file=TEST_DIR/t.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/tmp.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=536870912 backing_file=TEST_DIR/t.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
{"return": {}}
=== Performing block-commit on active layer ===
@@ -31,6 +31,6 @@ Formatting 'TEST_DIR/tmp.qcow2', fmt=qcow2 cluster_size=65536 compression_type=z
=== Performing Live Snapshot 2 ===
{ 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'virtio0', 'snapshot-file':'TEST_DIR/tmp2.IMGFMT', 'format': 'IMGFMT' } }
-Formatting 'TEST_DIR/tmp2.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=536870912 backing_file=TEST_DIR/t.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/tmp2.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=536870912 backing_file=TEST_DIR/t.qcow2 backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
{"return": {}}
*** done
diff --git a/tests/qemu-iotests/169 b/tests/qemu-iotests/169
index 2c5a132aa3..40afb15299 100755
--- a/tests/qemu-iotests/169
+++ b/tests/qemu-iotests/169
@@ -24,11 +24,12 @@ import time
import itertools
import operator
import re
-from iotests import qemu_img
+from iotests import qemu_img, qemu_img_create, Timeout
disk_a = os.path.join(iotests.test_dir, 'disk_a')
disk_b = os.path.join(iotests.test_dir, 'disk_b')
+base_a = os.path.join(iotests.test_dir, 'base_a')
size = '1M'
mig_file = os.path.join(iotests.test_dir, 'mig_file')
mig_cmd = 'exec: cat > ' + mig_file
@@ -234,6 +235,67 @@ for cmb in list(itertools.product((True, False), repeat=2)):
inject_test_case(TestDirtyBitmapMigration, name,
'do_test_migration_resume_source', *list(cmb))
+
+class TestDirtyBitmapBackingMigration(iotests.QMPTestCase):
+ def setUp(self):
+ qemu_img_create('-f', iotests.imgfmt, base_a, size)
+ qemu_img_create('-f', iotests.imgfmt, '-F', iotests.imgfmt,
+ '-b', base_a, disk_a, size)
+
+ for f in (disk_a, base_a):
+ qemu_img('bitmap', '--add', f, 'bmap0')
+
+ blockdev = {
+ 'node-name': 'node0',
+ 'driver': iotests.imgfmt,
+ 'file': {
+ 'driver': 'file',
+ 'filename': disk_a
+ },
+ 'backing': {
+ 'node-name': 'node0-base',
+ 'driver': iotests.imgfmt,
+ 'file': {
+ 'driver': 'file',
+ 'filename': base_a
+ }
+ }
+ }
+
+ self.vm = iotests.VM()
+ self.vm.launch()
+
+ result = self.vm.qmp('blockdev-add', **blockdev)
+ self.assert_qmp(result, 'return', {})
+
+ # Check that the bitmaps are there
+ for node in self.vm.qmp('query-named-block-nodes', flat=True)['return']:
+ if 'node0' in node['node-name']:
+ self.assert_qmp(node, 'dirty-bitmaps[0]/name', 'bmap0')
+
+ caps = [{'capability': 'events', 'state': True}]
+ result = self.vm.qmp('migrate-set-capabilities', capabilities=caps)
+ self.assert_qmp(result, 'return', {})
+
+ def tearDown(self):
+ self.vm.shutdown()
+ for f in (disk_a, base_a):
+ os.remove(f)
+
+ def test_cont_on_source(self):
+ """
+ Continue the source after migration.
+ """
+ result = self.vm.qmp('migrate', uri=f'exec: cat > /dev/null')
+ self.assert_qmp(result, 'return', {})
+
+ with Timeout(10, 'Migration timeout'):
+ self.vm.wait_migration('postmigrate')
+
+ result = self.vm.qmp('cont')
+ self.assert_qmp(result, 'return', {})
+
+
if __name__ == '__main__':
iotests.main(supported_fmts=['qcow2'],
supported_protocols=['file'])
diff --git a/tests/qemu-iotests/169.out b/tests/qemu-iotests/169.out
index 5c26d15c0d..cafb8161f7 100644
--- a/tests/qemu-iotests/169.out
+++ b/tests/qemu-iotests/169.out
@@ -1,5 +1,5 @@
-....................................
+.....................................
----------------------------------------------------------------------
-Ran 36 tests
+Ran 37 tests
OK
diff --git a/tests/qemu-iotests/182.out b/tests/qemu-iotests/182.out
index 29e9db3497..ce23340670 100644
--- a/tests/qemu-iotests/182.out
+++ b/tests/qemu-iotests/182.out
@@ -13,7 +13,7 @@ Is another process using the image [TEST_DIR/t.qcow2]?
{'execute': 'blockdev-add', 'arguments': { 'node-name': 'node0', 'driver': 'file', 'filename': 'TEST_DIR/t.IMGFMT', 'locking': 'on' } }
{"return": {}}
{'execute': 'blockdev-snapshot-sync', 'arguments': { 'node-name': 'node0', 'snapshot-file': 'TEST_DIR/t.IMGFMT.overlay', 'snapshot-node-name': 'node1' } }
-Formatting 'TEST_DIR/t.qcow2.overlay', fmt=qcow2 cluster_size=65536 compression_type=zlib size=197120 backing_file=TEST_DIR/t.qcow2 backing_fmt=file lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2.overlay', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=197120 backing_file=TEST_DIR/t.qcow2 backing_fmt=file lazy_refcounts=off refcount_bits=16
{"return": {}}
{'execute': 'blockdev-add', 'arguments': { 'node-name': 'node1', 'driver': 'file', 'filename': 'TEST_DIR/t.IMGFMT', 'locking': 'on' } }
{"return": {}}
diff --git a/tests/qemu-iotests/185.out b/tests/qemu-iotests/185.out
index 62d1ab74d3..339438ac68 100644
--- a/tests/qemu-iotests/185.out
+++ b/tests/qemu-iotests/185.out
@@ -9,14 +9,14 @@ Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=67108864
=== Creating backing chain ===
{ 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'disk', 'snapshot-file': 'TEST_DIR/t.IMGFMT.mid', 'format': 'IMGFMT', 'mode': 'absolute-paths' } }
-Formatting 'TEST_DIR/t.qcow2.mid', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 backing_file=TEST_DIR/t.qcow2.base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2.mid', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 backing_file=TEST_DIR/t.qcow2.base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
{"return": {}}
{ 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'qemu-io disk "write 0 4M"' } }
wrote 4194304/4194304 bytes at offset 0
4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
{"return": ""}
{ 'execute': 'blockdev-snapshot-sync', 'arguments': { 'device': 'disk', 'snapshot-file': 'TEST_DIR/t.IMGFMT', 'format': 'IMGFMT', 'mode': 'absolute-paths' } }
-Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 backing_file=TEST_DIR/t.qcow2.mid backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 backing_file=TEST_DIR/t.qcow2.mid backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
{"return": {}}
=== Start commit job and exit qemu ===
@@ -48,7 +48,7 @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zli
{ 'execute': 'qmp_capabilities' }
{"return": {}}
{ 'execute': 'drive-mirror', 'arguments': { 'device': 'disk', 'target': 'TEST_DIR/t.IMGFMT.copy', 'format': 'IMGFMT', 'sync': 'full', 'speed': 65536 } }
-Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}}
{"return": {}}
@@ -62,7 +62,7 @@ Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 cluster_size=65536 compression_typ
{ 'execute': 'qmp_capabilities' }
{"return": {}}
{ 'execute': 'drive-backup', 'arguments': { 'device': 'disk', 'target': 'TEST_DIR/t.IMGFMT.copy', 'format': 'IMGFMT', 'sync': 'full', 'speed': 65536 } }
-Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "disk"}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "disk"}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "JOB_STATUS_CHANGE", "data": {"status": "paused", "id": "disk"}}
diff --git a/tests/qemu-iotests/198 b/tests/qemu-iotests/198
index 1b9bfb827b..46f0c54537 100755
--- a/tests/qemu-iotests/198
+++ b/tests/qemu-iotests/198
@@ -94,6 +94,7 @@ echo "== checking image base =="
$QEMU_IMG info --image-opts $IMGSPECBASE | _filter_img_info --format-specific \
| sed -e "/^disk size:/ D" -e '/refcount bits:/ D' -e '/compat:/ D' \
-e '/lazy refcounts:/ D' -e '/corrupt:/ D' -e '/^\s*data file/ D' \
+ -e '/extended l2:/ D' \
| _filter_json_filename
echo
@@ -101,6 +102,7 @@ echo "== checking image layer =="
$QEMU_IMG info --image-opts $IMGSPECLAYER | _filter_img_info --format-specific \
| sed -e "/^disk size:/ D" -e '/refcount bits:/ D' -e '/compat:/ D' \
-e '/lazy refcounts:/ D' -e '/corrupt:/ D' -e '/^\s*data file/ D' \
+ -e '/extended l2:/ D' \
| _filter_json_filename
diff --git a/tests/qemu-iotests/206.out b/tests/qemu-iotests/206.out
index 1a14255a83..a100849fcb 100644
--- a/tests/qemu-iotests/206.out
+++ b/tests/qemu-iotests/206.out
@@ -22,6 +22,7 @@ Format specific information:
lazy refcounts: false
refcount bits: 16
corrupt: false
+ extended l2: false
=== Successful image creation (inline blockdev-add, explicit defaults) ===
@@ -45,6 +46,7 @@ Format specific information:
lazy refcounts: false
refcount bits: 16
corrupt: false
+ extended l2: false
=== Successful image creation (v3 non-default options) ===
@@ -68,6 +70,7 @@ Format specific information:
lazy refcounts: true
refcount bits: 1
corrupt: false
+ extended l2: false
=== Successful image creation (v2 non-default options) ===
@@ -146,6 +149,7 @@ Format specific information:
payload offset: 528384
master key iters: XXX
corrupt: false
+ extended l2: false
=== Invalid BlockdevRef ===
@@ -199,7 +203,7 @@ Job failed: Different refcount widths than 16 bits require compatibility level 1
=== Invalid backing file options ===
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"backing-file": "/dev/null", "driver": "qcow2", "file": "node0", "preallocation": "full", "size": 67108864}}}
{"return": {}}
-Job failed: Backing file and preallocation cannot be used at the same time
+Job failed: Backing file and preallocation can only be used at the same time if extended_l2 is on
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
{"return": {}}
diff --git a/tests/qemu-iotests/242.out b/tests/qemu-iotests/242.out
index 091b9126ce..3759c99284 100644
--- a/tests/qemu-iotests/242.out
+++ b/tests/qemu-iotests/242.out
@@ -16,6 +16,7 @@ Format specific information:
lazy refcounts: false
refcount bits: 16
corrupt: false
+ extended l2: false
No bitmap in JSON format output
@@ -42,6 +43,7 @@ Format specific information:
granularity: 32768
refcount bits: 16
corrupt: false
+ extended l2: false
The same bitmaps in JSON format:
[
@@ -80,6 +82,7 @@ Format specific information:
granularity: 65536
refcount bits: 16
corrupt: false
+ extended l2: false
The same bitmaps in JSON format:
[
@@ -123,6 +126,7 @@ Format specific information:
granularity: 65536
refcount bits: 16
corrupt: false
+ extended l2: false
The same bitmaps in JSON format:
[
@@ -167,5 +171,6 @@ Format specific information:
granularity: 16384
refcount bits: 16
corrupt: false
+ extended l2: false
Test complete
diff --git a/tests/qemu-iotests/255.out b/tests/qemu-iotests/255.out
index d74903db99..33b7f22de3 100644
--- a/tests/qemu-iotests/255.out
+++ b/tests/qemu-iotests/255.out
@@ -3,9 +3,9 @@ Finishing a commit job with background reads
=== Create backing chain and start VM ===
-Formatting 'TEST_DIR/PID-t.qcow2.mid', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-t.qcow2.mid', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/PID-t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-t.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16
=== Start background read requests ===
@@ -23,9 +23,9 @@ Closing the VM while a job is being cancelled
=== Create images and start VM ===
-Formatting 'TEST_DIR/PID-src.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-src.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/PID-dst.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-dst.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=134217728 lazy_refcounts=off refcount_bits=16
wrote 1048576/1048576 bytes at offset 0
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
diff --git a/tests/qemu-iotests/264 b/tests/qemu-iotests/264
index 304a7443d7..666f164ed8 100755
--- a/tests/qemu-iotests/264
+++ b/tests/qemu-iotests/264
@@ -36,48 +36,32 @@ wait_step = 0.2
qemu_img_create('-f', iotests.imgfmt, disk_a, str(size))
qemu_img_create('-f', iotests.imgfmt, disk_b, str(size))
-srv = qemu_nbd_popen('-k', nbd_sock, '-f', iotests.imgfmt, disk_b)
-# Wait for NBD server availability
-t = 0
-ok = False
-while t < wait_limit:
- ok = qemu_io_silent_check('-f', 'raw', '-c', 'read 0 512', nbd_uri)
- if ok:
- break
- time.sleep(wait_step)
- t += wait_step
+with qemu_nbd_popen('-k', nbd_sock, '-f', iotests.imgfmt, disk_b):
+ vm = iotests.VM().add_drive(disk_a)
+ vm.launch()
+ vm.hmp_qemu_io('drive0', 'write 0 {}'.format(size))
+
+ vm.qmp_log('blockdev-add', filters=[iotests.filter_qmp_testfiles],
+ **{'node_name': 'backup0',
+ 'driver': 'raw',
+ 'file': {'driver': 'nbd',
+ 'server': {'type': 'unix', 'path': nbd_sock},
+ 'reconnect-delay': 10}})
+ vm.qmp_log('blockdev-backup', device='drive0', sync='full', target='backup0',
+ speed=(1 * 1024 * 1024))
+
+ # Wait for some progress
+ t = 0
+ while t < wait_limit:
+ jobs = vm.qmp('query-block-jobs')['return']
+ if jobs and jobs[0]['offset'] > 0:
+ break
+ time.sleep(wait_step)
+ t += wait_step
-assert ok
-
-vm = iotests.VM().add_drive(disk_a)
-vm.launch()
-vm.hmp_qemu_io('drive0', 'write 0 {}'.format(size))
-
-vm.qmp_log('blockdev-add', filters=[iotests.filter_qmp_testfiles],
- **{'node_name': 'backup0',
- 'driver': 'raw',
- 'file': {'driver': 'nbd',
- 'server': {'type': 'unix', 'path': nbd_sock},
- 'reconnect-delay': 10}})
-vm.qmp_log('blockdev-backup', device='drive0', sync='full', target='backup0',
- speed=(1 * 1024 * 1024))
-
-# Wait for some progress
-t = 0
-while t < wait_limit:
- jobs = vm.qmp('query-block-jobs')['return']
if jobs and jobs[0]['offset'] > 0:
- break
- time.sleep(wait_step)
- t += wait_step
-
-if jobs and jobs[0]['offset'] > 0:
- log('Backup job is started')
-
-log('Kill NBD server')
-srv.kill()
-srv.wait()
+ log('Backup job is started')
jobs = vm.qmp('query-block-jobs')['return']
if jobs and jobs[0]['offset'] < jobs[0]['len']:
@@ -88,12 +72,8 @@ vm.qmp_log('block-job-set-speed', device='drive0', speed=0)
# Emulate server down time for 1 second
time.sleep(1)
-log('Start NBD server')
-srv = qemu_nbd_popen('-k', nbd_sock, '-f', iotests.imgfmt, disk_b)
-
-e = vm.event_wait('BLOCK_JOB_COMPLETED')
-log('Backup completed: {}'.format(e['data']['offset']))
-
-vm.qmp_log('blockdev-del', node_name='backup0')
-srv.kill()
-vm.shutdown()
+with qemu_nbd_popen('-k', nbd_sock, '-f', iotests.imgfmt, disk_b):
+ e = vm.event_wait('BLOCK_JOB_COMPLETED')
+ log('Backup completed: {}'.format(e['data']['offset']))
+ vm.qmp_log('blockdev-del', node_name='backup0')
+ vm.shutdown()
diff --git a/tests/qemu-iotests/264.out b/tests/qemu-iotests/264.out
index 3000944b09..c45b1e81ef 100644
--- a/tests/qemu-iotests/264.out
+++ b/tests/qemu-iotests/264.out
@@ -1,3 +1,4 @@
+Start NBD server
{"execute": "blockdev-add", "arguments": {"driver": "raw", "file": {"driver": "nbd", "reconnect-delay": 10, "server": {"path": "TEST_DIR/PID-nbd-sock", "type": "unix"}}, "node-name": "backup0"}}
{"return": {}}
{"execute": "blockdev-backup", "arguments": {"device": "drive0", "speed": 1048576, "sync": "full", "target": "backup0"}}
@@ -11,3 +12,4 @@ Start NBD server
Backup completed: 5242880
{"execute": "blockdev-del", "arguments": {"node-name": "backup0"}}
{"return": {}}
+Kill NBD server
diff --git a/tests/qemu-iotests/271 b/tests/qemu-iotests/271
new file mode 100755
index 0000000000..e242b28b58
--- /dev/null
+++ b/tests/qemu-iotests/271
@@ -0,0 +1,901 @@
+#!/usr/bin/env bash
+#
+# Test qcow2 images with extended L2 entries
+#
+# Copyright (C) 2019-2020 Igalia, S.L.
+# Author: Alberto Garcia <berto@igalia.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+# creator
+owner=berto@igalia.com
+
+seq="$(basename $0)"
+echo "QA output created by $seq"
+
+here="$PWD"
+status=1 # failure is the default!
+
+_cleanup()
+{
+ _cleanup_test_img
+ rm -f "$TEST_IMG.raw"
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# get standard environment, filters and checks
+. ./common.rc
+. ./common.filter
+
+_supported_fmt qcow2
+_supported_proto file nfs
+_supported_os Linux
+_unsupported_imgopts extended_l2 compat=0.10 cluster_size data_file refcount_bits=1[^0-9]
+
+l2_offset=$((0x40000))
+
+_verify_img()
+{
+ $QEMU_IMG compare "$TEST_IMG" "$TEST_IMG.raw" | grep -v 'Images are identical'
+ $QEMU_IMG check "$TEST_IMG" | _filter_qemu_img_check | \
+ grep -v 'No errors were found on the image'
+}
+
+# Compare the bitmap of an extended L2 entry against an expected value
+_verify_l2_bitmap()
+{
+ entry_no="$1" # L2 entry number, starting from 0
+ expected_alloc="$alloc" # Space-separated list of allocated subcluster indexes
+ expected_zero="$zero" # Space-separated list of zero subcluster indexes
+
+ offset=$(($l2_offset + $entry_no * 16))
+ entry=$(peek_file_be "$TEST_IMG" $offset 8)
+ offset=$(($offset + 8))
+ bitmap=$(peek_file_be "$TEST_IMG" $offset 8)
+
+ expected_bitmap=0
+ for bit in $expected_alloc; do
+ expected_bitmap=$(($expected_bitmap | (1 << $bit)))
+ done
+ for bit in $expected_zero; do
+ expected_bitmap=$(($expected_bitmap | (1 << (32 + $bit))))
+ done
+ printf -v expected_bitmap "%u" $expected_bitmap # Convert to unsigned
+
+ printf "L2 entry #%d: 0x%016x %016x\n" "$entry_no" "$entry" "$bitmap"
+ if [ "$bitmap" != "$expected_bitmap" ]; then
+ printf "ERROR: expecting bitmap 0x%016x\n" "$expected_bitmap"
+ fi
+}
+
+# This should be called as _run_test c=XXX sc=XXX off=XXX len=XXX cmd=XXX
+# c: cluster number (0 if unset)
+# sc: subcluster number inside cluster @c (0 if unset)
+# off: offset inside subcluster @sc, in kilobytes (0 if unset)
+# len: request length, passed directly to qemu-io (e.g: 256, 4k, 1M, ...)
+# cmd: the command to pass to qemu-io, must be one of
+# write -> write
+# zero -> write -z
+# unmap -> write -z -u
+# compress -> write -c
+# discard -> discard
+_run_test()
+{
+ unset c sc off len cmd
+ for var in "$@"; do eval "$var"; done
+ case "${cmd:-write}" in
+ zero)
+ cmd="write -q -z";;
+ unmap)
+ cmd="write -q -z -u";;
+ compress)
+ pat=$((${pat:-0} + 1))
+ cmd="write -q -c -P ${pat}";;
+ write)
+ pat=$((${pat:-0} + 1))
+ cmd="write -q -P ${pat}";;
+ discard)
+ cmd="discard -q";;
+ *)
+ echo "Unknown option $cmd"
+ exit 1;;
+ esac
+ c="${c:-0}"
+ sc="${sc:-0}"
+ off="${off:-0}"
+ offset="$(($c * 64 + $sc * 2 + $off))"
+ [ "$offset" != 0 ] && offset="${offset}k"
+ cmd="$cmd ${offset} ${len}"
+ raw_cmd=$(echo $cmd | sed s/-c//) # Raw images don't support -c
+ echo $cmd | sed 's/-P [0-9][0-9]\?/-P PATTERN/'
+ $QEMU_IO -c "$cmd" "$TEST_IMG" | _filter_qemu_io
+ $QEMU_IO -c "$raw_cmd" -f raw "$TEST_IMG.raw" | _filter_qemu_io
+ _verify_img
+ _verify_l2_bitmap "$c"
+}
+
+_reset_img()
+{
+ size="$1"
+ $QEMU_IMG create -f raw "$TEST_IMG.raw" "$size" | _filter_img_create
+ if [ "$use_backing_file" = "yes" ]; then
+ $QEMU_IMG create -f raw "$TEST_IMG.base" "$size" | _filter_img_create
+ $QEMU_IO -c "write -q -P 0xFF 0 $size" -f raw "$TEST_IMG.base" | _filter_qemu_io
+ $QEMU_IO -c "write -q -P 0xFF 0 $size" -f raw "$TEST_IMG.raw" | _filter_qemu_io
+ _make_test_img -o extended_l2=on -F raw -b "$TEST_IMG.base" "$size"
+ else
+ _make_test_img -o extended_l2=on "$size"
+ fi
+}
+
+############################################################
+############################################################
+############################################################
+
+# Test that writing to an image with subclusters produces the expected
+# results, in images with and without backing files
+for use_backing_file in yes no; do
+ echo
+ echo "### Standard write tests (backing file: $use_backing_file) ###"
+ echo
+ _reset_img 1M
+ ### Write subcluster #0 (beginning of subcluster) ###
+ alloc="0"; zero=""
+ _run_test sc=0 len=1k
+
+ ### Write subcluster #1 (middle of subcluster) ###
+ alloc="0 1"; zero=""
+ _run_test sc=1 off=1 len=512
+
+ ### Write subcluster #2 (end of subcluster) ###
+ alloc="0 1 2"; zero=""
+ _run_test sc=2 off=1 len=1k
+
+ ### Write subcluster #3 (full subcluster) ###
+ alloc="0 1 2 3"; zero=""
+ _run_test sc=3 len=2k
+
+ ### Write subclusters #4-6 (full subclusters) ###
+ alloc="$(seq 0 6)"; zero=""
+ _run_test sc=4 len=6k
+
+ ### Write subclusters #7-9 (partial subclusters) ###
+ alloc="$(seq 0 9)"; zero=""
+ _run_test sc=7 off=1 len=4k
+
+ ### Write subcluster #16 (partial subcluster) ###
+ alloc="$(seq 0 9) 16"; zero=""
+ _run_test sc=16 len=1k
+
+ ### Write subcluster #31-#33 (cluster overlap) ###
+ alloc="$(seq 0 9) 16 31"; zero=""
+ _run_test sc=31 off=1 len=4k
+ alloc="0 1" ; zero=""
+ _verify_l2_bitmap 1
+
+ ### Zero subcluster #1
+ alloc="0 $(seq 2 9) 16 31"; zero="1"
+ _run_test sc=1 len=2k cmd=zero
+
+ ### Zero cluster #0
+ alloc=""; zero="$(seq 0 31)"
+ _run_test sc=0 len=64k cmd=zero
+
+ ### Fill cluster #0 with data
+ alloc="$(seq 0 31)"; zero=""
+ _run_test sc=0 len=64k
+
+ ### Zero and unmap half of cluster #0 (this won't unmap it)
+ alloc="$(seq 16 31)"; zero="$(seq 0 15)"
+ _run_test sc=0 len=32k cmd=unmap
+
+ ### Zero and unmap cluster #0
+ alloc=""; zero="$(seq 0 31)"
+ _run_test sc=0 len=64k cmd=unmap
+
+ ### Write subcluster #1 (middle of subcluster)
+ alloc="1"; zero="0 $(seq 2 31)"
+ _run_test sc=1 off=1 len=512
+
+ ### Fill cluster #0 with data
+ alloc="$(seq 0 31)"; zero=""
+ _run_test sc=0 len=64k
+
+ ### Discard cluster #0
+ alloc=""; zero="$(seq 0 31)"
+ _run_test sc=0 len=64k cmd=discard
+
+ ### Write compressed data to cluster #0
+ alloc=""; zero=""
+ _run_test sc=0 len=64k cmd=compress
+
+ ### Write subcluster #1 (middle of subcluster)
+ alloc="$(seq 0 31)"; zero=""
+ _run_test sc=1 off=1 len=512
+done
+
+############################################################
+############################################################
+############################################################
+
+# calculate_l2_meta() checks if none of the clusters affected by a
+# write operation need COW or changes to their L2 metadata and simply
+# returns when they don't. This is a test for that optimization.
+# Here clusters #0-#3 are overwritten but only #1 and #2 need changes.
+echo
+echo '### Overwriting several clusters without COW ###'
+echo
+use_backing_file="no" _reset_img 1M
+# Write cluster #0, subclusters #12-#31
+alloc="$(seq 12 31)"; zero=""
+_run_test sc=12 len=40k
+
+# Write cluster #1, subcluster #13
+alloc="13"; zero=""
+_run_test c=1 sc=13 len=2k
+
+# Zeroize cluster #2, subcluster #14
+alloc="14"; zero=""
+_run_test c=2 sc=14 len=2k
+alloc=""; zero="14"
+_run_test c=2 sc=14 len=2k cmd=zero
+
+# Write cluster #3, subclusters #0-#16
+alloc="$(seq 0 16)"; zero=""
+_run_test c=3 sc=0 len=34k
+
+# Write from cluster #0, subcluster #12 to cluster #3, subcluster #11
+alloc="$(seq 12 31)"; zero=""
+_run_test sc=12 len=192k
+alloc="$(seq 0 31)"; zero=""
+_verify_l2_bitmap 1
+_verify_l2_bitmap 2
+
+alloc="$(seq 0 16)"; zero=""
+_verify_l2_bitmap 3
+
+############################################################
+############################################################
+############################################################
+
+# Test different patterns of writing zeroes
+for use_backing_file in yes no; do
+ echo
+ echo "### Writing zeroes 1: unallocated clusters (backing file: $use_backing_file) ###"
+ echo
+ # Note that the image size is not a multiple of the cluster size
+ _reset_img 2083k
+
+ # Cluster-aligned request from clusters #0 to #2
+ alloc=""; zero="$(seq 0 31)"
+ _run_test c=0 sc=0 len=192k cmd=zero
+ _verify_l2_bitmap 1
+ _verify_l2_bitmap 2
+
+ # Subcluster-aligned request from clusters #3 to #5
+ alloc=""; zero="$(seq 16 31)"
+ _run_test c=3 sc=16 len=128k cmd=zero
+ alloc=""; zero="$(seq 0 31)"
+ _verify_l2_bitmap 4
+ alloc=""; zero="$(seq 0 15)"
+ _verify_l2_bitmap 5
+
+ # Unaligned request from clusters #6 to #8
+ if [ "$use_backing_file" = "yes" ]; then
+ alloc="15"; zero="$(seq 16 31)" # copy-on-write happening here
+ else
+ alloc=""; zero="$(seq 15 31)"
+ fi
+ _run_test c=6 sc=15 off=1 len=128k cmd=zero
+ alloc=""; zero="$(seq 0 31)"
+ _verify_l2_bitmap 7
+ if [ "$use_backing_file" = "yes" ]; then
+ alloc="15"; zero="$(seq 0 14)" # copy-on-write happening here
+ else
+ alloc=""; zero="$(seq 0 15)"
+ fi
+ _verify_l2_bitmap 8
+
+ echo
+ echo "### Writing zeroes 2: allocated clusters (backing file: $use_backing_file) ###"
+ echo
+ alloc="$(seq 0 31)"; zero=""
+ _run_test c=9 sc=0 len=576k
+ _verify_l2_bitmap 10
+ _verify_l2_bitmap 11
+ _verify_l2_bitmap 12
+ _verify_l2_bitmap 13
+ _verify_l2_bitmap 14
+ _verify_l2_bitmap 15
+ _verify_l2_bitmap 16
+ _verify_l2_bitmap 17
+
+ # Cluster-aligned request from clusters #9 to #11
+ alloc=""; zero="$(seq 0 31)"
+ _run_test c=9 sc=0 len=192k cmd=zero
+ _verify_l2_bitmap 10
+ _verify_l2_bitmap 11
+
+ # Subcluster-aligned request from clusters #12 to #14
+ alloc="$(seq 0 15)"; zero="$(seq 16 31)"
+ _run_test c=12 sc=16 len=128k cmd=zero
+ alloc=""; zero="$(seq 0 31)"
+ _verify_l2_bitmap 13
+ alloc="$(seq 16 31)"; zero="$(seq 0 15)"
+ _verify_l2_bitmap 14
+
+ # Unaligned request from clusters #15 to #17
+ alloc="$(seq 0 15)"; zero="$(seq 16 31)"
+ _run_test c=15 sc=15 off=1 len=128k cmd=zero
+ alloc=""; zero="$(seq 0 31)"
+ _verify_l2_bitmap 16
+ alloc="$(seq 15 31)"; zero="$(seq 0 14)"
+ _verify_l2_bitmap 17
+
+ echo
+ echo "### Writing zeroes 3: compressed clusters (backing file: $use_backing_file) ###"
+ echo
+ alloc=""; zero=""
+ for c in $(seq 18 28); do
+ _run_test c=$c sc=0 len=64k cmd=compress
+ done
+
+ # Cluster-aligned request from clusters #18 to #20
+ alloc=""; zero="$(seq 0 31)"
+ _run_test c=18 sc=0 len=192k cmd=zero
+ _verify_l2_bitmap 19
+ _verify_l2_bitmap 20
+
+ # Subcluster-aligned request from clusters #21 to #23.
+ # We cannot partially zero a compressed cluster so the code
+ # returns -ENOTSUP, which means copy-on-write of the compressed
+ # data and fill the rest with actual zeroes on disk.
+ # TODO: cluster #22 should use the 'all zeroes' bits.
+ alloc="$(seq 0 31)"; zero=""
+ _run_test c=21 sc=16 len=128k cmd=zero
+ _verify_l2_bitmap 22
+ _verify_l2_bitmap 23
+
+ # Unaligned request from clusters #24 to #26
+ # In this case QEMU internally sends a 1k request followed by a
+ # subcluster-aligned 128k request. The first request decompresses
+ # cluster #24, but that's not enough to perform the second request
+ # efficiently because it partially writes to cluster #26 (which is
+ # compressed) so we hit the same problem as before.
+ alloc="$(seq 0 31)"; zero=""
+ _run_test c=24 sc=15 off=1 len=129k cmd=zero
+ _verify_l2_bitmap 25
+ _verify_l2_bitmap 26
+
+ # Unaligned request from clusters #27 to #29
+ # Similar to the previous case, but this time the tail of the
+ # request does not correspond to a compressed cluster, so it can
+ # be zeroed efficiently.
+ # Note that the very last subcluster is partially written, so if
+ # there's a backing file we need to perform cow.
+ alloc="$(seq 0 15)"; zero="$(seq 16 31)"
+ _run_test c=27 sc=15 off=1 len=128k cmd=zero
+ alloc=""; zero="$(seq 0 31)"
+ _verify_l2_bitmap 28
+ if [ "$use_backing_file" = "yes" ]; then
+ alloc="15"; zero="$(seq 0 14)" # copy-on-write happening here
+ else
+ alloc=""; zero="$(seq 0 15)"
+ fi
+ _verify_l2_bitmap 29
+
+ echo
+ echo "### Writing zeroes 4: other tests (backing file: $use_backing_file) ###"
+ echo
+ # Unaligned request in the middle of cluster #30.
+ # If there's a backing file we need to allocate and do
+ # copy-on-write on the partially zeroed subclusters.
+ # If not we can set the 'all zeroes' bit on them.
+ if [ "$use_backing_file" = "yes" ]; then
+ alloc="15 19"; zero="$(seq 16 18)" # copy-on-write happening here
+ else
+ alloc=""; zero="$(seq 15 19)"
+ fi
+ _run_test c=30 sc=15 off=1 len=8k cmd=zero
+
+ # Fill the last cluster with zeroes, up to the end of the image
+ # (the image size is not a multiple of the cluster or subcluster size).
+ alloc=""; zero="$(seq 0 17)"
+ _run_test c=32 sc=0 len=35k cmd=zero
+done
+
+############################################################
+############################################################
+############################################################
+
+# Zero + unmap
+for use_backing_file in yes no; do
+ echo
+ echo "### Zero + unmap 1: allocated clusters (backing file: $use_backing_file) ###"
+ echo
+ # Note that the image size is not a multiple of the cluster size
+ _reset_img 2083k
+ alloc="$(seq 0 31)"; zero=""
+ _run_test c=9 sc=0 len=576k
+ _verify_l2_bitmap 10
+ _verify_l2_bitmap 11
+ _verify_l2_bitmap 12
+ _verify_l2_bitmap 13
+ _verify_l2_bitmap 14
+ _verify_l2_bitmap 15
+ _verify_l2_bitmap 16
+ _verify_l2_bitmap 17
+
+ # Cluster-aligned request from clusters #9 to #11
+ alloc=""; zero="$(seq 0 31)"
+ _run_test c=9 sc=0 len=192k cmd=unmap
+ _verify_l2_bitmap 10
+ _verify_l2_bitmap 11
+
+ # Subcluster-aligned request from clusters #12 to #14
+ alloc="$(seq 0 15)"; zero="$(seq 16 31)"
+ _run_test c=12 sc=16 len=128k cmd=unmap
+ alloc=""; zero="$(seq 0 31)"
+ _verify_l2_bitmap 13
+ alloc="$(seq 16 31)"; zero="$(seq 0 15)"
+ _verify_l2_bitmap 14
+
+ # Unaligned request from clusters #15 to #17
+ alloc="$(seq 0 15)"; zero="$(seq 16 31)"
+ _run_test c=15 sc=15 off=1 len=128k cmd=unmap
+ alloc=""; zero="$(seq 0 31)"
+ _verify_l2_bitmap 16
+ alloc="$(seq 15 31)"; zero="$(seq 0 14)"
+ _verify_l2_bitmap 17
+
+ echo
+ echo "### Zero + unmap 2: compressed clusters (backing file: $use_backing_file) ###"
+ echo
+ alloc=""; zero=""
+ for c in $(seq 18 28); do
+ _run_test c=$c sc=0 len=64k cmd=compress
+ done
+
+ # Cluster-aligned request from clusters #18 to #20
+ alloc=""; zero="$(seq 0 31)"
+ _run_test c=18 sc=0 len=192k cmd=unmap
+ _verify_l2_bitmap 19
+ _verify_l2_bitmap 20
+
+ # Subcluster-aligned request from clusters #21 to #23.
+ # We cannot partially zero a compressed cluster so the code
+ # returns -ENOTSUP, which means copy-on-write of the compressed
+ # data and fill the rest with actual zeroes on disk.
+ # TODO: cluster #22 should use the 'all zeroes' bits.
+ alloc="$(seq 0 31)"; zero=""
+ _run_test c=21 sc=16 len=128k cmd=unmap
+ _verify_l2_bitmap 22
+ _verify_l2_bitmap 23
+
+ # Unaligned request from clusters #24 to #26
+ # In this case QEMU internally sends a 1k request followed by a
+ # subcluster-aligned 128k request. The first request decompresses
+ # cluster #24, but that's not enough to perform the second request
+ # efficiently because it partially writes to cluster #26 (which is
+ # compressed) so we hit the same problem as before.
+ alloc="$(seq 0 31)"; zero=""
+ _run_test c=24 sc=15 off=1 len=129k cmd=unmap
+ _verify_l2_bitmap 25
+ _verify_l2_bitmap 26
+
+ # Unaligned request from clusters #27 to #29
+ # Similar to the previous case, but this time the tail of the
+ # request does not correspond to a compressed cluster, so it can
+ # be zeroed efficiently.
+ # Note that the very last subcluster is partially written, so if
+ # there's a backing file we need to perform cow.
+ alloc="$(seq 0 15)"; zero="$(seq 16 31)"
+ _run_test c=27 sc=15 off=1 len=128k cmd=unmap
+ alloc=""; zero="$(seq 0 31)"
+ _verify_l2_bitmap 28
+ if [ "$use_backing_file" = "yes" ]; then
+ alloc="15"; zero="$(seq 0 14)" # copy-on-write happening here
+ else
+ alloc=""; zero="$(seq 0 15)"
+ fi
+ _verify_l2_bitmap 29
+done
+
+############################################################
+############################################################
+############################################################
+
+# Test qcow2_cluster_discard() with full and normal discards
+for use_backing_file in yes no; do
+ echo
+ echo "### Discarding clusters with non-zero bitmaps (backing file: $use_backing_file) ###"
+ echo
+ if [ "$use_backing_file" = "yes" ]; then
+ _make_test_img -o extended_l2=on -F raw -b "$TEST_IMG.base" 1M
+ else
+ _make_test_img -o extended_l2=on 1M
+ fi
+ # Write clusters #0-#2 and then discard them
+ $QEMU_IO -c 'write -q 0 128k' "$TEST_IMG"
+ $QEMU_IO -c 'discard -q 0 128k' "$TEST_IMG"
+ # 'qemu-io discard' doesn't do a full discard, it zeroizes the
+ # cluster, so both clusters have all zero bits set now
+ alloc=""; zero="$(seq 0 31)"
+ _verify_l2_bitmap 0
+ _verify_l2_bitmap 1
+ # Now mark the 2nd half of the subclusters from cluster #0 as unallocated
+ poke_file "$TEST_IMG" $(($l2_offset+8)) "\x00\x00"
+ # Discard cluster #0 again to see how the zero bits have changed
+ $QEMU_IO -c 'discard -q 0 64k' "$TEST_IMG"
+ # And do a full discard of cluster #1 by shrinking and growing the image
+ $QEMU_IMG resize --shrink "$TEST_IMG" 64k
+ $QEMU_IMG resize "$TEST_IMG" 1M
+ # A normal discard sets all 'zero' bits only if the image has a
+ # backing file, otherwise it won't touch them.
+ if [ "$use_backing_file" = "yes" ]; then
+ alloc=""; zero="$(seq 0 31)"
+ else
+ alloc=""; zero="$(seq 0 15)"
+ fi
+ _verify_l2_bitmap 0
+ # A full discard should clear the L2 entry completely. However
+ # when growing an image with a backing file the new clusters are
+ # zeroized to hide the stale data from the backing file
+ if [ "$use_backing_file" = "yes" ]; then
+ alloc=""; zero="$(seq 0 31)"
+ else
+ alloc=""; zero=""
+ fi
+ _verify_l2_bitmap 1
+done
+
+############################################################
+############################################################
+############################################################
+
+# Test that corrupted L2 entries are detected in both read and write
+# operations
+for corruption_test_cmd in read write; do
+ echo
+ echo "### Corrupted L2 entries - $corruption_test_cmd test (allocated) ###"
+ echo
+ echo "# 'cluster is zero' bit set on the standard cluster descriptor"
+ echo
+ # We actually don't consider this a corrupted image.
+ # The 'cluster is zero' bit is unused in extended L2 entries so
+ # QEMU ignores it.
+ # TODO: maybe treat the image as corrupted and make qemu-img check fix it?
+ _make_test_img -o extended_l2=on 1M
+ $QEMU_IO -c 'write -q -P 0x11 0 2k' "$TEST_IMG"
+ poke_file "$TEST_IMG" $(($l2_offset+7)) "\x01"
+ alloc="0"; zero=""
+ _verify_l2_bitmap 0
+ $QEMU_IO -c "$corruption_test_cmd -q -P 0x11 0 1k" "$TEST_IMG"
+ if [ "$corruption_test_cmd" = "write" ]; then
+ alloc="0"; zero=""
+ fi
+ _verify_l2_bitmap 0
+
+ echo
+ echo "# Both 'subcluster is zero' and 'subcluster is allocated' bits set"
+ echo
+ _make_test_img -o extended_l2=on 1M
+ # Write from the middle of cluster #0 to the middle of cluster #2
+ $QEMU_IO -c 'write -q 32k 128k' "$TEST_IMG"
+ # Corrupt the L2 entry from cluster #1
+ poke_file_be "$TEST_IMG" $(($l2_offset+24)) 4 1
+ alloc="$(seq 0 31)"; zero="0"
+ _verify_l2_bitmap 1
+ $QEMU_IO -c "$corruption_test_cmd 0 192k" "$TEST_IMG"
+
+ echo
+ echo "### Corrupted L2 entries - $corruption_test_cmd test (unallocated) ###"
+ echo
+ echo "# 'cluster is zero' bit set on the standard cluster descriptor"
+ echo
+ # We actually don't consider this a corrupted image.
+ # The 'cluster is zero' bit is unused in extended L2 entries so
+ # QEMU ignores it.
+ # TODO: maybe treat the image as corrupted and make qemu-img check fix it?
+ _make_test_img -o extended_l2=on 1M
+ # We want to modify the (empty) L2 entry from cluster #0,
+ # but we write to #4 in order to initialize the L2 table first
+ $QEMU_IO -c 'write -q 256k 1k' "$TEST_IMG"
+ poke_file "$TEST_IMG" $(($l2_offset+7)) "\x01"
+ alloc=""; zero=""
+ _verify_l2_bitmap 0
+ $QEMU_IO -c "$corruption_test_cmd -q 0 1k" "$TEST_IMG"
+ if [ "$corruption_test_cmd" = "write" ]; then
+ alloc="0"; zero=""
+ fi
+ _verify_l2_bitmap 0
+
+ echo
+ echo "# 'subcluster is allocated' bit set"
+ echo
+ _make_test_img -o extended_l2=on 1M
+ # We want to corrupt the (empty) L2 entry from cluster #0,
+ # but we write to #4 in order to initialize the L2 table first
+ $QEMU_IO -c 'write -q 256k 1k' "$TEST_IMG"
+ poke_file "$TEST_IMG" $(($l2_offset+15)) "\x01"
+ alloc="0"; zero=""
+ _verify_l2_bitmap 0
+ $QEMU_IO -c "$corruption_test_cmd 0 1k" "$TEST_IMG"
+
+ echo
+ echo "# Both 'subcluster is zero' and 'subcluster is allocated' bits set"
+ echo
+ _make_test_img -o extended_l2=on 1M
+ # We want to corrupt the (empty) L2 entry from cluster #1,
+ # but we write to #4 in order to initialize the L2 table first
+ $QEMU_IO -c 'write -q 256k 1k' "$TEST_IMG"
+ # Corrupt the L2 entry from cluster #1
+ poke_file_be "$TEST_IMG" $(($l2_offset+24)) 8 $(((1 << 32) | 1))
+ alloc="0"; zero="0"
+ _verify_l2_bitmap 1
+ $QEMU_IO -c "$corruption_test_cmd 0 192k" "$TEST_IMG"
+
+ echo
+ echo "### Compressed cluster with subcluster bitmap != 0 - $corruption_test_cmd test ###"
+ echo
+ # We actually don't consider this a corrupted image.
+ # The bitmap in compressed clusters is unused so QEMU should just ignore it.
+ _make_test_img -o extended_l2=on 1M
+ $QEMU_IO -c 'write -q -P 11 -c 0 64k' "$TEST_IMG"
+ # Change the L2 bitmap to allocate subcluster #31 and zeroize subcluster #0
+ poke_file "$TEST_IMG" $(($l2_offset+11)) "\x01\x80"
+ alloc="31"; zero="0"
+ _verify_l2_bitmap 0
+ $QEMU_IO -c "$corruption_test_cmd -P 11 0 64k" "$TEST_IMG" | _filter_qemu_io
+ # Writing allocates a new uncompressed cluster so we get a new bitmap
+ if [ "$corruption_test_cmd" = "write" ]; then
+ alloc="$(seq 0 31)"; zero=""
+ fi
+ _verify_l2_bitmap 0
+done
+
+############################################################
+############################################################
+############################################################
+
+echo
+echo "### Detect and repair unaligned clusters ###"
+echo
+# Create a backing file and fill it with data
+$QEMU_IMG create -f raw "$TEST_IMG.base" 128k | _filter_img_create
+$QEMU_IO -c "write -q -P 0xff 0 128k" -f raw "$TEST_IMG.base" | _filter_qemu_io
+
+echo "# Corrupted L2 entry, allocated subcluster #"
+# Create a new image, allocate a cluster and write some data to it
+_make_test_img -o extended_l2=on -F raw -b "$TEST_IMG.base"
+$QEMU_IO -c 'write -q -P 1 4k 2k' "$TEST_IMG"
+# Corrupt the L2 entry by making the offset unaligned
+poke_file "$TEST_IMG" "$(($l2_offset+6))" "\x02"
+# This cannot be repaired, qemu-img check will fail to fix it
+_check_test_img -r all
+# Attempting to read the image will still show that it's corrupted
+$QEMU_IO -c 'read -q 0 2k' "$TEST_IMG"
+
+echo "# Corrupted L2 entry, no allocated subclusters #"
+# Create a new image, allocate a cluster and zeroize subcluster #2
+_make_test_img -o extended_l2=on -F raw -b "$TEST_IMG.base"
+$QEMU_IO -c 'write -q -P 1 4k 2k' "$TEST_IMG"
+$QEMU_IO -c 'write -q -z 4k 2k' "$TEST_IMG"
+# Corrupt the L2 entry by making the offset unaligned
+poke_file "$TEST_IMG" "$(($l2_offset+6))" "\x02"
+# This time none of the subclusters are allocated so we can repair the image
+_check_test_img -r all
+# And the data can be read normally
+$QEMU_IO -c 'read -q -P 0xff 0 4k' "$TEST_IMG"
+$QEMU_IO -c 'read -q -P 0x00 4k 2k' "$TEST_IMG"
+$QEMU_IO -c 'read -q -P 0xff 6k 122k' "$TEST_IMG"
+
+############################################################
+############################################################
+############################################################
+
+echo
+echo "### Image creation options ###"
+echo
+echo "# cluster_size < 16k"
+_make_test_img -o extended_l2=on,cluster_size=8k 1M
+
+echo "# backing file and preallocation=metadata"
+# For preallocation with backing files, create a backing file first
+$QEMU_IMG create -f raw "$TEST_IMG.base" 1M | _filter_img_create
+$QEMU_IO -c "write -q -P 0xff 0 1M" -f raw "$TEST_IMG.base" | _filter_qemu_io
+
+_make_test_img -o extended_l2=on,preallocation=metadata -F raw -b "$TEST_IMG.base" 512k
+$QEMU_IMG resize "$TEST_IMG" 1M
+$QEMU_IO -c 'read -P 0xff 0 512k' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c 'read -P 0x00 512k 512k' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IMG map "$TEST_IMG" | _filter_testdir
+
+echo "# backing file and preallocation=falloc"
+_make_test_img -o extended_l2=on,preallocation=falloc -F raw -b "$TEST_IMG.base" 512k
+$QEMU_IMG resize "$TEST_IMG" 1M
+$QEMU_IO -c 'read -P 0xff 0 512k' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c 'read -P 0x00 512k 512k' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IMG map "$TEST_IMG" | _filter_testdir
+
+echo "# backing file and preallocation=full"
+_make_test_img -o extended_l2=on,preallocation=full -F raw -b "$TEST_IMG.base" 512k
+$QEMU_IMG resize "$TEST_IMG" 1M
+$QEMU_IO -c 'read -P 0xff 0 512k' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c 'read -P 0x00 512k 512k' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IMG map "$TEST_IMG" | _filter_testdir
+
+echo
+echo "### Image resizing with preallocation and backing files ###"
+echo
+# In this case the new subclusters must have the 'all zeroes' bit set
+echo "# resize --preallocation=metadata"
+_make_test_img -o extended_l2=on -F raw -b "$TEST_IMG.base" 503k
+$QEMU_IMG resize --preallocation=metadata "$TEST_IMG" 1013k
+$QEMU_IO -c 'read -P 0xff 0 503k' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c 'read -P 0x00 503k 510k' "$TEST_IMG" | _filter_qemu_io
+
+# In this case and the next one the new subclusters must be allocated
+echo "# resize --preallocation=falloc"
+_make_test_img -o extended_l2=on -F raw -b "$TEST_IMG.base" 503k
+$QEMU_IMG resize --preallocation=falloc "$TEST_IMG" 1013k
+$QEMU_IO -c 'read -P 0xff 0 503k' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c 'read -P 0x00 503k 510k' "$TEST_IMG" | _filter_qemu_io
+
+echo "# resize --preallocation=full"
+_make_test_img -o extended_l2=on -F raw -b "$TEST_IMG.base" 503k
+$QEMU_IMG resize --preallocation=full "$TEST_IMG" 1013k
+$QEMU_IO -c 'read -P 0xff 0 503k' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c 'read -P 0x00 503k 510k' "$TEST_IMG" | _filter_qemu_io
+
+echo
+echo "### Image resizing with preallocation without backing files ###"
+echo
+# In this case the new subclusters must have the 'all zeroes' bit set
+echo "# resize --preallocation=metadata"
+_make_test_img -o extended_l2=on 503k
+$QEMU_IO -c 'write -P 0xff 0 503k' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IMG resize --preallocation=metadata "$TEST_IMG" 1013k
+$QEMU_IO -c 'read -P 0xff 0 503k' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c 'read -P 0x00 503k 510k' "$TEST_IMG" | _filter_qemu_io
+
+# In this case and the next one the new subclusters must be allocated
+echo "# resize --preallocation=falloc"
+_make_test_img -o extended_l2=on 503k
+$QEMU_IO -c 'write -P 0xff 0 503k' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IMG resize --preallocation=falloc "$TEST_IMG" 1013k
+$QEMU_IO -c 'read -P 0xff 0 503k' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c 'read -P 0x00 503k 510k' "$TEST_IMG" | _filter_qemu_io
+
+echo "# resize --preallocation=full"
+_make_test_img -o extended_l2=on 503k
+$QEMU_IO -c 'write -P 0xff 0 503k' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IMG resize --preallocation=full "$TEST_IMG" 1013k
+$QEMU_IO -c 'read -P 0xff 0 503k' "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c 'read -P 0x00 503k 510k' "$TEST_IMG" | _filter_qemu_io
+
+echo
+echo "### qemu-img measure ###"
+echo
+echo "# 512MB, extended_l2=off" # This needs one L2 table
+$QEMU_IMG measure --size 512M -O qcow2 -o extended_l2=off
+echo "# 512MB, extended_l2=on" # This needs two L2 tables
+$QEMU_IMG measure --size 512M -O qcow2 -o extended_l2=on
+
+echo "# 16K clusters, 64GB, extended_l2=off" # This needs one full L1 table cluster
+$QEMU_IMG measure --size 64G -O qcow2 -o cluster_size=16k,extended_l2=off
+echo "# 16K clusters, 64GB, extended_l2=on" # This needs two full L2 table clusters
+$QEMU_IMG measure --size 64G -O qcow2 -o cluster_size=16k,extended_l2=on
+
+echo "# 8k clusters" # This should fail
+$QEMU_IMG measure --size 1M -O qcow2 -o cluster_size=8k,extended_l2=on
+
+echo "# 1024 TB" # Maximum allowed size with extended_l2=on and 64K clusters
+$QEMU_IMG measure --size 1024T -O qcow2 -o extended_l2=on
+echo "# 1025 TB" # This should fail
+$QEMU_IMG measure --size 1025T -O qcow2 -o extended_l2=on
+
+echo
+echo "### qemu-img amend ###"
+echo
+_make_test_img -o extended_l2=on 1M
+$QEMU_IMG amend -o extended_l2=off "$TEST_IMG" && echo "Unexpected pass"
+
+_make_test_img -o extended_l2=off 1M
+$QEMU_IMG amend -o extended_l2=on "$TEST_IMG" && echo "Unexpected pass"
+
+echo
+echo "### Test copy-on-write on an image with snapshots ###"
+echo
+_make_test_img -o extended_l2=on 1M
+
+# For each cluster from #0 to #9 this loop zeroes subcluster #7
+# and allocates subclusters #13 and #18.
+alloc="13 18"; zero="7"
+for c in $(seq 0 9); do
+ $QEMU_IO -c "write -q -z $((64*$c+14))k 2k" \
+ -c "write -q -P $((0xd0+$c)) $((64*$c+26))k 2k" \
+ -c "write -q -P $((0xe0+$c)) $((64*$c+36))k 2k" "$TEST_IMG"
+ _verify_l2_bitmap "$c"
+done
+
+# Create a snapshot and set l2_offset to the new L2 table
+$QEMU_IMG snapshot -c snap1 "$TEST_IMG"
+l2_offset=$((0x110000))
+
+# Write different patterns to each one of the clusters
+# in order to see how copy-on-write behaves in each case.
+$QEMU_IO -c "write -q -P 0xf0 $((64*0+30))k 1k" \
+ -c "write -q -P 0xf1 $((64*1+20))k 1k" \
+ -c "write -q -P 0xf2 $((64*2+40))k 1k" \
+ -c "write -q -P 0xf3 $((64*3+26))k 1k" \
+ -c "write -q -P 0xf4 $((64*4+14))k 1k" \
+ -c "write -q -P 0xf5 $((64*5+1))k 1k" \
+ -c "write -q -z $((64*6+30))k 3k" \
+ -c "write -q -z $((64*7+26))k 2k" \
+ -c "write -q -z $((64*8+26))k 1k" \
+ -c "write -q -z $((64*9+12))k 1k" \
+ "$TEST_IMG"
+alloc="$(seq 13 18)"; zero="7" _verify_l2_bitmap 0
+alloc="$(seq 10 18)"; zero="7" _verify_l2_bitmap 1
+alloc="$(seq 13 20)"; zero="7" _verify_l2_bitmap 2
+alloc="$(seq 13 18)"; zero="7" _verify_l2_bitmap 3
+alloc="$(seq 7 18)"; zero="" _verify_l2_bitmap 4
+alloc="$(seq 0 18)"; zero="" _verify_l2_bitmap 5
+alloc="13 18"; zero="7 15 16" _verify_l2_bitmap 6
+alloc="18"; zero="7 13" _verify_l2_bitmap 7
+alloc="$(seq 13 18)"; zero="7" _verify_l2_bitmap 8
+alloc="13 18"; zero="6 7" _verify_l2_bitmap 9
+
+echo
+echo "### Test concurrent requests ###"
+echo
+
+_concurrent_io()
+{
+# Allocate three subclusters in the same cluster.
+# This works because handle_dependencies() checks whether the requests
+# allocate the same cluster, even if the COW regions don't overlap (in
+# this case they don't).
+cat <<EOF
+open -o driver=$IMGFMT blkdebug::$TEST_IMG
+break write_aio A
+aio_write -P 10 30k 2k
+wait_break A
+aio_write -P 11 20k 2k
+aio_write -P 12 40k 2k
+resume A
+aio_flush
+EOF
+}
+
+_concurrent_verify()
+{
+cat <<EOF
+open -o driver=$IMGFMT $TEST_IMG
+read -q -P 10 30k 2k
+read -q -P 11 20k 2k
+read -q -P 12 40k 2k
+EOF
+}
+
+_make_test_img -o extended_l2=on 1M
+_concurrent_io | $QEMU_IO | _filter_qemu_io
+_concurrent_verify | $QEMU_IO | _filter_qemu_io
+
+# success, all done
+echo "*** done"
+rm -f $seq.full
+status=0
diff --git a/tests/qemu-iotests/271.out b/tests/qemu-iotests/271.out
new file mode 100644
index 0000000000..92deb7ebb0
--- /dev/null
+++ b/tests/qemu-iotests/271.out
@@ -0,0 +1,726 @@
+QA output created by 271
+
+### Standard write tests (backing file: yes) ###
+
+Formatting 'TEST_DIR/t.IMGFMT.raw', fmt=raw size=1048576
+Formatting 'TEST_DIR/t.IMGFMT.base', fmt=raw size=1048576
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
+write -q -P PATTERN 0 1k
+L2 entry #0: 0x8000000000050000 0000000000000001
+write -q -P PATTERN 3k 512
+L2 entry #0: 0x8000000000050000 0000000000000003
+write -q -P PATTERN 5k 1k
+L2 entry #0: 0x8000000000050000 0000000000000007
+write -q -P PATTERN 6k 2k
+L2 entry #0: 0x8000000000050000 000000000000000f
+write -q -P PATTERN 8k 6k
+L2 entry #0: 0x8000000000050000 000000000000007f
+write -q -P PATTERN 15k 4k
+L2 entry #0: 0x8000000000050000 00000000000003ff
+write -q -P PATTERN 32k 1k
+L2 entry #0: 0x8000000000050000 00000000000103ff
+write -q -P PATTERN 63k 4k
+L2 entry #0: 0x8000000000050000 00000000800103ff
+L2 entry #1: 0x8000000000060000 0000000000000003
+write -q -z 2k 2k
+L2 entry #0: 0x8000000000050000 00000002800103fd
+write -q -z 0 64k
+L2 entry #0: 0x8000000000050000 ffffffff00000000
+write -q -P PATTERN 0 64k
+L2 entry #0: 0x8000000000050000 00000000ffffffff
+write -q -z -u 0 32k
+L2 entry #0: 0x8000000000050000 0000ffffffff0000
+write -q -z -u 0 64k
+L2 entry #0: 0x0000000000000000 ffffffff00000000
+write -q -P PATTERN 3k 512
+L2 entry #0: 0x8000000000050000 fffffffd00000002
+write -q -P PATTERN 0 64k
+L2 entry #0: 0x8000000000050000 00000000ffffffff
+discard -q 0 64k
+L2 entry #0: 0x0000000000000000 ffffffff00000000
+write -q -c -P PATTERN 0 64k
+L2 entry #0: 0x4000000000050000 0000000000000000
+write -q -P PATTERN 3k 512
+L2 entry #0: 0x8000000000070000 00000000ffffffff
+
+### Standard write tests (backing file: no) ###
+
+Formatting 'TEST_DIR/t.IMGFMT.raw', fmt=raw size=1048576
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+write -q -P PATTERN 0 1k
+L2 entry #0: 0x8000000000050000 0000000000000001
+write -q -P PATTERN 3k 512
+L2 entry #0: 0x8000000000050000 0000000000000003
+write -q -P PATTERN 5k 1k
+L2 entry #0: 0x8000000000050000 0000000000000007
+write -q -P PATTERN 6k 2k
+L2 entry #0: 0x8000000000050000 000000000000000f
+write -q -P PATTERN 8k 6k
+L2 entry #0: 0x8000000000050000 000000000000007f
+write -q -P PATTERN 15k 4k
+L2 entry #0: 0x8000000000050000 00000000000003ff
+write -q -P PATTERN 32k 1k
+L2 entry #0: 0x8000000000050000 00000000000103ff
+write -q -P PATTERN 63k 4k
+L2 entry #0: 0x8000000000050000 00000000800103ff
+L2 entry #1: 0x8000000000060000 0000000000000003
+write -q -z 2k 2k
+L2 entry #0: 0x8000000000050000 00000002800103fd
+write -q -z 0 64k
+L2 entry #0: 0x8000000000050000 ffffffff00000000
+write -q -P PATTERN 0 64k
+L2 entry #0: 0x8000000000050000 00000000ffffffff
+write -q -z -u 0 32k
+L2 entry #0: 0x8000000000050000 0000ffffffff0000
+write -q -z -u 0 64k
+L2 entry #0: 0x0000000000000000 ffffffff00000000
+write -q -P PATTERN 3k 512
+L2 entry #0: 0x8000000000050000 fffffffd00000002
+write -q -P PATTERN 0 64k
+L2 entry #0: 0x8000000000050000 00000000ffffffff
+discard -q 0 64k
+L2 entry #0: 0x0000000000000000 ffffffff00000000
+write -q -c -P PATTERN 0 64k
+L2 entry #0: 0x4000000000050000 0000000000000000
+write -q -P PATTERN 3k 512
+L2 entry #0: 0x8000000000070000 00000000ffffffff
+
+### Overwriting several clusters without COW ###
+
+Formatting 'TEST_DIR/t.IMGFMT.raw', fmt=raw size=1048576
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+write -q -P PATTERN 24k 40k
+L2 entry #0: 0x8000000000050000 00000000fffff000
+write -q -P PATTERN 90k 2k
+L2 entry #1: 0x8000000000060000 0000000000002000
+write -q -P PATTERN 156k 2k
+L2 entry #2: 0x8000000000070000 0000000000004000
+write -q -z 156k 2k
+L2 entry #2: 0x8000000000070000 0000400000000000
+write -q -P PATTERN 192k 34k
+L2 entry #3: 0x8000000000080000 000000000001ffff
+write -q -P PATTERN 24k 192k
+L2 entry #0: 0x8000000000050000 00000000fffff000
+L2 entry #1: 0x8000000000060000 00000000ffffffff
+L2 entry #2: 0x8000000000070000 00000000ffffffff
+L2 entry #3: 0x8000000000080000 000000000001ffff
+
+### Writing zeroes 1: unallocated clusters (backing file: yes) ###
+
+Formatting 'TEST_DIR/t.IMGFMT.raw', fmt=raw size=2132992
+Formatting 'TEST_DIR/t.IMGFMT.base', fmt=raw size=2132992
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2132992 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
+write -q -z 0 192k
+L2 entry #0: 0x0000000000000000 ffffffff00000000
+L2 entry #1: 0x0000000000000000 ffffffff00000000
+L2 entry #2: 0x0000000000000000 ffffffff00000000
+write -q -z 224k 128k
+L2 entry #3: 0x0000000000000000 ffff000000000000
+L2 entry #4: 0x0000000000000000 ffffffff00000000
+L2 entry #5: 0x0000000000000000 0000ffff00000000
+write -q -z 415k 128k
+L2 entry #6: 0x8000000000050000 ffff000000008000
+L2 entry #7: 0x0000000000000000 ffffffff00000000
+L2 entry #8: 0x8000000000060000 00007fff00008000
+
+### Writing zeroes 2: allocated clusters (backing file: yes) ###
+
+write -q -P PATTERN 576k 576k
+L2 entry #9: 0x8000000000070000 00000000ffffffff
+L2 entry #10: 0x8000000000080000 00000000ffffffff
+L2 entry #11: 0x8000000000090000 00000000ffffffff
+L2 entry #12: 0x80000000000a0000 00000000ffffffff
+L2 entry #13: 0x80000000000b0000 00000000ffffffff
+L2 entry #14: 0x80000000000c0000 00000000ffffffff
+L2 entry #15: 0x80000000000d0000 00000000ffffffff
+L2 entry #16: 0x80000000000e0000 00000000ffffffff
+L2 entry #17: 0x80000000000f0000 00000000ffffffff
+write -q -z 576k 192k
+L2 entry #9: 0x8000000000070000 ffffffff00000000
+L2 entry #10: 0x8000000000080000 ffffffff00000000
+L2 entry #11: 0x8000000000090000 ffffffff00000000
+write -q -z 800k 128k
+L2 entry #12: 0x80000000000a0000 ffff00000000ffff
+L2 entry #13: 0x80000000000b0000 ffffffff00000000
+L2 entry #14: 0x80000000000c0000 0000ffffffff0000
+write -q -z 991k 128k
+L2 entry #15: 0x80000000000d0000 ffff00000000ffff
+L2 entry #16: 0x80000000000e0000 ffffffff00000000
+L2 entry #17: 0x80000000000f0000 00007fffffff8000
+
+### Writing zeroes 3: compressed clusters (backing file: yes) ###
+
+write -q -c -P PATTERN 1152k 64k
+L2 entry #18: 0x4000000000100000 0000000000000000
+write -q -c -P PATTERN 1216k 64k
+L2 entry #19: 0x4000000000110000 0000000000000000
+write -q -c -P PATTERN 1280k 64k
+L2 entry #20: 0x4000000000120000 0000000000000000
+write -q -c -P PATTERN 1344k 64k
+L2 entry #21: 0x4000000000130000 0000000000000000
+write -q -c -P PATTERN 1408k 64k
+L2 entry #22: 0x4000000000140000 0000000000000000
+write -q -c -P PATTERN 1472k 64k
+L2 entry #23: 0x4000000000150000 0000000000000000
+write -q -c -P PATTERN 1536k 64k
+L2 entry #24: 0x4000000000160000 0000000000000000
+write -q -c -P PATTERN 1600k 64k
+L2 entry #25: 0x4000000000170000 0000000000000000
+write -q -c -P PATTERN 1664k 64k
+L2 entry #26: 0x4000000000180000 0000000000000000
+write -q -c -P PATTERN 1728k 64k
+L2 entry #27: 0x4000000000190000 0000000000000000
+write -q -c -P PATTERN 1792k 64k
+L2 entry #28: 0x40000000001a0000 0000000000000000
+write -q -z 1152k 192k
+L2 entry #18: 0x0000000000000000 ffffffff00000000
+L2 entry #19: 0x0000000000000000 ffffffff00000000
+L2 entry #20: 0x0000000000000000 ffffffff00000000
+write -q -z 1376k 128k
+L2 entry #21: 0x8000000000100000 00000000ffffffff
+L2 entry #22: 0x8000000000110000 00000000ffffffff
+L2 entry #23: 0x8000000000120000 00000000ffffffff
+write -q -z 1567k 129k
+L2 entry #24: 0x8000000000130000 00000000ffffffff
+L2 entry #25: 0x8000000000140000 00000000ffffffff
+L2 entry #26: 0x8000000000150000 00000000ffffffff
+write -q -z 1759k 128k
+L2 entry #27: 0x8000000000160000 ffff00000000ffff
+L2 entry #28: 0x0000000000000000 ffffffff00000000
+L2 entry #29: 0x8000000000170000 00007fff00008000
+
+### Writing zeroes 4: other tests (backing file: yes) ###
+
+write -q -z 1951k 8k
+L2 entry #30: 0x8000000000180000 0007000000088000
+write -q -z 2048k 35k
+L2 entry #32: 0x0000000000000000 0003ffff00000000
+
+### Writing zeroes 1: unallocated clusters (backing file: no) ###
+
+Formatting 'TEST_DIR/t.IMGFMT.raw', fmt=raw size=2132992
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2132992
+write -q -z 0 192k
+L2 entry #0: 0x0000000000000000 ffffffff00000000
+L2 entry #1: 0x0000000000000000 ffffffff00000000
+L2 entry #2: 0x0000000000000000 ffffffff00000000
+write -q -z 224k 128k
+L2 entry #3: 0x0000000000000000 ffff000000000000
+L2 entry #4: 0x0000000000000000 ffffffff00000000
+L2 entry #5: 0x0000000000000000 0000ffff00000000
+write -q -z 415k 128k
+L2 entry #6: 0x0000000000000000 ffff800000000000
+L2 entry #7: 0x0000000000000000 ffffffff00000000
+L2 entry #8: 0x0000000000000000 0000ffff00000000
+
+### Writing zeroes 2: allocated clusters (backing file: no) ###
+
+write -q -P PATTERN 576k 576k
+L2 entry #9: 0x8000000000050000 00000000ffffffff
+L2 entry #10: 0x8000000000060000 00000000ffffffff
+L2 entry #11: 0x8000000000070000 00000000ffffffff
+L2 entry #12: 0x8000000000080000 00000000ffffffff
+L2 entry #13: 0x8000000000090000 00000000ffffffff
+L2 entry #14: 0x80000000000a0000 00000000ffffffff
+L2 entry #15: 0x80000000000b0000 00000000ffffffff
+L2 entry #16: 0x80000000000c0000 00000000ffffffff
+L2 entry #17: 0x80000000000d0000 00000000ffffffff
+write -q -z 576k 192k
+L2 entry #9: 0x8000000000050000 ffffffff00000000
+L2 entry #10: 0x8000000000060000 ffffffff00000000
+L2 entry #11: 0x8000000000070000 ffffffff00000000
+write -q -z 800k 128k
+L2 entry #12: 0x8000000000080000 ffff00000000ffff
+L2 entry #13: 0x8000000000090000 ffffffff00000000
+L2 entry #14: 0x80000000000a0000 0000ffffffff0000
+write -q -z 991k 128k
+L2 entry #15: 0x80000000000b0000 ffff00000000ffff
+L2 entry #16: 0x80000000000c0000 ffffffff00000000
+L2 entry #17: 0x80000000000d0000 00007fffffff8000
+
+### Writing zeroes 3: compressed clusters (backing file: no) ###
+
+write -q -c -P PATTERN 1152k 64k
+L2 entry #18: 0x40000000000e0000 0000000000000000
+write -q -c -P PATTERN 1216k 64k
+L2 entry #19: 0x40000000000f0000 0000000000000000
+write -q -c -P PATTERN 1280k 64k
+L2 entry #20: 0x4000000000100000 0000000000000000
+write -q -c -P PATTERN 1344k 64k
+L2 entry #21: 0x4000000000110000 0000000000000000
+write -q -c -P PATTERN 1408k 64k
+L2 entry #22: 0x4000000000120000 0000000000000000
+write -q -c -P PATTERN 1472k 64k
+L2 entry #23: 0x4000000000130000 0000000000000000
+write -q -c -P PATTERN 1536k 64k
+L2 entry #24: 0x4000000000140000 0000000000000000
+write -q -c -P PATTERN 1600k 64k
+L2 entry #25: 0x4000000000150000 0000000000000000
+write -q -c -P PATTERN 1664k 64k
+L2 entry #26: 0x4000000000160000 0000000000000000
+write -q -c -P PATTERN 1728k 64k
+L2 entry #27: 0x4000000000170000 0000000000000000
+write -q -c -P PATTERN 1792k 64k
+L2 entry #28: 0x4000000000180000 0000000000000000
+write -q -z 1152k 192k
+L2 entry #18: 0x0000000000000000 ffffffff00000000
+L2 entry #19: 0x0000000000000000 ffffffff00000000
+L2 entry #20: 0x0000000000000000 ffffffff00000000
+write -q -z 1376k 128k
+L2 entry #21: 0x80000000000e0000 00000000ffffffff
+L2 entry #22: 0x80000000000f0000 00000000ffffffff
+L2 entry #23: 0x8000000000100000 00000000ffffffff
+write -q -z 1567k 129k
+L2 entry #24: 0x8000000000110000 00000000ffffffff
+L2 entry #25: 0x8000000000120000 00000000ffffffff
+L2 entry #26: 0x8000000000130000 00000000ffffffff
+write -q -z 1759k 128k
+L2 entry #27: 0x8000000000140000 ffff00000000ffff
+L2 entry #28: 0x0000000000000000 ffffffff00000000
+L2 entry #29: 0x0000000000000000 0000ffff00000000
+
+### Writing zeroes 4: other tests (backing file: no) ###
+
+write -q -z 1951k 8k
+L2 entry #30: 0x0000000000000000 000f800000000000
+write -q -z 2048k 35k
+L2 entry #32: 0x0000000000000000 0003ffff00000000
+
+### Zero + unmap 1: allocated clusters (backing file: yes) ###
+
+Formatting 'TEST_DIR/t.IMGFMT.raw', fmt=raw size=2132992
+Formatting 'TEST_DIR/t.IMGFMT.base', fmt=raw size=2132992
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2132992 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
+write -q -P PATTERN 576k 576k
+L2 entry #9: 0x8000000000050000 00000000ffffffff
+L2 entry #10: 0x8000000000060000 00000000ffffffff
+L2 entry #11: 0x8000000000070000 00000000ffffffff
+L2 entry #12: 0x8000000000080000 00000000ffffffff
+L2 entry #13: 0x8000000000090000 00000000ffffffff
+L2 entry #14: 0x80000000000a0000 00000000ffffffff
+L2 entry #15: 0x80000000000b0000 00000000ffffffff
+L2 entry #16: 0x80000000000c0000 00000000ffffffff
+L2 entry #17: 0x80000000000d0000 00000000ffffffff
+write -q -z -u 576k 192k
+L2 entry #9: 0x0000000000000000 ffffffff00000000
+L2 entry #10: 0x0000000000000000 ffffffff00000000
+L2 entry #11: 0x0000000000000000 ffffffff00000000
+write -q -z -u 800k 128k
+L2 entry #12: 0x8000000000080000 ffff00000000ffff
+L2 entry #13: 0x0000000000000000 ffffffff00000000
+L2 entry #14: 0x80000000000a0000 0000ffffffff0000
+write -q -z -u 991k 128k
+L2 entry #15: 0x80000000000b0000 ffff00000000ffff
+L2 entry #16: 0x0000000000000000 ffffffff00000000
+L2 entry #17: 0x80000000000d0000 00007fffffff8000
+
+### Zero + unmap 2: compressed clusters (backing file: yes) ###
+
+write -q -c -P PATTERN 1152k 64k
+L2 entry #18: 0x4000000000050000 0000000000000000
+write -q -c -P PATTERN 1216k 64k
+L2 entry #19: 0x4000000000060000 0000000000000000
+write -q -c -P PATTERN 1280k 64k
+L2 entry #20: 0x4000000000070000 0000000000000000
+write -q -c -P PATTERN 1344k 64k
+L2 entry #21: 0x4000000000090000 0000000000000000
+write -q -c -P PATTERN 1408k 64k
+L2 entry #22: 0x40000000000c0000 0000000000000000
+write -q -c -P PATTERN 1472k 64k
+L2 entry #23: 0x40000000000e0000 0000000000000000
+write -q -c -P PATTERN 1536k 64k
+L2 entry #24: 0x40000000000f0000 0000000000000000
+write -q -c -P PATTERN 1600k 64k
+L2 entry #25: 0x4000000000100000 0000000000000000
+write -q -c -P PATTERN 1664k 64k
+L2 entry #26: 0x4000000000110000 0000000000000000
+write -q -c -P PATTERN 1728k 64k
+L2 entry #27: 0x4000000000120000 0000000000000000
+write -q -c -P PATTERN 1792k 64k
+L2 entry #28: 0x4000000000130000 0000000000000000
+write -q -z -u 1152k 192k
+L2 entry #18: 0x0000000000000000 ffffffff00000000
+L2 entry #19: 0x0000000000000000 ffffffff00000000
+L2 entry #20: 0x0000000000000000 ffffffff00000000
+write -q -z -u 1376k 128k
+L2 entry #21: 0x8000000000050000 00000000ffffffff
+L2 entry #22: 0x8000000000060000 00000000ffffffff
+L2 entry #23: 0x8000000000070000 00000000ffffffff
+write -q -z -u 1567k 129k
+L2 entry #24: 0x8000000000090000 00000000ffffffff
+L2 entry #25: 0x80000000000e0000 00000000ffffffff
+L2 entry #26: 0x80000000000f0000 00000000ffffffff
+write -q -z -u 1759k 128k
+L2 entry #27: 0x80000000000c0000 ffff00000000ffff
+L2 entry #28: 0x0000000000000000 ffffffff00000000
+L2 entry #29: 0x8000000000100000 00007fff00008000
+
+### Zero + unmap 1: allocated clusters (backing file: no) ###
+
+Formatting 'TEST_DIR/t.IMGFMT.raw', fmt=raw size=2132992
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2132992
+write -q -P PATTERN 576k 576k
+L2 entry #9: 0x8000000000050000 00000000ffffffff
+L2 entry #10: 0x8000000000060000 00000000ffffffff
+L2 entry #11: 0x8000000000070000 00000000ffffffff
+L2 entry #12: 0x8000000000080000 00000000ffffffff
+L2 entry #13: 0x8000000000090000 00000000ffffffff
+L2 entry #14: 0x80000000000a0000 00000000ffffffff
+L2 entry #15: 0x80000000000b0000 00000000ffffffff
+L2 entry #16: 0x80000000000c0000 00000000ffffffff
+L2 entry #17: 0x80000000000d0000 00000000ffffffff
+write -q -z -u 576k 192k
+L2 entry #9: 0x0000000000000000 ffffffff00000000
+L2 entry #10: 0x0000000000000000 ffffffff00000000
+L2 entry #11: 0x0000000000000000 ffffffff00000000
+write -q -z -u 800k 128k
+L2 entry #12: 0x8000000000080000 ffff00000000ffff
+L2 entry #13: 0x0000000000000000 ffffffff00000000
+L2 entry #14: 0x80000000000a0000 0000ffffffff0000
+write -q -z -u 991k 128k
+L2 entry #15: 0x80000000000b0000 ffff00000000ffff
+L2 entry #16: 0x0000000000000000 ffffffff00000000
+L2 entry #17: 0x80000000000d0000 00007fffffff8000
+
+### Zero + unmap 2: compressed clusters (backing file: no) ###
+
+write -q -c -P PATTERN 1152k 64k
+L2 entry #18: 0x4000000000050000 0000000000000000
+write -q -c -P PATTERN 1216k 64k
+L2 entry #19: 0x4000000000060000 0000000000000000
+write -q -c -P PATTERN 1280k 64k
+L2 entry #20: 0x4000000000070000 0000000000000000
+write -q -c -P PATTERN 1344k 64k
+L2 entry #21: 0x4000000000090000 0000000000000000
+write -q -c -P PATTERN 1408k 64k
+L2 entry #22: 0x40000000000c0000 0000000000000000
+write -q -c -P PATTERN 1472k 64k
+L2 entry #23: 0x40000000000e0000 0000000000000000
+write -q -c -P PATTERN 1536k 64k
+L2 entry #24: 0x40000000000f0000 0000000000000000
+write -q -c -P PATTERN 1600k 64k
+L2 entry #25: 0x4000000000100000 0000000000000000
+write -q -c -P PATTERN 1664k 64k
+L2 entry #26: 0x4000000000110000 0000000000000000
+write -q -c -P PATTERN 1728k 64k
+L2 entry #27: 0x4000000000120000 0000000000000000
+write -q -c -P PATTERN 1792k 64k
+L2 entry #28: 0x4000000000130000 0000000000000000
+write -q -z -u 1152k 192k
+L2 entry #18: 0x0000000000000000 ffffffff00000000
+L2 entry #19: 0x0000000000000000 ffffffff00000000
+L2 entry #20: 0x0000000000000000 ffffffff00000000
+write -q -z -u 1376k 128k
+L2 entry #21: 0x8000000000050000 00000000ffffffff
+L2 entry #22: 0x8000000000060000 00000000ffffffff
+L2 entry #23: 0x8000000000070000 00000000ffffffff
+write -q -z -u 1567k 129k
+L2 entry #24: 0x8000000000090000 00000000ffffffff
+L2 entry #25: 0x80000000000e0000 00000000ffffffff
+L2 entry #26: 0x80000000000f0000 00000000ffffffff
+write -q -z -u 1759k 128k
+L2 entry #27: 0x80000000000c0000 ffff00000000ffff
+L2 entry #28: 0x0000000000000000 ffffffff00000000
+L2 entry #29: 0x0000000000000000 0000ffff00000000
+
+### Discarding clusters with non-zero bitmaps (backing file: yes) ###
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
+L2 entry #0: 0x0000000000000000 ffffffff00000000
+L2 entry #1: 0x0000000000000000 ffffffff00000000
+Image resized.
+Image resized.
+L2 entry #0: 0x0000000000000000 ffffffff00000000
+L2 entry #1: 0x0000000000000000 ffffffff00000000
+
+### Discarding clusters with non-zero bitmaps (backing file: no) ###
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+L2 entry #0: 0x0000000000000000 ffffffff00000000
+L2 entry #1: 0x0000000000000000 ffffffff00000000
+Image resized.
+Image resized.
+L2 entry #0: 0x0000000000000000 0000ffff00000000
+L2 entry #1: 0x0000000000000000 0000000000000000
+
+### Corrupted L2 entries - read test (allocated) ###
+
+# 'cluster is zero' bit set on the standard cluster descriptor
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+L2 entry #0: 0x8000000000050001 0000000000000001
+L2 entry #0: 0x8000000000050001 0000000000000001
+
+# Both 'subcluster is zero' and 'subcluster is allocated' bits set
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+L2 entry #1: 0x8000000000060000 00000001ffffffff
+qcow2: Marking image as corrupt: Invalid cluster entry found (L2 offset: 0x40000, L2 index: 0x1); further corruption events will be suppressed
+read failed: Input/output error
+
+### Corrupted L2 entries - read test (unallocated) ###
+
+# 'cluster is zero' bit set on the standard cluster descriptor
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+L2 entry #0: 0x0000000000000001 0000000000000000
+L2 entry #0: 0x0000000000000001 0000000000000000
+
+# 'subcluster is allocated' bit set
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+L2 entry #0: 0x0000000000000000 0000000000000001
+qcow2: Marking image as corrupt: Invalid cluster entry found (L2 offset: 0x40000, L2 index: 0); further corruption events will be suppressed
+read failed: Input/output error
+
+# Both 'subcluster is zero' and 'subcluster is allocated' bits set
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+L2 entry #1: 0x0000000000000000 0000000100000001
+qcow2: Marking image as corrupt: Invalid cluster entry found (L2 offset: 0x40000, L2 index: 0x1); further corruption events will be suppressed
+read failed: Input/output error
+
+### Compressed cluster with subcluster bitmap != 0 - read test ###
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+L2 entry #0: 0x4000000000050000 0000000180000000
+read 65536/65536 bytes at offset 0
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+L2 entry #0: 0x4000000000050000 0000000180000000
+
+### Corrupted L2 entries - write test (allocated) ###
+
+# 'cluster is zero' bit set on the standard cluster descriptor
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+L2 entry #0: 0x8000000000050001 0000000000000001
+L2 entry #0: 0x8000000000050001 0000000000000001
+
+# Both 'subcluster is zero' and 'subcluster is allocated' bits set
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+L2 entry #1: 0x8000000000060000 00000001ffffffff
+qcow2: Marking image as corrupt: Invalid cluster entry found (L2 offset: 0x40000, L2 index: 0x1); further corruption events will be suppressed
+write failed: Input/output error
+
+### Corrupted L2 entries - write test (unallocated) ###
+
+# 'cluster is zero' bit set on the standard cluster descriptor
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+L2 entry #0: 0x0000000000000001 0000000000000000
+L2 entry #0: 0x8000000000060000 0000000000000001
+
+# 'subcluster is allocated' bit set
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+L2 entry #0: 0x0000000000000000 0000000000000001
+qcow2: Marking image as corrupt: Invalid cluster entry found (L2 offset: 0x40000, L2 index: 0); further corruption events will be suppressed
+write failed: Input/output error
+
+# Both 'subcluster is zero' and 'subcluster is allocated' bits set
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+L2 entry #1: 0x0000000000000000 0000000100000001
+qcow2: Marking image as corrupt: Invalid cluster entry found (L2 offset: 0x40000, L2 index: 0x1); further corruption events will be suppressed
+write failed: Input/output error
+
+### Compressed cluster with subcluster bitmap != 0 - write test ###
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+L2 entry #0: 0x4000000000050000 0000000180000000
+wrote 65536/65536 bytes at offset 0
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+L2 entry #0: 0x8000000000060000 00000000ffffffff
+
+### Detect and repair unaligned clusters ###
+
+Formatting 'TEST_DIR/t.IMGFMT.base', fmt=raw size=131072
+# Corrupted L2 entry, allocated subcluster #
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=131072 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
+ERROR offset=50200: Data cluster is not properly aligned; L2 entry corrupted.
+ERROR cluster 6 refcount=0 reference=1
+Rebuilding refcount structure
+ERROR offset=50200: Data cluster is not properly aligned; L2 entry corrupted.
+Repairing cluster 1 refcount=1 reference=0
+Repairing cluster 2 refcount=1 reference=0
+ERROR offset=50200: Data cluster is not properly aligned; L2 entry corrupted.
+The following inconsistencies were found and repaired:
+
+ 0 leaked clusters
+ 1 corruptions
+
+Double checking the fixed image now...
+
+1 errors were found on the image.
+Data may be corrupted, or further writes to the image may corrupt it.
+qcow2: Marking image as corrupt: Cluster allocation offset 0x50200 unaligned (L2 offset: 0x40000, L2 index: 0); further corruption events will be suppressed
+read failed: Input/output error
+# Corrupted L2 entry, no allocated subclusters #
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=131072 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
+Repairing offset=50200: Preallocated cluster is not properly aligned; L2 entry corrupted.
+Leaked cluster 5 refcount=1 reference=0
+Repairing cluster 5 refcount=1 reference=0
+The following inconsistencies were found and repaired:
+
+ 1 leaked clusters
+ 1 corruptions
+
+Double checking the fixed image now...
+No errors were found on the image.
+
+### Image creation options ###
+
+# cluster_size < 16k
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+qemu-img: TEST_DIR/t.IMGFMT: Extended L2 entries are only supported with cluster sizes of at least 16384 bytes
+# backing file and preallocation=metadata
+Formatting 'TEST_DIR/t.IMGFMT.base', fmt=raw size=1048576
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=524288 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw preallocation=metadata
+Image resized.
+read 524288/524288 bytes at offset 0
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 524288/524288 bytes at offset 524288
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Offset Length Mapped to File
+0 0x80000 0 TEST_DIR/t.qcow2.base
+# backing file and preallocation=falloc
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=524288 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw preallocation=falloc
+Image resized.
+read 524288/524288 bytes at offset 0
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 524288/524288 bytes at offset 524288
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Offset Length Mapped to File
+0 0x80000 0 TEST_DIR/t.qcow2.base
+# backing file and preallocation=full
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=524288 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw preallocation=full
+Image resized.
+read 524288/524288 bytes at offset 0
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 524288/524288 bytes at offset 524288
+512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Offset Length Mapped to File
+0 0x80000 0 TEST_DIR/t.qcow2.base
+
+### Image resizing with preallocation and backing files ###
+
+# resize --preallocation=metadata
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=515072 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
+Image resized.
+read 515072/515072 bytes at offset 0
+503 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 522240/522240 bytes at offset 515072
+510 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+# resize --preallocation=falloc
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=515072 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
+Image resized.
+read 515072/515072 bytes at offset 0
+503 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 522240/522240 bytes at offset 515072
+510 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+# resize --preallocation=full
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=515072 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=raw
+Image resized.
+read 515072/515072 bytes at offset 0
+503 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 522240/522240 bytes at offset 515072
+510 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+### Image resizing with preallocation without backing files ###
+
+# resize --preallocation=metadata
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=515072
+wrote 515072/515072 bytes at offset 0
+503 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Image resized.
+read 515072/515072 bytes at offset 0
+503 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 522240/522240 bytes at offset 515072
+510 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+# resize --preallocation=falloc
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=515072
+wrote 515072/515072 bytes at offset 0
+503 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Image resized.
+read 515072/515072 bytes at offset 0
+503 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 522240/522240 bytes at offset 515072
+510 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+# resize --preallocation=full
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=515072
+wrote 515072/515072 bytes at offset 0
+503 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Image resized.
+read 515072/515072 bytes at offset 0
+503 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 522240/522240 bytes at offset 515072
+510 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+### qemu-img measure ###
+
+# 512MB, extended_l2=off
+required size: 327680
+fully allocated size: 537198592
+# 512MB, extended_l2=on
+required size: 393216
+fully allocated size: 537264128
+# 16K clusters, 64GB, extended_l2=off
+required size: 42008576
+fully allocated size: 68761485312
+# 16K clusters, 64GB, extended_l2=on
+required size: 75579392
+fully allocated size: 68795056128
+# 8k clusters
+qemu-img: Extended L2 entries are only supported with cluster sizes of at least 16384 bytes
+# 1024 TB
+required size: 309285027840
+fully allocated size: 1126209191870464
+# 1025 TB
+qemu-img: The image size is too large (try using a larger cluster size)
+
+### qemu-img amend ###
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+qemu-img: Invalid parameter 'extended_l2'
+This option is only supported for image creation
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+qemu-img: Invalid parameter 'extended_l2'
+This option is only supported for image creation
+
+### Test copy-on-write on an image with snapshots ###
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+L2 entry #0: 0x8000000000050000 0000008000042000
+L2 entry #1: 0x8000000000060000 0000008000042000
+L2 entry #2: 0x8000000000070000 0000008000042000
+L2 entry #3: 0x8000000000080000 0000008000042000
+L2 entry #4: 0x8000000000090000 0000008000042000
+L2 entry #5: 0x80000000000a0000 0000008000042000
+L2 entry #6: 0x80000000000b0000 0000008000042000
+L2 entry #7: 0x80000000000c0000 0000008000042000
+L2 entry #8: 0x80000000000d0000 0000008000042000
+L2 entry #9: 0x80000000000e0000 0000008000042000
+L2 entry #0: 0x8000000000120000 000000800007e000
+L2 entry #1: 0x8000000000130000 000000800007fc00
+L2 entry #2: 0x8000000000140000 00000080001fe000
+L2 entry #3: 0x8000000000150000 000000800007e000
+L2 entry #4: 0x8000000000160000 000000000007ff80
+L2 entry #5: 0x8000000000170000 000000000007ffff
+L2 entry #6: 0x00000000000b0000 0001808000042000
+L2 entry #7: 0x00000000000c0000 0000208000040000
+L2 entry #8: 0x8000000000180000 000000800007e000
+L2 entry #9: 0x00000000000e0000 000000c000042000
+
+### Test concurrent requests ###
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
+blkdebug: Suspended request 'A'
+blkdebug: Resuming request 'A'
+wrote 2048/2048 bytes at offset 30720
+2 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 2048/2048 bytes at offset 20480
+2 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 2048/2048 bytes at offset 40960
+2 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+*** done
diff --git a/tests/qemu-iotests/274.out b/tests/qemu-iotests/274.out
index 3a36fe7dfd..bf5abd4c10 100644
--- a/tests/qemu-iotests/274.out
+++ b/tests/qemu-iotests/274.out
@@ -1,9 +1,9 @@
== Commit tests ==
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=2097152 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/PID-mid', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1048576 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-mid', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1048576 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=2097152 backing_file=TEST_DIR/PID-mid backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 backing_file=TEST_DIR/PID-mid backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
wrote 2097152/2097152 bytes at offset 0
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -57,6 +57,7 @@ Format specific information:
lazy refcounts: false
refcount bits: 16
corrupt: false
+ extended l2: false
read 1048576/1048576 bytes at offset 0
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -65,11 +66,11 @@ read 1048576/1048576 bytes at offset 1048576
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
=== Testing HMP commit (top -> mid) ===
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=2097152 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/PID-mid', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1048576 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-mid', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1048576 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=2097152 backing_file=TEST_DIR/PID-mid backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 backing_file=TEST_DIR/PID-mid backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
wrote 2097152/2097152 bytes at offset 0
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -88,6 +89,7 @@ Format specific information:
lazy refcounts: false
refcount bits: 16
corrupt: false
+ extended l2: false
read 1048576/1048576 bytes at offset 0
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -96,11 +98,11 @@ read 1048576/1048576 bytes at offset 1048576
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
=== Testing QMP active commit (top -> mid) ===
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=2097152 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/PID-mid', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1048576 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-mid', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1048576 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=2097152 backing_file=TEST_DIR/PID-mid backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=2097152 backing_file=TEST_DIR/PID-mid backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
wrote 2097152/2097152 bytes at offset 0
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -125,6 +127,7 @@ Format specific information:
lazy refcounts: false
refcount bits: 16
corrupt: false
+ extended l2: false
read 1048576/1048576 bytes at offset 0
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -134,9 +137,9 @@ read 1048576/1048576 bytes at offset 1048576
== Resize tests ==
=== preallocation=off ===
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=6442450944 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=6442450944 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=1073741824 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=1073741824 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
wrote 65536/65536 bytes at offset 5368709120
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -153,9 +156,9 @@ read 65536/65536 bytes at offset 5368709120
{ "start": 1073741824, "length": 7516192768, "depth": 0, "zero": true, "data": false}]
=== preallocation=metadata ===
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=34359738368 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=34359738368 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=32212254720 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=32212254720 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
wrote 65536/65536 bytes at offset 33285996544
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -177,9 +180,9 @@ read 65536/65536 bytes at offset 33285996544
{ "start": 34896609280, "length": 536870912, "depth": 0, "zero": true, "data": false, "offset": 2685075456}]
=== preallocation=falloc ===
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=10485760 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=10485760 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=5242880 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=5242880 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
wrote 65536/65536 bytes at offset 9437184
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -196,9 +199,9 @@ read 65536/65536 bytes at offset 9437184
{ "start": 5242880, "length": 10485760, "depth": 0, "zero": false, "data": true, "offset": 327680}]
=== preallocation=full ===
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=16777216 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=16777216 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=8388608 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=8388608 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
wrote 65536/65536 bytes at offset 11534336
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -215,9 +218,9 @@ read 65536/65536 bytes at offset 11534336
{ "start": 8388608, "length": 4194304, "depth": 0, "zero": false, "data": true, "offset": 327680}]
=== preallocation=off ===
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=393216 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=393216 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=259072 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=259072 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
wrote 65536/65536 bytes at offset 259072
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -235,9 +238,9 @@ read 65536/65536 bytes at offset 259072
{ "start": 262144, "length": 262144, "depth": 0, "zero": true, "data": false}]
=== preallocation=off ===
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=409600 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=409600 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=262144 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=262144 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
wrote 65536/65536 bytes at offset 344064
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -254,9 +257,9 @@ read 65536/65536 bytes at offset 344064
{ "start": 262144, "length": 262144, "depth": 0, "zero": true, "data": false}]
=== preallocation=off ===
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=524288 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=524288 lazy_refcounts=off refcount_bits=16
-Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 compression_type=zlib size=262144 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-top', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=262144 backing_file=TEST_DIR/PID-base backing_fmt=qcow2 lazy_refcounts=off refcount_bits=16
wrote 65536/65536 bytes at offset 446464
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
diff --git a/tests/qemu-iotests/280.out b/tests/qemu-iotests/280.out
index fc59b9bc5c..09a0f1a7cb 100644
--- a/tests/qemu-iotests/280.out
+++ b/tests/qemu-iotests/280.out
@@ -1,4 +1,4 @@
-Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+Formatting 'TEST_DIR/PID-base', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
=== Launch VM ===
Enabling migration QMP events on VM...
diff --git a/tests/qemu-iotests/291.out b/tests/qemu-iotests/291.out
index 9f661515b4..ee89a72885 100644
--- a/tests/qemu-iotests/291.out
+++ b/tests/qemu-iotests/291.out
@@ -41,6 +41,7 @@ Format specific information:
granularity: 65536
refcount bits: 16
corrupt: false
+ extended l2: false
image: TEST_DIR/t.IMGFMT
file format: IMGFMT
virtual size: 10 MiB (10485760 bytes)
@@ -65,6 +66,7 @@ Format specific information:
granularity: 65536
refcount bits: 16
corrupt: false
+ extended l2: false
=== Check bitmap contents ===
diff --git a/tests/qemu-iotests/300 b/tests/qemu-iotests/300
new file mode 100755
index 0000000000..5b75121b84
--- /dev/null
+++ b/tests/qemu-iotests/300
@@ -0,0 +1,593 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) 2020 Red Hat, Inc.
+#
+# Tests for dirty bitmaps migration with node aliases
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import os
+import random
+import re
+from typing import Dict, List, Optional, Union
+import iotests
+import qemu
+
+BlockBitmapMapping = List[Dict[str, Union[str, List[Dict[str, str]]]]]
+
+assert iotests.sock_dir is not None
+mig_sock = os.path.join(iotests.sock_dir, 'mig_sock')
+
+
+class TestDirtyBitmapMigration(iotests.QMPTestCase):
+ src_node_name: str = ''
+ dst_node_name: str = ''
+ src_bmap_name: str = ''
+ dst_bmap_name: str = ''
+
+ def setUp(self) -> None:
+ self.vm_a = iotests.VM(path_suffix='-a')
+ self.vm_a.add_blockdev(f'node-name={self.src_node_name},'
+ 'driver=null-co')
+ self.vm_a.launch()
+
+ self.vm_b = iotests.VM(path_suffix='-b')
+ self.vm_b.add_blockdev(f'node-name={self.dst_node_name},'
+ 'driver=null-co')
+ self.vm_b.add_incoming(f'unix:{mig_sock}')
+ self.vm_b.launch()
+
+ result = self.vm_a.qmp('block-dirty-bitmap-add',
+ node=self.src_node_name,
+ name=self.src_bmap_name)
+ self.assert_qmp(result, 'return', {})
+
+ # Dirty some random megabytes
+ for _ in range(9):
+ mb_ofs = random.randrange(1024)
+ self.vm_a.hmp_qemu_io(self.src_node_name, f'discard {mb_ofs}M 1M')
+
+ result = self.vm_a.qmp('x-debug-block-dirty-bitmap-sha256',
+ node=self.src_node_name,
+ name=self.src_bmap_name)
+ self.bitmap_hash_reference = result['return']['sha256']
+
+ caps = [{'capability': name, 'state': True}
+ for name in ('dirty-bitmaps', 'events')]
+
+ for vm in (self.vm_a, self.vm_b):
+ result = vm.qmp('migrate-set-capabilities', capabilities=caps)
+ self.assert_qmp(result, 'return', {})
+
+ def tearDown(self) -> None:
+ self.vm_a.shutdown()
+ self.vm_b.shutdown()
+ try:
+ os.remove(mig_sock)
+ except OSError:
+ pass
+
+ def check_bitmap(self, bitmap_name_valid: bool) -> None:
+ result = self.vm_b.qmp('x-debug-block-dirty-bitmap-sha256',
+ node=self.dst_node_name,
+ name=self.dst_bmap_name)
+ if bitmap_name_valid:
+ self.assert_qmp(result, 'return/sha256',
+ self.bitmap_hash_reference)
+ else:
+ self.assert_qmp(result, 'error/desc',
+ f"Dirty bitmap '{self.dst_bmap_name}' not found")
+
+ def migrate(self, bitmap_name_valid: bool = True,
+ migration_success: bool = True) -> None:
+ result = self.vm_a.qmp('migrate', uri=f'unix:{mig_sock}')
+ self.assert_qmp(result, 'return', {})
+
+ with iotests.Timeout(5, 'Timeout waiting for migration to complete'):
+ self.assertEqual(self.vm_a.wait_migration('postmigrate'),
+ migration_success)
+ self.assertEqual(self.vm_b.wait_migration('running'),
+ migration_success)
+
+ if migration_success:
+ self.check_bitmap(bitmap_name_valid)
+
+ def verify_dest_error(self, msg: Optional[str]) -> None:
+ """
+ Check whether the given error message is present in vm_b's log.
+ (vm_b is shut down to do so.)
+ If @msg is None, check that there has not been any error.
+ """
+ self.vm_b.shutdown()
+ if msg is None:
+ self.assertNotIn('qemu-system-', self.vm_b.get_log())
+ else:
+ self.assertIn(msg, self.vm_b.get_log())
+
+ @staticmethod
+ def mapping(node_name: str, node_alias: str,
+ bitmap_name: str, bitmap_alias: str) -> BlockBitmapMapping:
+ return [{
+ 'node-name': node_name,
+ 'alias': node_alias,
+ 'bitmaps': [{
+ 'name': bitmap_name,
+ 'alias': bitmap_alias
+ }]
+ }]
+
+ def set_mapping(self, vm: iotests.VM, mapping: BlockBitmapMapping,
+ error: Optional[str] = None) -> None:
+ """
+ Invoke migrate-set-parameters on @vm to set the given @mapping.
+ Check for success if @error is None, or verify the error message
+ if it is not.
+ On success, verify that "info migrate_parameters" on HMP returns
+ our mapping. (Just to check its formatting code.)
+ """
+ result = vm.qmp('migrate-set-parameters',
+ block_bitmap_mapping=mapping)
+
+ if error is None:
+ self.assert_qmp(result, 'return', {})
+
+ result = vm.qmp('human-monitor-command',
+ command_line='info migrate_parameters')
+
+ m = re.search(r'^block-bitmap-mapping:\r?(\n .*)*\n',
+ result['return'], flags=re.MULTILINE)
+ hmp_mapping = m.group(0).replace('\r', '') if m else None
+
+ self.assertEqual(hmp_mapping, self.to_hmp_mapping(mapping))
+ else:
+ self.assert_qmp(result, 'error/desc', error)
+
+ @staticmethod
+ def to_hmp_mapping(mapping: BlockBitmapMapping) -> str:
+ result = 'block-bitmap-mapping:\n'
+
+ for node in mapping:
+ result += f" '{node['node-name']}' -> '{node['alias']}'\n"
+
+ assert isinstance(node['bitmaps'], list)
+ for bitmap in node['bitmaps']:
+ result += f" '{bitmap['name']}' -> '{bitmap['alias']}'\n"
+
+ return result
+
+
+class TestAliasMigration(TestDirtyBitmapMigration):
+ src_node_name = 'node0'
+ dst_node_name = 'node0'
+ src_bmap_name = 'bmap0'
+ dst_bmap_name = 'bmap0'
+
+ def test_migration_without_alias(self) -> None:
+ self.migrate(self.src_node_name == self.dst_node_name and
+ self.src_bmap_name == self.dst_bmap_name)
+
+ # Check for error message on the destination
+ if self.src_node_name != self.dst_node_name:
+ self.verify_dest_error(f"Cannot find "
+ f"device={self.src_node_name} nor "
+ f"node_name={self.src_node_name}")
+ else:
+ self.verify_dest_error(None)
+
+ def test_alias_on_src_migration(self) -> None:
+ mapping = self.mapping(self.src_node_name, self.dst_node_name,
+ self.src_bmap_name, self.dst_bmap_name)
+
+ self.set_mapping(self.vm_a, mapping)
+ self.migrate()
+ self.verify_dest_error(None)
+
+ def test_alias_on_dst_migration(self) -> None:
+ mapping = self.mapping(self.dst_node_name, self.src_node_name,
+ self.dst_bmap_name, self.src_bmap_name)
+
+ self.set_mapping(self.vm_b, mapping)
+ self.migrate()
+ self.verify_dest_error(None)
+
+ def test_alias_on_both_migration(self) -> None:
+ src_map = self.mapping(self.src_node_name, 'node-alias',
+ self.src_bmap_name, 'bmap-alias')
+
+ dst_map = self.mapping(self.dst_node_name, 'node-alias',
+ self.dst_bmap_name, 'bmap-alias')
+
+ self.set_mapping(self.vm_a, src_map)
+ self.set_mapping(self.vm_b, dst_map)
+ self.migrate()
+ self.verify_dest_error(None)
+
+
+class TestNodeAliasMigration(TestAliasMigration):
+ src_node_name = 'node-src'
+ dst_node_name = 'node-dst'
+
+
+class TestBitmapAliasMigration(TestAliasMigration):
+ src_bmap_name = 'bmap-src'
+ dst_bmap_name = 'bmap-dst'
+
+
+class TestFullAliasMigration(TestAliasMigration):
+ src_node_name = 'node-src'
+ dst_node_name = 'node-dst'
+ src_bmap_name = 'bmap-src'
+ dst_bmap_name = 'bmap-dst'
+
+
+class TestLongBitmapNames(TestAliasMigration):
+ # Giving long bitmap names is OK, as long as there is a short alias for
+ # migration
+ src_bmap_name = 'a' * 512
+ dst_bmap_name = 'b' * 512
+
+ # Skip all tests that do not use the intermediate alias
+ def test_migration_without_alias(self) -> None:
+ pass
+
+ def test_alias_on_src_migration(self) -> None:
+ pass
+
+ def test_alias_on_dst_migration(self) -> None:
+ pass
+
+
+class TestBlockBitmapMappingErrors(TestDirtyBitmapMigration):
+ src_node_name = 'node0'
+ dst_node_name = 'node0'
+ src_bmap_name = 'bmap0'
+ dst_bmap_name = 'bmap0'
+
+ """
+ Note that mapping nodes or bitmaps that do not exist is not an error.
+ """
+
+ def test_non_injective_node_mapping(self) -> None:
+ mapping: BlockBitmapMapping = [
+ {
+ 'node-name': 'node0',
+ 'alias': 'common-alias',
+ 'bitmaps': [{
+ 'name': 'bmap0',
+ 'alias': 'bmap-alias0'
+ }]
+ },
+ {
+ 'node-name': 'node1',
+ 'alias': 'common-alias',
+ 'bitmaps': [{
+ 'name': 'bmap1',
+ 'alias': 'bmap-alias1'
+ }]
+ }
+ ]
+
+ self.set_mapping(self.vm_a, mapping,
+ "Invalid mapping given for block-bitmap-mapping: "
+ "The node alias 'common-alias' is used twice")
+
+ def test_non_injective_bitmap_mapping(self) -> None:
+ mapping: BlockBitmapMapping = [{
+ 'node-name': 'node0',
+ 'alias': 'node-alias0',
+ 'bitmaps': [
+ {
+ 'name': 'bmap0',
+ 'alias': 'common-alias'
+ },
+ {
+ 'name': 'bmap1',
+ 'alias': 'common-alias'
+ }
+ ]
+ }]
+
+ self.set_mapping(self.vm_a, mapping,
+ "Invalid mapping given for block-bitmap-mapping: "
+ "The bitmap alias 'node-alias0'/'common-alias' is "
+ "used twice")
+
+ def test_ambiguous_node_mapping(self) -> None:
+ mapping: BlockBitmapMapping = [
+ {
+ 'node-name': 'node0',
+ 'alias': 'node-alias0',
+ 'bitmaps': [{
+ 'name': 'bmap0',
+ 'alias': 'bmap-alias0'
+ }]
+ },
+ {
+ 'node-name': 'node0',
+ 'alias': 'node-alias1',
+ 'bitmaps': [{
+ 'name': 'bmap0',
+ 'alias': 'bmap-alias0'
+ }]
+ }
+ ]
+
+ self.set_mapping(self.vm_a, mapping,
+ "Invalid mapping given for block-bitmap-mapping: "
+ "The node name 'node0' is mapped twice")
+
+ def test_ambiguous_bitmap_mapping(self) -> None:
+ mapping: BlockBitmapMapping = [{
+ 'node-name': 'node0',
+ 'alias': 'node-alias0',
+ 'bitmaps': [
+ {
+ 'name': 'bmap0',
+ 'alias': 'bmap-alias0'
+ },
+ {
+ 'name': 'bmap0',
+ 'alias': 'bmap-alias1'
+ }
+ ]
+ }]
+
+ self.set_mapping(self.vm_a, mapping,
+ "Invalid mapping given for block-bitmap-mapping: "
+ "The bitmap 'node0'/'bmap0' is mapped twice")
+
+ def test_migratee_node_is_not_mapped_on_src(self) -> None:
+ self.set_mapping(self.vm_a, [])
+ # Should just ignore all bitmaps on unmapped nodes
+ self.migrate(False)
+ self.verify_dest_error(None)
+
+ def test_migratee_node_is_not_mapped_on_dst(self) -> None:
+ self.set_mapping(self.vm_b, [])
+ self.migrate(False)
+ self.verify_dest_error(f"Unknown node alias '{self.src_node_name}'")
+
+ def test_migratee_bitmap_is_not_mapped_on_src(self) -> None:
+ mapping: BlockBitmapMapping = [{
+ 'node-name': self.src_node_name,
+ 'alias': self.dst_node_name,
+ 'bitmaps': []
+ }]
+
+ self.set_mapping(self.vm_a, mapping)
+ # Should just ignore all unmapped bitmaps
+ self.migrate(False)
+ self.verify_dest_error(None)
+
+ def test_migratee_bitmap_is_not_mapped_on_dst(self) -> None:
+ mapping: BlockBitmapMapping = [{
+ 'node-name': self.dst_node_name,
+ 'alias': self.src_node_name,
+ 'bitmaps': []
+ }]
+
+ self.set_mapping(self.vm_b, mapping)
+ self.migrate(False)
+ self.verify_dest_error(f"Unknown bitmap alias "
+ f"'{self.src_bmap_name}' "
+ f"on node '{self.dst_node_name}' "
+ f"(alias '{self.src_node_name}')")
+
+ def test_unused_mapping_on_dst(self) -> None:
+ # Let the source not send any bitmaps
+ self.set_mapping(self.vm_a, [])
+
+ # Establish some mapping on the destination
+ self.set_mapping(self.vm_b, [])
+
+ # The fact that there is a mapping on B without any bitmaps
+ # being received should be fine, not fatal
+ self.migrate(False)
+ self.verify_dest_error(None)
+
+ def test_non_wellformed_node_alias(self) -> None:
+ alias = '123-foo'
+
+ mapping: BlockBitmapMapping = [{
+ 'node-name': self.src_node_name,
+ 'alias': alias,
+ 'bitmaps': []
+ }]
+
+ self.set_mapping(self.vm_a, mapping,
+ f"Invalid mapping given for block-bitmap-mapping: "
+ f"The node alias '{alias}' is not well-formed")
+
+ def test_node_alias_too_long(self) -> None:
+ alias = 'a' * 256
+
+ mapping: BlockBitmapMapping = [{
+ 'node-name': self.src_node_name,
+ 'alias': alias,
+ 'bitmaps': []
+ }]
+
+ self.set_mapping(self.vm_a, mapping,
+ f"Invalid mapping given for block-bitmap-mapping: "
+ f"The node alias '{alias}' is longer than 255 bytes")
+
+ def test_bitmap_alias_too_long(self) -> None:
+ alias = 'a' * 256
+
+ mapping = self.mapping(self.src_node_name, self.dst_node_name,
+ self.src_bmap_name, alias)
+
+ self.set_mapping(self.vm_a, mapping,
+ f"Invalid mapping given for block-bitmap-mapping: "
+ f"The bitmap alias '{alias}' is longer than 255 "
+ f"bytes")
+
+ def test_bitmap_name_too_long(self) -> None:
+ name = 'a' * 256
+
+ result = self.vm_a.qmp('block-dirty-bitmap-add',
+ node=self.src_node_name,
+ name=name)
+ self.assert_qmp(result, 'return', {})
+
+ self.migrate(False, False)
+
+ # Check for the error in the source's log
+ self.vm_a.shutdown()
+ self.assertIn(f"Cannot migrate bitmap '{name}' on node "
+ f"'{self.src_node_name}': Name is longer than 255 bytes",
+ self.vm_a.get_log())
+
+ # Expect abnormal shutdown of the destination VM because of
+ # the failed migration
+ try:
+ self.vm_b.shutdown()
+ except qemu.machine.AbnormalShutdown:
+ pass
+
+ def test_aliased_bitmap_name_too_long(self) -> None:
+ # Longer than the maximum for bitmap names
+ self.dst_bmap_name = 'a' * 1024
+
+ mapping = self.mapping(self.dst_node_name, self.src_node_name,
+ self.dst_bmap_name, self.src_bmap_name)
+
+ # We would have to create this bitmap during migration, and
+ # that would fail, because the name is too long. Better to
+ # catch it early.
+ self.set_mapping(self.vm_b, mapping,
+ f"Invalid mapping given for block-bitmap-mapping: "
+ f"The bitmap name '{self.dst_bmap_name}' is longer "
+ f"than 1023 bytes")
+
+ def test_node_name_too_long(self) -> None:
+ # Longer than the maximum for node names
+ self.dst_node_name = 'a' * 32
+
+ mapping = self.mapping(self.dst_node_name, self.src_node_name,
+ self.dst_bmap_name, self.src_bmap_name)
+
+ # During migration, this would appear simply as a node that
+ # cannot be found. Still better to catch impossible node
+ # names early (similar to test_non_wellformed_node_alias).
+ self.set_mapping(self.vm_b, mapping,
+ f"Invalid mapping given for block-bitmap-mapping: "
+ f"The node name '{self.dst_node_name}' is longer "
+ f"than 31 bytes")
+
+
+class TestCrossAliasMigration(TestDirtyBitmapMigration):
+ """
+ Swap aliases, both to see that qemu does not get confused, and
+ that we can migrate multiple things at once.
+
+ So we migrate this:
+ node-a.bmap-a -> node-b.bmap-b
+ node-a.bmap-b -> node-b.bmap-a
+ node-b.bmap-a -> node-a.bmap-b
+ node-b.bmap-b -> node-a.bmap-a
+ """
+
+ src_node_name = 'node-a'
+ dst_node_name = 'node-b'
+ src_bmap_name = 'bmap-a'
+ dst_bmap_name = 'bmap-b'
+
+ def setUp(self) -> None:
+ TestDirtyBitmapMigration.setUp(self)
+
+ # Now create another block device and let both have two bitmaps each
+ result = self.vm_a.qmp('blockdev-add',
+ node_name='node-b', driver='null-co')
+ self.assert_qmp(result, 'return', {})
+
+ result = self.vm_b.qmp('blockdev-add',
+ node_name='node-a', driver='null-co')
+ self.assert_qmp(result, 'return', {})
+
+ bmaps_to_add = (('node-a', 'bmap-b'),
+ ('node-b', 'bmap-a'),
+ ('node-b', 'bmap-b'))
+
+ for (node, bmap) in bmaps_to_add:
+ result = self.vm_a.qmp('block-dirty-bitmap-add',
+ node=node, name=bmap)
+ self.assert_qmp(result, 'return', {})
+
+ @staticmethod
+ def cross_mapping() -> BlockBitmapMapping:
+ return [
+ {
+ 'node-name': 'node-a',
+ 'alias': 'node-b',
+ 'bitmaps': [
+ {
+ 'name': 'bmap-a',
+ 'alias': 'bmap-b'
+ },
+ {
+ 'name': 'bmap-b',
+ 'alias': 'bmap-a'
+ }
+ ]
+ },
+ {
+ 'node-name': 'node-b',
+ 'alias': 'node-a',
+ 'bitmaps': [
+ {
+ 'name': 'bmap-b',
+ 'alias': 'bmap-a'
+ },
+ {
+ 'name': 'bmap-a',
+ 'alias': 'bmap-b'
+ }
+ ]
+ }
+ ]
+
+ def verify_dest_has_all_bitmaps(self) -> None:
+ bitmaps = self.vm_b.query_bitmaps()
+
+ # Extract and sort bitmap names
+ for node in bitmaps:
+ bitmaps[node] = sorted((bmap['name'] for bmap in bitmaps[node]))
+
+ self.assertEqual(bitmaps,
+ {'node-a': ['bmap-a', 'bmap-b'],
+ 'node-b': ['bmap-a', 'bmap-b']})
+
+ def test_alias_on_src(self) -> None:
+ self.set_mapping(self.vm_a, self.cross_mapping())
+
+ # Checks that node-a.bmap-a was migrated to node-b.bmap-b, and
+ # that is enough
+ self.migrate()
+ self.verify_dest_has_all_bitmaps()
+ self.verify_dest_error(None)
+
+ def test_alias_on_dst(self) -> None:
+ self.set_mapping(self.vm_b, self.cross_mapping())
+
+ # Checks that node-a.bmap-a was migrated to node-b.bmap-b, and
+ # that is enough
+ self.migrate()
+ self.verify_dest_has_all_bitmaps()
+ self.verify_dest_error(None)
+
+
+if __name__ == '__main__':
+ iotests.main(supported_protocols=['file'])
diff --git a/tests/qemu-iotests/300.out b/tests/qemu-iotests/300.out
new file mode 100644
index 0000000000..cafb8161f7
--- /dev/null
+++ b/tests/qemu-iotests/300.out
@@ -0,0 +1,5 @@
+.....................................
+----------------------------------------------------------------------
+Ran 37 tests
+
+OK
diff --git a/tests/qemu-iotests/302 b/tests/qemu-iotests/302
new file mode 100755
index 0000000000..a8506bda15
--- /dev/null
+++ b/tests/qemu-iotests/302
@@ -0,0 +1,127 @@
+#!/usr/bin/env python3
+#
+# Tests converting qcow2 compressed to NBD
+#
+# Copyright (c) 2020 Nir Soffer <nirsof@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# owner=nirsof@gmail.com
+
+import io
+import tarfile
+
+import iotests
+
+from iotests import (
+ file_path,
+ qemu_img,
+ qemu_img_check,
+ qemu_img_create,
+ qemu_img_log,
+ qemu_img_measure,
+ qemu_io,
+ qemu_nbd_popen,
+)
+
+iotests.script_initialize(supported_fmts=["qcow2"])
+
+# Create source disk. Using qcow2 to enable strict comparing later, and
+# avoid issues with random filesystem on CI environment.
+src_disk = file_path("disk.qcow2")
+qemu_img_create("-f", iotests.imgfmt, src_disk, "1g")
+qemu_io("-f", iotests.imgfmt, "-c", "write 1m 64k", src_disk)
+
+# The use case is writing qcow2 image directly into an ova file, which
+# is a tar file with specific layout. This is tricky since we don't know the
+# size of the image before compressing, so we have to do:
+# 1. Add an ovf file.
+# 2. Find the offset of the next member data.
+# 3. Make room for image data, allocating for the worst case.
+# 4. Write compressed image data into the tar.
+# 5. Add a tar entry with the actual image size.
+# 6. Shrink the tar to the actual size, aligned to 512 bytes.
+
+tar_file = file_path("test.ova")
+
+with tarfile.open(tar_file, "w") as tar:
+
+ # 1. Add an ovf file.
+
+ ovf_data = b"<xml/>"
+ ovf = tarfile.TarInfo("vm.ovf")
+ ovf.size = len(ovf_data)
+ tar.addfile(ovf, io.BytesIO(ovf_data))
+
+ # 2. Find the offset of the next member data.
+
+ offset = tar.fileobj.tell() + 512
+
+ # 3. Make room for image data, allocating for the worst case.
+
+ measure = qemu_img_measure("-O", "qcow2", src_disk)
+ tar.fileobj.truncate(offset + measure["required"])
+
+ # 4. Write compressed image data into the tar.
+
+ nbd_sock = file_path("nbd-sock", base_dir=iotests.sock_dir)
+ nbd_uri = "nbd+unix:///exp?socket=" + nbd_sock
+
+ # Use raw format to allow creating qcow2 directly into tar file.
+ with qemu_nbd_popen(
+ "--socket", nbd_sock,
+ "--export-name", "exp",
+ "--format", "raw",
+ "--offset", str(offset),
+ tar_file):
+
+ iotests.log("=== Target image info ===")
+ qemu_img_log("info", nbd_uri)
+
+ qemu_img(
+ "convert",
+ "-f", iotests.imgfmt,
+ "-O", "qcow2",
+ "-c",
+ src_disk,
+ nbd_uri)
+
+ iotests.log("=== Converted image info ===")
+ qemu_img_log("info", nbd_uri)
+
+ iotests.log("=== Converted image check ===")
+ qemu_img_log("check", nbd_uri)
+
+ iotests.log("=== Comparing to source disk ===")
+ qemu_img_log("compare", src_disk, nbd_uri)
+
+ actual_size = qemu_img_check(nbd_uri)["image-end-offset"]
+
+ # 5. Add a tar entry with the actual image size.
+
+ disk = tarfile.TarInfo("disk")
+ disk.size = actual_size
+ tar.addfile(disk)
+
+ # 6. Shrink the tar to the actual size, aligned to 512 bytes.
+
+ tar_size = offset + (disk.size + 511) & ~511
+ tar.fileobj.seek(tar_size)
+ tar.fileobj.truncate(tar_size)
+
+with tarfile.open(tar_file) as tar:
+ members = [{"name": m.name, "size": m.size, "offset": m.offset_data}
+ for m in tar]
+ iotests.log("=== OVA file contents ===")
+ iotests.log(members)
diff --git a/tests/qemu-iotests/302.out b/tests/qemu-iotests/302.out
new file mode 100644
index 0000000000..e2f6077e83
--- /dev/null
+++ b/tests/qemu-iotests/302.out
@@ -0,0 +1,32 @@
+Start NBD server
+=== Target image info ===
+image: nbd+unix:///exp?socket=SOCK_DIR/PID-nbd-sock
+file format: raw
+virtual size: 448 KiB (458752 bytes)
+disk size: unavailable
+
+=== Converted image info ===
+image: nbd+unix:///exp?socket=SOCK_DIR/PID-nbd-sock
+file format: qcow2
+virtual size: 1 GiB (1073741824 bytes)
+disk size: unavailable
+cluster_size: 65536
+Format specific information:
+ compat: 1.1
+ compression type: zlib
+ lazy refcounts: false
+ refcount bits: 16
+ corrupt: false
+ extended l2: false
+
+=== Converted image check ===
+No errors were found on the image.
+1/16384 = 0.01% allocated, 100.00% fragmented, 100.00% compressed clusters
+Image end offset: 393216
+
+=== Comparing to source disk ===
+Images are identical.
+
+Kill NBD server
+=== OVA file contents ===
+[{"name": "vm.ovf", "offset": 512, "size": 6}, {"name": "disk", "offset": 1536, "size": 393216}]
diff --git a/tests/qemu-iotests/303 b/tests/qemu-iotests/303
new file mode 100755
index 0000000000..6c21774483
--- /dev/null
+++ b/tests/qemu-iotests/303
@@ -0,0 +1,63 @@
+#!/usr/bin/env python3
+#
+# Test for dumping of qcow2 image metadata
+#
+# Copyright (c) 2020 Virtuozzo International GmbH
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import iotests
+import subprocess
+from iotests import qemu_img_create, qemu_io, file_path, log, filter_qemu_io
+
+iotests.script_initialize(supported_fmts=['qcow2'])
+
+disk = file_path('disk')
+chunk = 1024 * 1024
+
+
+def create_bitmap(bitmap_number, disabled):
+ granularity = 1 << (14 + bitmap_number)
+ bitmap_name = 'bitmap-' + str(bitmap_number)
+ args = ['bitmap', '--add', '-g', f'{granularity}', '-f', iotests.imgfmt,
+ disk, bitmap_name]
+ if disabled:
+ args.append('--disable')
+
+ iotests.qemu_img_pipe(*args)
+
+
+def write_to_disk(offset, size):
+ write = f'write {offset} {size}'
+ log(qemu_io('-c', write, disk), filters=[filter_qemu_io])
+
+
+def add_bitmap(num, begin, end, disabled):
+ log(f'Add bitmap {num}')
+ create_bitmap(num, disabled)
+ for i in range(begin, end):
+ write_to_disk((i) * chunk, chunk)
+ log('')
+
+
+qemu_img_create('-f', iotests.imgfmt, disk, '10M')
+
+add_bitmap(1, 0, 6, False)
+add_bitmap(2, 6, 8, True)
+dump = ['qcow2.py', disk, 'dump-header']
+subprocess.run(dump)
+# Dump the metadata in JSON format
+dump.append('-j')
+subprocess.run(dump)
diff --git a/tests/qemu-iotests/303.out b/tests/qemu-iotests/303.out
new file mode 100644
index 0000000000..7c16998587
--- /dev/null
+++ b/tests/qemu-iotests/303.out
@@ -0,0 +1,158 @@
+Add bitmap 1
+wrote 1048576/1048576 bytes at offset 0
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+wrote 1048576/1048576 bytes at offset 1048576
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+wrote 1048576/1048576 bytes at offset 2097152
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+wrote 1048576/1048576 bytes at offset 3145728
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+wrote 1048576/1048576 bytes at offset 4194304
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+wrote 1048576/1048576 bytes at offset 5242880
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+
+Add bitmap 2
+wrote 1048576/1048576 bytes at offset 6291456
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+wrote 1048576/1048576 bytes at offset 7340032
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+
+magic 0x514649fb
+version 3
+backing_file_offset 0x0
+backing_file_size 0x0
+cluster_bits 16
+size 10485760
+crypt_method 0
+l1_size 1
+l1_table_offset 0x30000
+refcount_table_offset 0x10000
+refcount_table_clusters 1
+nb_snapshots 0
+snapshot_offset 0x0
+incompatible_features []
+compatible_features []
+autoclear_features [0]
+refcount_order 4
+header_length 112
+
+Header extension:
+magic 0x6803f857 (Feature table)
+length 384
+data <binary>
+
+Header extension:
+magic 0x23852875 (Bitmaps)
+length 24
+nb_bitmaps 2
+reserved32 0
+bitmap_directory_size 0x40
+bitmap_directory_offset 0x9d0000
+
+Bitmap name bitmap-1
+bitmap_table_offset 0x9b0000
+bitmap_table_size 1
+flags 0x2 (['auto'])
+type 1
+granularity_bits 15
+name_size 8
+extra_data_size 0
+Bitmap table type size offset
+0 serialized 65536 10092544
+
+Bitmap name bitmap-2
+bitmap_table_offset 0x9c0000
+bitmap_table_size 1
+flags 0x0 ([])
+type 1
+granularity_bits 16
+name_size 8
+extra_data_size 0
+Bitmap table type size offset
+0 all-zeroes 0 0
+
+{
+ "magic": 1363560955,
+ "version": 3,
+ "backing_file_offset": 0,
+ "backing_file_size": 0,
+ "cluster_bits": 16,
+ "size": 10485760,
+ "crypt_method": 0,
+ "l1_size": 1,
+ "l1_table_offset": 196608,
+ "refcount_table_offset": 65536,
+ "refcount_table_clusters": 1,
+ "nb_snapshots": 0,
+ "snapshot_offset": 0,
+ "incompatible_features": 0,
+ "compatible_features": 0,
+ "autoclear_features": 1,
+ "refcount_order": 4,
+ "header_length": 112
+}
+
+[
+ {
+ "name": "Feature table",
+ "magic": 1745090647,
+ "length": 384,
+ "data_str": "<binary>"
+ },
+ {
+ "name": "Bitmaps",
+ "magic": 595929205,
+ "length": 24,
+ "data": {
+ "nb_bitmaps": 2,
+ "reserved32": 0,
+ "bitmap_directory_size": 64,
+ "bitmap_directory_offset": 10289152,
+ "bitmap_directory": [
+ {
+ "name": "bitmap-1",
+ "bitmap_table_offset": 10158080,
+ "bitmap_table_size": 1,
+ "flags": 2,
+ "type": 1,
+ "granularity_bits": 15,
+ "name_size": 8,
+ "extra_data_size": 0,
+ "bitmap_table": [
+ {
+ "type": "serialized",
+ "offset": 10092544,
+ "reserved": 0
+ }
+ ]
+ },
+ {
+ "name": "bitmap-2",
+ "bitmap_table_offset": 10223616,
+ "bitmap_table_size": 1,
+ "flags": 0,
+ "type": 1,
+ "granularity_bits": 16,
+ "name_size": 8,
+ "extra_data_size": 0,
+ "bitmap_table": [
+ {
+ "type": "all-zeroes",
+ "offset": 0,
+ "reserved": 0
+ }
+ ]
+ }
+ ]
+ }
+ }
+]
diff --git a/tests/qemu-iotests/304 b/tests/qemu-iotests/304
new file mode 100755
index 0000000000..aaf9e14617
--- /dev/null
+++ b/tests/qemu-iotests/304
@@ -0,0 +1,60 @@
+#!/usr/bin/env python3
+#
+# Tests dirty-bitmap backup with unaligned bitmap granularity
+#
+# Copyright (c) 2020 Proxmox Server Solutions
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# owner=s.reiter@proxmox.com
+
+import iotests
+from iotests import qemu_img_create, qemu_img_log, file_path
+
+iotests.script_initialize(supported_fmts=['qcow2'],
+ supported_protocols=['file'])
+
+test_img = file_path('test.qcow2')
+target_img = file_path('target.qcow2')
+
+# unaligned by one byte
+image_len = 4097
+bitmap_granularity = 4096
+
+qemu_img_create('-f', iotests.imgfmt, test_img, str(image_len))
+
+# create VM
+vm = iotests.VM().add_drive(test_img)
+vm.launch()
+
+# write to the entire image
+vm.hmp_qemu_io('drive0', 'write -P0x16 0 4096');
+vm.hmp_qemu_io('drive0', 'write -P0x17 4096 1');
+
+# do backup and wait for completion
+vm.qmp('drive-backup', **{
+ 'device': 'drive0',
+ 'sync': 'full',
+ 'target': target_img
+})
+
+event = vm.event_wait(name='BLOCK_JOB_COMPLETED',
+ match={'data': {'device': 'drive0'}},
+ timeout=5.0)
+
+# shutdown to sync images
+vm.shutdown()
+
+# backup succeeded, check if image is correct
+qemu_img_log('compare', test_img, target_img)
diff --git a/tests/qemu-iotests/304.out b/tests/qemu-iotests/304.out
new file mode 100644
index 0000000000..381cc056f7
--- /dev/null
+++ b/tests/qemu-iotests/304.out
@@ -0,0 +1,2 @@
+Images are identical.
+
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index 0657f7286c..3ab859ac1a 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -577,11 +577,11 @@ if [ -z "$QEMU_PROG" ]
then
if [ -x "$build_iotests/qemu" ]; then
export QEMU_PROG="$build_iotests/qemu"
- elif [ -x "$build_root/${qemu_arch}-softmmu/qemu-system-${qemu_arch}" ]; then
- export QEMU_PROG="$build_root/${qemu_arch}-softmmu/qemu-system-${qemu_arch}"
+ elif [ -x "$build_root/qemu-system-${qemu_arch}" ]; then
+ export QEMU_PROG="$build_root/qemu-system-${qemu_arch}"
else
pushd "$build_root" > /dev/null
- for binary in *-softmmu/qemu-system-*
+ for binary in qemu-system-*
do
if [ -x "$binary" ]
then
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
index c6912be009..838ed15793 100644
--- a/tests/qemu-iotests/common.filter
+++ b/tests/qemu-iotests/common.filter
@@ -239,6 +239,7 @@ _filter_img_info()
-e "/adapter_type: '[^']*'/d" \
-e "/hwversion: '[^']*'/d" \
-e "/lazy_refcounts: \\(on\\|off\\)/d" \
+ -e "/extended_l2=\\(on\\|off\\)/d" \
-e "/block_size: [0-9]\\+/d" \
-e "/block_state_zero: \\(on\\|off\\)/d" \
-e "/log_size: [0-9]\\+/d" \
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index 806044642c..5cad015231 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -284,6 +284,7 @@
267 rw auto quick snapshot
268 rw auto quick
270 rw backing quick
+271 rw auto
272 rw
273 backing quick
274 rw backing
@@ -307,4 +308,8 @@
296 rw
297 meta
299 auto quick
+300 migration
301 backing quick
+302 quick
+303 rw quick
+304 rw quick
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 3590ed78a0..e197c73ca5 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -28,10 +28,13 @@ import signal
import struct
import subprocess
import sys
+import time
from typing import (Any, Callable, Dict, Iterable,
List, Optional, Sequence, Tuple, TypeVar)
import unittest
+from contextlib import contextmanager
+
# pylint: disable=import-error, wrong-import-position
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
from qemu import qtest
@@ -138,6 +141,12 @@ def qemu_img_create(*args):
return qemu_img(*args)
+def qemu_img_measure(*args):
+ return json.loads(qemu_img_pipe("measure", "--output", "json", *args))
+
+def qemu_img_check(*args):
+ return json.loads(qemu_img_pipe("check", "--output", "json", *args))
+
def qemu_img_verbose(*args):
'''Run qemu-img without suppressing its output and return the exit code'''
exitcode = subprocess.call(qemu_img_args + list(args))
@@ -270,9 +279,30 @@ def qemu_nbd_early_pipe(*args):
return subp.returncode, output if subp.returncode else ''
+@contextmanager
def qemu_nbd_popen(*args):
- '''Run qemu-nbd in daemon mode and return the parent's exit code'''
- return subprocess.Popen(qemu_nbd_args + ['--persistent'] + list(args))
+ '''Context manager running qemu-nbd within the context'''
+ pid_file = file_path("pid")
+
+ cmd = list(qemu_nbd_args)
+ cmd.extend(('--persistent', '--pid-file', pid_file))
+ cmd.extend(args)
+
+ log('Start NBD server')
+ p = subprocess.Popen(cmd)
+ try:
+ while not os.path.exists(pid_file):
+ if p.poll() is not None:
+ raise RuntimeError(
+ "qemu-nbd terminated with exit code {}: {}"
+ .format(p.returncode, ' '.join(cmd)))
+
+ time.sleep(0.01)
+ yield
+ finally:
+ log('Kill NBD server')
+ p.kill()
+ p.wait()
def compare_images(img1, img2, fmt1=imgfmt, fmt2=imgfmt):
'''Return True if two image files are identical'''
@@ -699,16 +729,22 @@ class VM(qtest.QEMUQtestMachine):
}
]))
- def wait_migration(self, expect_runstate):
+ def wait_migration(self, expect_runstate: Optional[str]) -> bool:
while True:
event = self.event_wait('MIGRATION')
log(event, filters=[filter_qmp_event])
- if event['data']['status'] == 'completed':
+ if event['data']['status'] in ('completed', 'failed'):
break
- # The event may occur in finish-migrate, so wait for the expected
- # post-migration runstate
- while self.qmp('query-status')['return']['status'] != expect_runstate:
- pass
+
+ if event['data']['status'] == 'completed':
+ # The event may occur in finish-migrate, so wait for the expected
+ # post-migration runstate
+ runstate = None
+ while runstate != expect_runstate:
+ runstate = self.qmp('query-status')['return']['status']
+ return True
+ else:
+ return False
def node_info(self, node_name):
nodes = self.qmp('query-named-block-nodes')
diff --git a/tests/qemu-iotests/meson.build b/tests/qemu-iotests/meson.build
new file mode 100644
index 0000000000..3de09fb8fa
--- /dev/null
+++ b/tests/qemu-iotests/meson.build
@@ -0,0 +1,10 @@
+if 'CONFIG_LINUX' in config_host
+ socket_scm_helper = executable('socket_scm_helper', 'socket_scm_helper.c',
+ build_by_default: false)
+else
+ socket_scm_helper = []
+endif
+test('qemu-iotests', sh, args: [files('../check-block.sh')],
+ depends: [qemu_block_tools, emulators, socket_scm_helper],
+ suite: 'block', timeout: 10000)
+
diff --git a/tests/qemu-iotests/qcow2.py b/tests/qemu-iotests/qcow2.py
index 0910e6ac07..77ca59cc66 100755
--- a/tests/qemu-iotests/qcow2.py
+++ b/tests/qemu-iotests/qcow2.py
@@ -26,16 +26,19 @@ from qcow2_format import (
)
+is_json = False
+
+
def cmd_dump_header(fd):
h = QcowHeader(fd)
- h.dump()
+ h.dump(is_json)
print()
- h.dump_extensions()
+ h.dump_extensions(is_json)
def cmd_dump_header_exts(fd):
h = QcowHeader(fd)
- h.dump_extensions()
+ h.dump_extensions(is_json)
def cmd_set_header(fd, name, value):
@@ -151,11 +154,14 @@ def main(filename, cmd, args):
def usage():
- print("Usage: %s <file> <cmd> [<arg>, ...]" % sys.argv[0])
+ print("Usage: %s <file> <cmd> [<arg>, ...] [<key>, ...]" % sys.argv[0])
print("")
print("Supported commands:")
for name, handler, num_args, desc in cmds:
print(" %-20s - %s" % (name, desc))
+ print("")
+ print("Supported keys:")
+ print(" %-20s - %s" % ('-j', 'Dump in JSON format'))
if __name__ == '__main__':
@@ -163,4 +169,8 @@ if __name__ == '__main__':
usage()
sys.exit(1)
+ is_json = '-j' in sys.argv
+ if is_json:
+ sys.argv.remove('-j')
+
main(sys.argv[1], sys.argv[2], sys.argv[3:])
diff --git a/tests/qemu-iotests/qcow2_format.py b/tests/qemu-iotests/qcow2_format.py
index cc432e7ae0..8adc9959e1 100644
--- a/tests/qemu-iotests/qcow2_format.py
+++ b/tests/qemu-iotests/qcow2_format.py
@@ -19,6 +19,15 @@
import struct
import string
+import json
+
+
+class ComplexEncoder(json.JSONEncoder):
+ def default(self, obj):
+ if hasattr(obj, 'to_json'):
+ return obj.to_json()
+ else:
+ return json.JSONEncoder.default(self, obj)
class Qcow2Field:
@@ -40,6 +49,22 @@ class Flags64(Qcow2Field):
return str(bits)
+class BitmapFlags(Qcow2Field):
+
+ flags = {
+ 0x1: 'in-use',
+ 0x2: 'auto'
+ }
+
+ def __str__(self):
+ bits = []
+ for bit in range(64):
+ flag = self.value & (1 << bit)
+ if flag:
+ bits.append(self.flags.get(flag, f'bit-{bit}'))
+ return f'{self.value:#x} ({bits})'
+
+
class Enum(Qcow2Field):
def __str__(self):
@@ -93,7 +118,11 @@ class Qcow2Struct(metaclass=Qcow2StructMeta):
self.__dict__ = dict((field[2], values[i])
for i, field in enumerate(self.fields))
- def dump(self):
+ def dump(self, is_json=False):
+ if is_json:
+ print(json.dumps(self.to_json(), indent=4, cls=ComplexEncoder))
+ return
+
for f in self.fields:
value = self.__dict__[f[2]]
if isinstance(f[1], str):
@@ -103,6 +132,9 @@ class Qcow2Struct(metaclass=Qcow2StructMeta):
print('{:<25} {}'.format(f[2], value_str))
+ def to_json(self):
+ return dict((f[2], self.__dict__[f[2]]) for f in self.fields)
+
class Qcow2BitmapExt(Qcow2Struct):
@@ -113,6 +145,131 @@ class Qcow2BitmapExt(Qcow2Struct):
('u64', '{:#x}', 'bitmap_directory_offset')
)
+ def __init__(self, fd, cluster_size):
+ super().__init__(fd=fd)
+ tail = struct.calcsize(self.fmt) % 8
+ if tail:
+ fd.seek(8 - tail, 1)
+ position = fd.tell()
+ self.cluster_size = cluster_size
+ self.read_bitmap_directory(fd)
+ fd.seek(position)
+
+ def read_bitmap_directory(self, fd):
+ fd.seek(self.bitmap_directory_offset)
+ self.bitmap_directory = \
+ [Qcow2BitmapDirEntry(fd, cluster_size=self.cluster_size)
+ for _ in range(self.nb_bitmaps)]
+
+ def dump(self):
+ super().dump()
+ for entry in self.bitmap_directory:
+ print()
+ entry.dump()
+
+ def to_json(self):
+ fields_dict = super().to_json()
+ fields_dict['bitmap_directory'] = self.bitmap_directory
+ return fields_dict
+
+
+class Qcow2BitmapDirEntry(Qcow2Struct):
+
+ fields = (
+ ('u64', '{:#x}', 'bitmap_table_offset'),
+ ('u32', '{}', 'bitmap_table_size'),
+ ('u32', BitmapFlags, 'flags'),
+ ('u8', '{}', 'type'),
+ ('u8', '{}', 'granularity_bits'),
+ ('u16', '{}', 'name_size'),
+ ('u32', '{}', 'extra_data_size')
+ )
+
+ def __init__(self, fd, cluster_size):
+ super().__init__(fd=fd)
+ self.cluster_size = cluster_size
+ # Seek relative to the current position in the file
+ fd.seek(self.extra_data_size, 1)
+ bitmap_name = fd.read(self.name_size)
+ self.name = bitmap_name.decode('ascii')
+ # Move position to the end of the entry in the directory
+ entry_raw_size = self.bitmap_dir_entry_raw_size()
+ padding = ((entry_raw_size + 7) & ~7) - entry_raw_size
+ fd.seek(padding, 1)
+ self.bitmap_table = Qcow2BitmapTable(fd=fd,
+ offset=self.bitmap_table_offset,
+ nb_entries=self.bitmap_table_size,
+ cluster_size=self.cluster_size)
+
+ def bitmap_dir_entry_raw_size(self):
+ return struct.calcsize(self.fmt) + self.name_size + \
+ self.extra_data_size
+
+ def dump(self):
+ print(f'{"Bitmap name":<25} {self.name}')
+ super(Qcow2BitmapDirEntry, self).dump()
+ self.bitmap_table.dump()
+
+ def to_json(self):
+ # Put the name ahead of the dict
+ return {
+ 'name': self.name,
+ **super().to_json(),
+ 'bitmap_table': self.bitmap_table
+ }
+
+
+class Qcow2BitmapTableEntry(Qcow2Struct):
+
+ fields = (
+ ('u64', '{}', 'entry'),
+ )
+
+ BME_TABLE_ENTRY_RESERVED_MASK = 0xff000000000001fe
+ BME_TABLE_ENTRY_OFFSET_MASK = 0x00fffffffffffe00
+ BME_TABLE_ENTRY_FLAG_ALL_ONES = 1
+
+ def __init__(self, fd):
+ super().__init__(fd=fd)
+ self.reserved = self.entry & self.BME_TABLE_ENTRY_RESERVED_MASK
+ self.offset = self.entry & self.BME_TABLE_ENTRY_OFFSET_MASK
+ if self.offset:
+ if self.entry & self.BME_TABLE_ENTRY_FLAG_ALL_ONES:
+ self.type = 'invalid'
+ else:
+ self.type = 'serialized'
+ elif self.entry & self.BME_TABLE_ENTRY_FLAG_ALL_ONES:
+ self.type = 'all-ones'
+ else:
+ self.type = 'all-zeroes'
+
+ def to_json(self):
+ return {'type': self.type, 'offset': self.offset,
+ 'reserved': self.reserved}
+
+
+class Qcow2BitmapTable:
+
+ def __init__(self, fd, offset, nb_entries, cluster_size):
+ self.cluster_size = cluster_size
+ position = fd.tell()
+ fd.seek(offset)
+ self.entries = [Qcow2BitmapTableEntry(fd) for _ in range(nb_entries)]
+ fd.seek(position)
+
+ def dump(self):
+ bitmap_table = enumerate(self.entries)
+ print(f'{"Bitmap table":<14} {"type":<15} {"size":<12} {"offset"}')
+ for i, entry in bitmap_table:
+ if entry.type == 'serialized':
+ size = self.cluster_size
+ else:
+ size = 0
+ print(f'{i:<14} {entry.type:<15} {size:<12} {entry.offset}')
+
+ def to_json(self):
+ return self.entries
+
QCOW2_EXT_MAGIC_BITMAPS = 0x23852875
@@ -128,6 +285,9 @@ class QcowHeaderExtension(Qcow2Struct):
0x44415441: 'Data file'
}
+ def to_json(self):
+ return self.mapping.get(self.value, "<unknown>")
+
fields = (
('u32', Magic, 'magic'),
('u32', '{}', 'length')
@@ -135,11 +295,13 @@ class QcowHeaderExtension(Qcow2Struct):
# then padding to next multiply of 8
)
- def __init__(self, magic=None, length=None, data=None, fd=None):
+ def __init__(self, magic=None, length=None, data=None, fd=None,
+ cluster_size=None):
"""
Support both loading from fd and creation from user data.
For fd-based creation current position in a file will be used to read
the data.
+ The cluster_size value may be obtained by dependent structures.
This should be somehow refactored and functionality should be moved to
superclass (to allow creation of any qcow2 struct), but then, fields
@@ -161,28 +323,43 @@ class QcowHeaderExtension(Qcow2Struct):
else:
assert all(v is None for v in (magic, length, data))
super().__init__(fd=fd)
- padded = (self.length + 7) & ~7
- self.data = fd.read(padded)
- assert self.data is not None
+ if self.magic == QCOW2_EXT_MAGIC_BITMAPS:
+ self.obj = Qcow2BitmapExt(fd=fd, cluster_size=cluster_size)
+ self.data = None
+ else:
+ padded = (self.length + 7) & ~7
+ self.data = fd.read(padded)
+ assert self.data is not None
+ self.obj = None
+
+ if self.data is not None:
+ data_str = self.data[:self.length]
+ if all(c in string.printable.encode(
+ 'ascii') for c in data_str):
+ data_str = f"'{ data_str.decode('ascii') }'"
+ else:
+ data_str = '<binary>'
+ self.data_str = data_str
- if self.magic == QCOW2_EXT_MAGIC_BITMAPS:
- self.obj = Qcow2BitmapExt(data=self.data)
- else:
- self.obj = None
def dump(self):
super().dump()
if self.obj is None:
- data = self.data[:self.length]
- if all(c in string.printable.encode('ascii') for c in data):
- data = f"'{ data.decode('ascii') }'"
- else:
- data = '<binary>'
- print(f'{"data":<25} {data}')
+ print(f'{"data":<25} {self.data_str}')
else:
self.obj.dump()
+ def to_json(self):
+ # Put the name ahead of the dict
+ res = {'name': self.Magic(self.magic), **super().to_json()}
+ if self.obj is not None:
+ res['data'] = self.obj
+ else:
+ res['data_str'] = self.data_str
+
+ return res
+
@classmethod
def create(cls, magic, data):
return QcowHeaderExtension(magic, len(data), data)
@@ -246,7 +423,7 @@ class QcowHeader(Qcow2Struct):
end = self.cluster_size
while fd.tell() < end:
- ext = QcowHeaderExtension(fd=fd)
+ ext = QcowHeaderExtension(fd=fd, cluster_size=self.cluster_size)
if ext.magic == 0:
break
else:
@@ -280,7 +457,11 @@ class QcowHeader(Qcow2Struct):
buf = buf[0:header_bytes-1]
fd.write(buf)
- def dump_extensions(self):
+ def dump_extensions(self, is_json=False):
+ if is_json:
+ print(json.dumps(self.extensions, indent=4, cls=ComplexEncoder))
+ return
+
for ex in self.extensions:
print('Header extension:')
ex.dump()
diff --git a/tests/qtest/Makefile.include b/tests/qtest/Makefile.include
deleted file mode 100644
index b0204e44f2..0000000000
--- a/tests/qtest/Makefile.include
+++ /dev/null
@@ -1,332 +0,0 @@
-# All QTests for now are POSIX-only, but the dependencies are
-# really in libqtest, not in the testcases themselves.
-
-check-qtest-generic-y += cdrom-test
-check-qtest-generic-y += device-introspect-test
-check-qtest-generic-y += machine-none-test
-check-qtest-generic-y += qmp-test
-check-qtest-generic-y += qmp-cmd-test
-check-qtest-generic-y += qom-test
-check-qtest-generic-$(CONFIG_MODULES) += modules-test
-check-qtest-generic-y += test-hmp
-
-check-qtest-pci-$(CONFIG_RTL8139_PCI) += rtl8139-test
-check-qtest-pci-$(CONFIG_VGA) += display-vga-test
-check-qtest-pci-$(CONFIG_HDA) += intel-hda-test
-check-qtest-pci-$(CONFIG_IVSHMEM_DEVICE) += ivshmem-test
-
-DBUS_DAEMON := $(shell which dbus-daemon 2>/dev/null)
-ifneq ($(GDBUS_CODEGEN),)
-ifneq ($(DBUS_DAEMON),)
-# Temporarily disabled due to Patchew failures:
-#check-qtest-pci-$(CONFIG_GIO) += dbus-vmstate-test
-endif
-endif
-
-check-qtest-i386-$(CONFIG_ISA_TESTDEV) = endianness-test
-check-qtest-i386-y += fdc-test
-check-qtest-i386-y += ide-test
-check-qtest-i386-$(CONFIG_TOOLS) += ahci-test
-check-qtest-i386-y += hd-geo-test
-check-qtest-i386-y += boot-order-test
-check-qtest-i386-y += bios-tables-test
-check-qtest-i386-$(CONFIG_SGA) += boot-serial-test
-check-qtest-i386-$(CONFIG_SLIRP) += pxe-test
-check-qtest-i386-y += rtc-test
-check-qtest-i386-$(CONFIG_ISA_IPMI_KCS) += ipmi-kcs-test
-ifdef CONFIG_LINUX
-check-qtest-i386-$(CONFIG_ISA_IPMI_BT) += ipmi-bt-test
-endif
-check-qtest-i386-y += i440fx-test
-check-qtest-i386-y += fw_cfg-test
-check-qtest-i386-y += device-plug-test
-check-qtest-i386-y += drive_del-test
-check-qtest-i386-$(CONFIG_WDT_IB700) += wdt_ib700-test
-check-qtest-i386-y += tco-test
-check-qtest-i386-y += $(check-qtest-pci-y)
-check-qtest-i386-$(CONFIG_PVPANIC) += pvpanic-test
-check-qtest-i386-$(CONFIG_I82801B11) += i82801b11-test
-check-qtest-i386-$(CONFIG_IOH3420) += ioh3420-test
-check-qtest-i386-$(CONFIG_USB_UHCI) += usb-hcd-uhci-test
-check-qtest-i386-$(call land,$(CONFIG_USB_EHCI),$(CONFIG_USB_UHCI)) += usb-hcd-ehci-test
-check-qtest-i386-$(CONFIG_USB_XHCI_NEC) += usb-hcd-xhci-test
-check-qtest-i386-y += cpu-plug-test
-check-qtest-i386-y += q35-test
-check-qtest-i386-y += vmgenid-test
-check-qtest-i386-$(CONFIG_TPM_CRB) += tpm-crb-swtpm-test
-check-qtest-i386-$(CONFIG_TPM_CRB) += tpm-crb-test
-check-qtest-i386-$(CONFIG_TPM_TIS_ISA) += tpm-tis-swtpm-test
-check-qtest-i386-$(CONFIG_TPM_TIS_ISA) += tpm-tis-test
-check-qtest-i386-$(CONFIG_SLIRP) += test-netfilter
-check-qtest-i386-$(CONFIG_POSIX) += test-filter-mirror
-check-qtest-i386-$(CONFIG_RTL8139_PCI) += test-filter-redirector
-check-qtest-i386-y += migration-test
-check-qtest-i386-y += test-x86-cpuid-compat
-check-qtest-i386-y += numa-test
-
-check-qtest-x86_64-y += $(check-qtest-i386-y)
-
-check-qtest-avr-y += boot-serial-test
-
-check-qtest-alpha-y += boot-serial-test
-check-qtest-alpha-$(CONFIG_VGA) += display-vga-test
-
-check-qtest-hppa-y += boot-serial-test
-check-qtest-hppa-$(CONFIG_VGA) += display-vga-test
-
-check-qtest-m68k-y = boot-serial-test
-
-check-qtest-microblaze-y += boot-serial-test
-
-check-qtest-mips-$(CONFIG_ISA_TESTDEV) = endianness-test
-check-qtest-mips-$(CONFIG_VGA) += display-vga-test
-
-check-qtest-mips64-$(CONFIG_ISA_TESTDEV) = endianness-test
-check-qtest-mips64-$(CONFIG_VGA) += display-vga-test
-
-check-qtest-mips64el-$(CONFIG_ISA_TESTDEV) = endianness-test
-check-qtest-mips64el-$(CONFIG_VGA) += display-vga-test
-
-check-qtest-moxie-y += boot-serial-test
-
-check-qtest-ppc-$(CONFIG_ISA_TESTDEV) = endianness-test
-check-qtest-ppc-y += boot-order-test
-check-qtest-ppc-y += prom-env-test
-check-qtest-ppc-y += drive_del-test
-check-qtest-ppc-y += boot-serial-test
-check-qtest-ppc-$(CONFIG_M48T59) += m48t59-test
-
-check-qtest-ppc64-y += $(check-qtest-ppc-y)
-check-qtest-ppc64-$(CONFIG_PSERIES) += device-plug-test
-check-qtest-ppc64-$(CONFIG_POWERNV) += pnv-xscom-test
-check-qtest-ppc64-y += migration-test
-check-qtest-ppc64-$(CONFIG_PSERIES) += rtas-test
-check-qtest-ppc64-$(CONFIG_SLIRP) += pxe-test
-check-qtest-ppc64-$(CONFIG_USB_UHCI) += usb-hcd-uhci-test
-check-qtest-ppc64-$(CONFIG_USB_XHCI_NEC) += usb-hcd-xhci-test
-check-qtest-ppc64-$(CONFIG_SLIRP) += test-netfilter
-check-qtest-ppc64-$(CONFIG_POSIX) += test-filter-mirror
-check-qtest-ppc64-$(CONFIG_RTL8139_PCI) += test-filter-redirector
-check-qtest-ppc64-$(CONFIG_VGA) += display-vga-test
-check-qtest-ppc64-y += numa-test
-check-qtest-ppc64-$(CONFIG_IVSHMEM_DEVICE) += ivshmem-test
-check-qtest-ppc64-y += cpu-plug-test
-
-check-qtest-sh4-$(CONFIG_ISA_TESTDEV) = endianness-test
-
-check-qtest-sh4eb-$(CONFIG_ISA_TESTDEV) = endianness-test
-
-check-qtest-sparc-y += prom-env-test
-check-qtest-sparc-y += m48t59-test
-check-qtest-sparc-y += boot-serial-test
-
-check-qtest-sparc64-$(CONFIG_ISA_TESTDEV) = endianness-test
-check-qtest-sparc64-y += prom-env-test
-check-qtest-sparc64-y += boot-serial-test
-
-check-qtest-arm-y += arm-cpu-features
-check-qtest-arm-y += microbit-test
-check-qtest-arm-y += m25p80-test
-check-qtest-arm-y += test-arm-mptimer
-check-qtest-arm-y += boot-serial-test
-check-qtest-arm-y += hexloader-test
-check-qtest-arm-$(CONFIG_PFLASH_CFI02) += pflash-cfi02-test
-
-check-qtest-aarch64-y += arm-cpu-features
-check-qtest-aarch64-$(CONFIG_TPM_TIS_SYSBUS) += tpm-tis-device-test
-check-qtest-aarch64-$(CONFIG_TPM_TIS_SYSBUS) += tpm-tis-device-swtpm-test
-check-qtest-aarch64-y += numa-test
-check-qtest-aarch64-y += boot-serial-test
-check-qtest-aarch64-y += migration-test
-
-# TODO: once aarch64 TCG is fixed on ARM 32 bit host, make test unconditional
-ifneq ($(ARCH),arm)
-check-qtest-aarch64-y += bios-tables-test
-endif
-
-check-qtest-microblazeel-y += $(check-qtest-microblaze-y)
-
-check-qtest-xtensaeb-y += $(check-qtest-xtensa-y)
-
-check-qtest-s390x-y = boot-serial-test
-check-qtest-s390x-$(CONFIG_SLIRP) += pxe-test
-check-qtest-s390x-$(CONFIG_SLIRP) += test-netfilter
-check-qtest-s390x-$(CONFIG_POSIX) += test-filter-mirror
-check-qtest-s390x-$(CONFIG_POSIX) += test-filter-redirector
-check-qtest-s390x-y += drive_del-test
-check-qtest-s390x-y += device-plug-test
-check-qtest-s390x-y += virtio-ccw-test
-check-qtest-s390x-y += cpu-plug-test
-check-qtest-s390x-y += migration-test
-
-# libqos / qgraph :
-libqgraph-obj-y = tests/qtest/libqos/qgraph.o
-
-libqos-core-obj-y = $(libqgraph-obj-y) tests/qtest/libqos/pci.o tests/qtest/libqos/fw_cfg.o
-libqos-core-obj-y += tests/qtest/libqos/malloc.o
-libqos-core-obj-y += tests/qtest/libqos/libqos.o
-libqos-spapr-obj-y = $(libqos-core-obj-y) tests/qtest/libqos/malloc-spapr.o
-libqos-spapr-obj-y += tests/qtest/libqos/libqos-spapr.o
-libqos-spapr-obj-y += tests/qtest/libqos/rtas.o
-libqos-spapr-obj-y += tests/qtest/libqos/pci-spapr.o
-libqos-pc-obj-y = $(libqos-core-obj-y) tests/qtest/libqos/pci-pc.o
-libqos-pc-obj-y += tests/qtest/libqos/malloc-pc.o tests/qtest/libqos/libqos-pc.o
-libqos-pc-obj-y += tests/qtest/libqos/ahci.o
-libqos-usb-obj-y = $(libqos-spapr-obj-y) $(libqos-pc-obj-y) tests/qtest/libqos/usb.o
-
-# qos devices:
-libqos-obj-y = $(libqgraph-obj-y)
-libqos-obj-y += $(libqos-pc-obj-y) $(libqos-spapr-obj-y)
-libqos-obj-y += tests/qtest/libqos/qos_external.o
-libqos-obj-y += tests/qtest/libqos/e1000e.o
-libqos-obj-y += tests/qtest/libqos/i2c.o
-libqos-obj-y += tests/qtest/libqos/i2c-imx.o
-libqos-obj-y += tests/qtest/libqos/i2c-omap.o
-libqos-obj-y += tests/qtest/libqos/sdhci.o
-libqos-obj-y += tests/qtest/libqos/tpci200.o
-libqos-obj-y += tests/qtest/libqos/virtio.o
-libqos-obj-$(CONFIG_VIRTFS) += tests/qtest/libqos/virtio-9p.o
-libqos-obj-y += tests/qtest/libqos/virtio-balloon.o
-libqos-obj-y += tests/qtest/libqos/virtio-blk.o
-libqos-obj-y += tests/qtest/libqos/virtio-mmio.o
-libqos-obj-y += tests/qtest/libqos/virtio-net.o
-libqos-obj-y += tests/qtest/libqos/virtio-pci.o
-libqos-obj-y += tests/qtest/libqos/virtio-pci-modern.o
-libqos-obj-y += tests/qtest/libqos/virtio-rng.o
-libqos-obj-y += tests/qtest/libqos/virtio-scsi.o
-libqos-obj-y += tests/qtest/libqos/virtio-serial.o
-
-# qos machines:
-libqos-obj-y += tests/qtest/libqos/aarch64-xlnx-zcu102-machine.o
-libqos-obj-y += tests/qtest/libqos/arm-imx25-pdk-machine.o
-libqos-obj-y += tests/qtest/libqos/arm-n800-machine.o
-libqos-obj-y += tests/qtest/libqos/arm-raspi2-machine.o
-libqos-obj-y += tests/qtest/libqos/arm-sabrelite-machine.o
-libqos-obj-y += tests/qtest/libqos/arm-smdkc210-machine.o
-libqos-obj-y += tests/qtest/libqos/arm-virt-machine.o
-libqos-obj-y += tests/qtest/libqos/arm-xilinx-zynq-a9-machine.o
-libqos-obj-y += tests/qtest/libqos/ppc64_pseries-machine.o
-libqos-obj-y += tests/qtest/libqos/x86_64_pc-machine.o
-
-# qos tests:
-qos-test-obj-y += tests/qtest/qos-test.o
-qos-test-obj-y += tests/qtest/ac97-test.o
-qos-test-obj-y += tests/qtest/ds1338-test.o
-qos-test-obj-y += tests/qtest/e1000-test.o
-qos-test-obj-y += tests/qtest/e1000e-test.o
-qos-test-obj-y += tests/qtest/eepro100-test.o
-qos-test-obj-y += tests/qtest/es1370-test.o
-qos-test-obj-y += tests/qtest/ipoctal232-test.o
-qos-test-obj-y += tests/qtest/megasas-test.o
-qos-test-obj-y += tests/qtest/ne2000-test.o
-qos-test-obj-y += tests/qtest/tulip-test.o
-qos-test-obj-y += tests/qtest/nvme-test.o
-qos-test-obj-y += tests/qtest/pca9552-test.o
-qos-test-obj-y += tests/qtest/pci-test.o
-qos-test-obj-y += tests/qtest/pcnet-test.o
-qos-test-obj-y += tests/qtest/sdhci-test.o
-qos-test-obj-y += tests/qtest/spapr-phb-test.o
-qos-test-obj-y += tests/qtest/tmp105-test.o
-qos-test-obj-y += tests/qtest/usb-hcd-ohci-test.o $(libqos-usb-obj-y)
-qos-test-obj-$(CONFIG_VHOST_NET_USER) += tests/qtest/vhost-user-test.o $(chardev-obj-y) $(test-io-obj-y)
-qos-test-obj-y += tests/qtest/virtio-test.o
-qos-test-obj-$(CONFIG_VIRTFS) += tests/qtest/virtio-9p-test.o
-qos-test-obj-y += tests/qtest/virtio-blk-test.o
-qos-test-obj-y += tests/qtest/virtio-net-test.o
-qos-test-obj-y += tests/qtest/virtio-rng-test.o
-qos-test-obj-y += tests/qtest/virtio-scsi-test.o
-qos-test-obj-y += tests/qtest/virtio-serial-test.o
-qos-test-obj-y += tests/qtest/vmxnet3-test.o
-
-check-unit-y += tests/test-qgraph$(EXESUF)
-tests/test-qgraph$(EXESUF): tests/test-qgraph.o $(libqgraph-obj-y)
-
-check-qtest-generic-y += qos-test
-tests/qtest/qos-test$(EXESUF): $(qos-test-obj-y) $(libqos-obj-y)
-
-# QTest dependencies:
-tests/qtest/qmp-test$(EXESUF): tests/qtest/qmp-test.o
-tests/qtest/qmp-cmd-test$(EXESUF): tests/qtest/qmp-cmd-test.o
-tests/qtest/device-introspect-test$(EXESUF): tests/qtest/device-introspect-test.o
-tests/qtest/rtc-test$(EXESUF): tests/qtest/rtc-test.o
-tests/qtest/m48t59-test$(EXESUF): tests/qtest/m48t59-test.o
-tests/qtest/hexloader-test$(EXESUF): tests/qtest/hexloader-test.o
-tests/qtest/pflash-cfi02$(EXESUF): tests/qtest/pflash-cfi02-test.o
-tests/qtest/endianness-test$(EXESUF): tests/qtest/endianness-test.o
-tests/qtest/prom-env-test$(EXESUF): tests/qtest/prom-env-test.o $(libqos-obj-y)
-tests/qtest/rtas-test$(EXESUF): tests/qtest/rtas-test.o $(libqos-spapr-obj-y)
-tests/qtest/fdc-test$(EXESUF): tests/qtest/fdc-test.o
-tests/qtest/ide-test$(EXESUF): tests/qtest/ide-test.o $(libqos-pc-obj-y)
-tests/qtest/ahci-test$(EXESUF): tests/qtest/ahci-test.o $(libqos-pc-obj-y) qemu-img$(EXESUF)
-tests/qtest/ipmi-kcs-test$(EXESUF): tests/qtest/ipmi-kcs-test.o
-tests/qtest/ipmi-bt-test$(EXESUF): tests/qtest/ipmi-bt-test.o
-tests/qtest/hd-geo-test$(EXESUF): tests/qtest/hd-geo-test.o $(libqos-obj-y)
-tests/qtest/boot-order-test$(EXESUF): tests/qtest/boot-order-test.o $(libqos-obj-y)
-tests/qtest/boot-serial-test$(EXESUF): tests/qtest/boot-serial-test.o $(libqos-obj-y)
-tests/qtest/bios-tables-test$(EXESUF): tests/qtest/bios-tables-test.o \
- tests/qtest/tpm-emu.o $(test-io-obj-y) \
- tests/qtest/boot-sector.o tests/qtest/acpi-utils.o $(libqos-obj-y)
-tests/qtest/pxe-test$(EXESUF): tests/qtest/pxe-test.o tests/qtest/boot-sector.o $(libqos-obj-y)
-tests/qtest/microbit-test$(EXESUF): tests/qtest/microbit-test.o
-tests/qtest/m25p80-test$(EXESUF): tests/qtest/m25p80-test.o
-tests/qtest/i440fx-test$(EXESUF): tests/qtest/i440fx-test.o $(libqos-pc-obj-y)
-tests/qtest/q35-test$(EXESUF): tests/qtest/q35-test.o $(libqos-pc-obj-y)
-tests/qtest/fw_cfg-test$(EXESUF): tests/qtest/fw_cfg-test.o $(libqos-pc-obj-y)
-tests/qtest/rtl8139-test$(EXESUF): tests/qtest/rtl8139-test.o $(libqos-pc-obj-y)
-tests/qtest/pnv-xscom-test$(EXESUF): tests/qtest/pnv-xscom-test.o
-tests/qtest/wdt_ib700-test$(EXESUF): tests/qtest/wdt_ib700-test.o
-tests/qtest/tco-test$(EXESUF): tests/qtest/tco-test.o $(libqos-pc-obj-y)
-tests/qtest/virtio-ccw-test$(EXESUF): tests/qtest/virtio-ccw-test.o
-tests/qtest/display-vga-test$(EXESUF): tests/qtest/display-vga-test.o
-tests/qtest/qom-test$(EXESUF): tests/qtest/qom-test.o
-tests/qtest/modules-test$(EXESUF): tests/qtest/modules-test.o
-tests/qtest/test-hmp$(EXESUF): tests/qtest/test-hmp.o
-tests/qtest/machine-none-test$(EXESUF): tests/qtest/machine-none-test.o
-tests/qtest/device-plug-test$(EXESUF): tests/qtest/device-plug-test.o
-tests/qtest/drive_del-test$(EXESUF): tests/qtest/drive_del-test.o
-tests/qtest/pvpanic-test$(EXESUF): tests/qtest/pvpanic-test.o
-tests/qtest/i82801b11-test$(EXESUF): tests/qtest/i82801b11-test.o
-tests/qtest/intel-hda-test$(EXESUF): tests/qtest/intel-hda-test.o
-tests/qtest/ioh3420-test$(EXESUF): tests/qtest/ioh3420-test.o
-tests/qtest/usb-hcd-uhci-test$(EXESUF): tests/qtest/usb-hcd-uhci-test.o $(libqos-usb-obj-y)
-tests/qtest/usb-hcd-ehci-test$(EXESUF): tests/qtest/usb-hcd-ehci-test.o $(libqos-usb-obj-y)
-tests/qtest/usb-hcd-xhci-test$(EXESUF): tests/qtest/usb-hcd-xhci-test.o $(libqos-usb-obj-y)
-tests/qtest/cpu-plug-test$(EXESUF): tests/qtest/cpu-plug-test.o
-tests/qtest/migration-test$(EXESUF): tests/qtest/migration-test.o tests/qtest/migration-helpers.o
-tests/qtest/test-netfilter$(EXESUF): tests/qtest/test-netfilter.o $(qtest-obj-y)
-tests/qtest/test-filter-mirror$(EXESUF): tests/qtest/test-filter-mirror.o $(qtest-obj-y)
-tests/qtest/test-filter-redirector$(EXESUF): tests/qtest/test-filter-redirector.o $(qtest-obj-y)
-tests/qtest/test-x86-cpuid-compat$(EXESUF): tests/qtest/test-x86-cpuid-compat.o $(qtest-obj-y)
-tests/qtest/ivshmem-test$(EXESUF): tests/qtest/ivshmem-test.o contrib/ivshmem-server/ivshmem-server.o $(libqos-pc-obj-y) $(libqos-spapr-obj-y)
-tests/qtest/dbus-vmstate-test$(EXESUF): tests/qtest/dbus-vmstate-test.o tests/qtest/migration-helpers.o tests/qtest/dbus-vmstate1.o $(libqos-pc-obj-y) $(libqos-spapr-obj-y)
-tests/qtest/test-arm-mptimer$(EXESUF): tests/qtest/test-arm-mptimer.o
-tests/qtest/numa-test$(EXESUF): tests/qtest/numa-test.o
-tests/qtest/vmgenid-test$(EXESUF): tests/qtest/vmgenid-test.o tests/qtest/boot-sector.o tests/qtest/acpi-utils.o
-tests/qtest/cdrom-test$(EXESUF): tests/qtest/cdrom-test.o tests/qtest/boot-sector.o $(libqos-obj-y)
-tests/qtest/arm-cpu-features$(EXESUF): tests/qtest/arm-cpu-features.o
-tests/qtest/tpm-crb-swtpm-test$(EXESUF): tests/qtest/tpm-crb-swtpm-test.o tests/qtest/tpm-emu.o \
- tests/qtest/tpm-util.o tests/qtest/tpm-tests.o $(test-io-obj-y)
-tests/qtest/tpm-crb-test$(EXESUF): tests/qtest/tpm-crb-test.o tests/qtest/tpm-emu.o $(test-io-obj-y)
-tests/qtest/tpm-tis-swtpm-test$(EXESUF): tests/qtest/tpm-tis-swtpm-test.o tests/qtest/tpm-emu.o \
- tests/qtest/tpm-util.o tests/qtest/tpm-tests.o $(test-io-obj-y)
-tests/qtest/tpm-tis-device-swtpm-test$(EXESUF): tests/qtest/tpm-tis-device-swtpm-test.o tests/qtest/tpm-emu.o \
- tests/qtest/tpm-util.o tests/qtest/tpm-tests.o $(test-io-obj-y)
-tests/qtest/tpm-tis-test$(EXESUF): tests/qtest/tpm-tis-test.o tests/qtest/tpm-tis-util.o tests/qtest/tpm-emu.o $(test-io-obj-y)
-tests/qtest/tpm-tis-device-test$(EXESUF): tests/qtest/tpm-tis-device-test.o tests/qtest/tpm-tis-util.o tests/qtest/tpm-emu.o $(test-io-obj-y)
-
-# QTest rules
-
-TARGETS=$(patsubst %-softmmu,%, $(filter %-softmmu,$(TARGET_DIRS)))
-QTEST_TARGETS =
-# The qtests are not runnable (yet) under TSan due to a known issue.
-# https://github.com/google/sanitizers/issues/1116
-ifndef CONFIG_TSAN
-ifeq ($(CONFIG_POSIX),y)
-QTEST_TARGETS = $(TARGETS)
-check-qtest-y=$(foreach TARGET,$(TARGETS), $(check-qtest-$(TARGET)-y:%=tests/qtest/%$(EXESUF)))
-check-qtest-y += $(check-qtest-generic-y:%=tests/qtest/%$(EXESUF))
-endif
-endif
-
-qtest-obj-y = tests/qtest/libqtest.o $(test-util-obj-y)
-$(check-qtest-y): $(qtest-obj-y)
diff --git a/tests/qtest/ac97-test.c b/tests/qtest/ac97-test.c
index b084e31bff..e09f2495d2 100644
--- a/tests/qtest/ac97-test.c
+++ b/tests/qtest/ac97-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/module.h"
#include "libqos/qgraph.h"
#include "libqos/pci.h"
diff --git a/tests/qtest/acpi-utils.h b/tests/qtest/acpi-utils.h
index 0c86780689..261784d251 100644
--- a/tests/qtest/acpi-utils.h
+++ b/tests/qtest/acpi-utils.h
@@ -13,7 +13,7 @@
#ifndef TEST_ACPI_UTILS_H
#define TEST_ACPI_UTILS_H
-#include "libqtest.h"
+#include "libqos/libqtest.h"
/* DSDT and SSDTs format */
typedef struct {
diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c
index c8d42ceea0..ca4294f44f 100644
--- a/tests/qtest/ahci-test.c
+++ b/tests/qtest/ahci-test.c
@@ -25,7 +25,7 @@
#include "qemu/osdep.h"
#include <getopt.h>
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "libqos/libqos-pc.h"
#include "libqos/ahci.h"
#include "libqos/pci-pc.h"
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
index f7e062c189..77b5e30a9c 100644
--- a/tests/qtest/arm-cpu-features.c
+++ b/tests/qtest/arm-cpu-features.c
@@ -10,7 +10,7 @@
*/
#include "qemu/osdep.h"
#include "qemu/bitops.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qjson.h"
diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
index d49b3988ec..d25ff35492 100644
--- a/tests/qtest/bios-tables-test.c
+++ b/tests/qtest/bios-tables-test.c
@@ -88,7 +88,7 @@ typedef struct {
static char disk[] = "tests/acpi-test-disk-XXXXXX";
static const char *data_dir = "tests/data/acpi";
#ifdef CONFIG_IASL
-static const char *iasl = stringify(CONFIG_IASL);
+static const char *iasl = CONFIG_IASL;
#else
static const char *iasl;
#endif
diff --git a/tests/qtest/boot-order-test.c b/tests/qtest/boot-order-test.c
index 2f1c07221c..fac580d6c4 100644
--- a/tests/qtest/boot-order-test.c
+++ b/tests/qtest/boot-order-test.c
@@ -12,7 +12,7 @@
#include "qemu/osdep.h"
#include "libqos/fw_cfg.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qapi/qmp/qdict.h"
#include "standard-headers/linux/qemu_fw_cfg.h"
diff --git a/tests/qtest/boot-sector.c b/tests/qtest/boot-sector.c
index 9e66c6d013..24df5c4734 100644
--- a/tests/qtest/boot-sector.c
+++ b/tests/qtest/boot-sector.c
@@ -13,7 +13,7 @@
#include "qemu/osdep.h"
#include "boot-sector.h"
#include "qemu-common.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#define LOW(x) ((x) & 0xff)
#define HIGH(x) ((x) >> 8)
diff --git a/tests/qtest/boot-sector.h b/tests/qtest/boot-sector.h
index 6ee6bb4d97..b339fdee4c 100644
--- a/tests/qtest/boot-sector.h
+++ b/tests/qtest/boot-sector.h
@@ -14,7 +14,7 @@
#ifndef TEST_BOOT_SECTOR_H
#define TEST_BOOT_SECTOR_H
-#include "libqtest.h"
+#include "libqos/libqtest.h"
/* Create boot disk file. fname must be a suitable string for mkstemp() */
int boot_sector_init(char *fname);
diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c
index bfe7624dc6..b6b1c23cd0 100644
--- a/tests/qtest/boot-serial-test.c
+++ b/tests/qtest/boot-serial-test.c
@@ -14,7 +14,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "libqos/libqos-spapr.h"
static const uint8_t bios_avr[] = {
diff --git a/tests/qtest/cdrom-test.c b/tests/qtest/cdrom-test.c
index 833a0508a1..e9afab693c 100644
--- a/tests/qtest/cdrom-test.c
+++ b/tests/qtest/cdrom-test.c
@@ -11,7 +11,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "boot-sector.h"
#include "qapi/qmp/qdict.h"
diff --git a/tests/qtest/dbus-vmstate-test.c b/tests/qtest/dbus-vmstate-test.c
index 2e5e47dec2..aca9b98b7a 100644
--- a/tests/qtest/dbus-vmstate-test.c
+++ b/tests/qtest/dbus-vmstate-test.c
@@ -1,7 +1,7 @@
#include "qemu/osdep.h"
#include <glib/gstdio.h>
#include <gio/gio.h>
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu-common.h"
#include "dbus-vmstate1.h"
#include "migration-helpers.h"
diff --git a/tests/qtest/device-introspect-test.c b/tests/qtest/device-introspect-test.c
index d68b7856a7..9f22340ee5 100644
--- a/tests/qtest/device-introspect-test.c
+++ b/tests/qtest/device-introspect-test.c
@@ -22,7 +22,7 @@
#include "qapi/qmp/qstring.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qlist.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
const char common_args[] = "-nodefaults -machine none";
diff --git a/tests/qtest/device-plug-test.c b/tests/qtest/device-plug-test.c
index 318e422d51..9214892741 100644
--- a/tests/qtest/device-plug-test.c
+++ b/tests/qtest/device-plug-test.c
@@ -11,7 +11,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qstring.h"
diff --git a/tests/qtest/drive_del-test.c b/tests/qtest/drive_del-test.c
index 5f8839b232..2ab11ad225 100644
--- a/tests/qtest/drive_del-test.c
+++ b/tests/qtest/drive_del-test.c
@@ -11,7 +11,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "libqos/virtio.h"
#include "qapi/qmp/qdict.h"
diff --git a/tests/qtest/ds1338-test.c b/tests/qtest/ds1338-test.c
index f6ade9a050..c5d46bcc64 100644
--- a/tests/qtest/ds1338-test.c
+++ b/tests/qtest/ds1338-test.c
@@ -18,7 +18,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "libqos/i2c.h"
#define DS1338_ADDR 0x68
diff --git a/tests/qtest/e1000-test.c b/tests/qtest/e1000-test.c
index c387984ef6..ea286d1793 100644
--- a/tests/qtest/e1000-test.c
+++ b/tests/qtest/e1000-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/module.h"
#include "libqos/qgraph.h"
#include "libqos/pci.h"
diff --git a/tests/qtest/eepro100-test.c b/tests/qtest/eepro100-test.c
index 8dbffff0b8..d72ad099f1 100644
--- a/tests/qtest/eepro100-test.c
+++ b/tests/qtest/eepro100-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/module.h"
#include "libqos/qgraph.h"
#include "libqos/pci.h"
diff --git a/tests/qtest/endianness-test.c b/tests/qtest/endianness-test.c
index cc088ac01a..4e79e22c28 100644
--- a/tests/qtest/endianness-test.c
+++ b/tests/qtest/endianness-test.c
@@ -13,7 +13,7 @@
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/bswap.h"
typedef struct TestCase TestCase;
diff --git a/tests/qtest/es1370-test.c b/tests/qtest/es1370-test.c
index adccdac1be..2fd7fd2d3d 100644
--- a/tests/qtest/es1370-test.c
+++ b/tests/qtest/es1370-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/module.h"
#include "libqos/qgraph.h"
#include "libqos/pci.h"
diff --git a/tests/qtest/fuzz/Makefile.include b/tests/qtest/fuzz/Makefile.include
deleted file mode 100644
index 5bde793bf2..0000000000
--- a/tests/qtest/fuzz/Makefile.include
+++ /dev/null
@@ -1,39 +0,0 @@
-QEMU_PROG_FUZZ=qemu-fuzz-$(TARGET_NAME)$(EXESUF)
-
-fuzz-obj-y += tests/qtest/libqtest.o
-fuzz-obj-y += $(libqos-obj-y)
-fuzz-obj-y += tests/qtest/fuzz/fuzz.o # Fuzzer skeleton
-fuzz-obj-y += tests/qtest/fuzz/fork_fuzz.o
-fuzz-obj-y += tests/qtest/fuzz/qos_fuzz.o
-fuzz-obj-y += tests/qtest/fuzz/qtest_wrappers.o
-
-# Targets
-fuzz-obj-$(CONFIG_PCI_I440FX) += tests/qtest/fuzz/i440fx_fuzz.o
-fuzz-obj-$(CONFIG_VIRTIO_NET) += tests/qtest/fuzz/virtio_net_fuzz.o
-fuzz-obj-$(CONFIG_SCSI) += tests/qtest/fuzz/virtio_scsi_fuzz.o
-
-FUZZ_CFLAGS += -I$(SRC_PATH)/tests -I$(SRC_PATH)/tests/qtest
-
-# Linker Script to force coverage-counters into known regions which we can mark
-# shared
-FUZZ_LDFLAGS += -Xlinker -T$(SRC_PATH)/tests/qtest/fuzz/fork_fuzz.ld
-
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_inb
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_inw
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_inl
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_outb
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_outw
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_outl
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_readb
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_readw
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_readl
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_readq
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_writeb
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_writew
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_writel
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_writeq
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_memread
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_bufread
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_memwrite
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_bufwrite
-FUZZ_LDFLAGS += -Wl,-wrap,qtest_memset
diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c
index 031594a686..1ceea84702 100644
--- a/tests/qtest/fuzz/fuzz.c
+++ b/tests/qtest/fuzz/fuzz.c
@@ -20,7 +20,7 @@
#include "sysemu/sysemu.h"
#include "qemu/main-loop.h"
#include "qemu/rcu.h"
-#include "tests/qtest/libqtest.h"
+#include "tests/qtest/libqos/libqtest.h"
#include "tests/qtest/libqos/qgraph.h"
#include "fuzz.h"
diff --git a/tests/qtest/fuzz/fuzz.h b/tests/qtest/fuzz/fuzz.h
index 9ca3d107c5..8eb765edc8 100644
--- a/tests/qtest/fuzz/fuzz.h
+++ b/tests/qtest/fuzz/fuzz.h
@@ -18,7 +18,7 @@
#include "qemu/units.h"
#include "qapi/error.h"
-#include "tests/qtest/libqtest.h"
+#include "tests/qtest/libqos/libqtest.h"
/**
* A libfuzzer fuzzing target
diff --git a/tests/qtest/fuzz/i440fx_fuzz.c b/tests/qtest/fuzz/i440fx_fuzz.c
index bf966d478b..86796bff2b 100644
--- a/tests/qtest/fuzz/i440fx_fuzz.c
+++ b/tests/qtest/fuzz/i440fx_fuzz.c
@@ -13,12 +13,12 @@
#include "qemu/osdep.h"
#include "qemu/main-loop.h"
-#include "tests/qtest/libqtest.h"
+#include "tests/qtest/libqos/libqtest.h"
#include "tests/qtest/libqos/pci.h"
#include "tests/qtest/libqos/pci-pc.h"
#include "fuzz.h"
-#include "fuzz/qos_fuzz.h"
-#include "fuzz/fork_fuzz.h"
+#include "qos_fuzz.h"
+#include "fork_fuzz.h"
#define I440FX_PCI_HOST_BRIDGE_CFG 0xcf8
diff --git a/tests/qtest/fuzz/meson.build b/tests/qtest/fuzz/meson.build
new file mode 100644
index 0000000000..bb0a3f271d
--- /dev/null
+++ b/tests/qtest/fuzz/meson.build
@@ -0,0 +1,35 @@
+specific_fuzz_ss.add(files('fuzz.c', 'fork_fuzz.c', 'qos_fuzz.c',
+ 'qtest_wrappers.c'), qos)
+
+# Targets
+specific_fuzz_ss.add(when: 'CONFIG_I440FX', if_true: files('i440fx_fuzz.c'))
+specific_fuzz_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('virtio_net_fuzz.c'))
+specific_fuzz_ss.add(when: 'CONFIG_VIRTIO_SCSI', if_true: files('virtio_scsi_fuzz.c'))
+
+# unfortunately declare_dependency does not support link_depends, so
+# this will be duplicated in meson.build
+fork_fuzz = declare_dependency(
+ link_args: ['-fsanitize=fuzzer',
+ '-Wl,-T,' + (meson.current_source_dir() / 'fork_fuzz.ld'),
+ '-Wl,-wrap,qtest_inb',
+ '-Wl,-wrap,qtest_inw',
+ '-Wl,-wrap,qtest_inl',
+ '-Wl,-wrap,qtest_outb',
+ '-Wl,-wrap,qtest_outw',
+ '-Wl,-wrap,qtest_outl',
+ '-Wl,-wrap,qtest_readb',
+ '-Wl,-wrap,qtest_readw',
+ '-Wl,-wrap,qtest_readl',
+ '-Wl,-wrap,qtest_readq',
+ '-Wl,-wrap,qtest_writeb',
+ '-Wl,-wrap,qtest_writew',
+ '-Wl,-wrap,qtest_writel',
+ '-Wl,-wrap,qtest_writeq',
+ '-Wl,-wrap,qtest_memread',
+ '-Wl,-wrap,qtest_bufread',
+ '-Wl,-wrap,qtest_memwrite',
+ '-Wl,-wrap,qtest_bufwrite',
+ '-Wl,-wrap,qtest_memset']
+)
+
+specific_fuzz_ss.add(fork_fuzz)
diff --git a/tests/qtest/fuzz/qos_fuzz.c b/tests/qtest/fuzz/qos_fuzz.c
index d52f3ebd83..b943577b8c 100644
--- a/tests/qtest/fuzz/qos_fuzz.c
+++ b/tests/qtest/fuzz/qos_fuzz.c
@@ -25,7 +25,7 @@
#include "sysemu/sysemu.h"
#include "qemu/main-loop.h"
-#include "tests/qtest/libqtest.h"
+#include "tests/qtest/libqos/libqtest.h"
#include "tests/qtest/libqos/malloc.h"
#include "tests/qtest/libqos/qgraph.h"
#include "tests/qtest/libqos/qgraph_internal.h"
diff --git a/tests/qtest/fuzz/qtest_wrappers.c b/tests/qtest/fuzz/qtest_wrappers.c
index 713c830cdb..0580f8df86 100644
--- a/tests/qtest/fuzz/qtest_wrappers.c
+++ b/tests/qtest/fuzz/qtest_wrappers.c
@@ -12,7 +12,7 @@
*/
#include "qemu/osdep.h"
-#include "cpu.h"
+#include "hw/core/cpu.h"
#include "exec/ioport.h"
#include "fuzz.h"
diff --git a/tests/qtest/fuzz/virtio_net_fuzz.c b/tests/qtest/fuzz/virtio_net_fuzz.c
index a33bd73067..0e873ab8e2 100644
--- a/tests/qtest/fuzz/virtio_net_fuzz.c
+++ b/tests/qtest/fuzz/virtio_net_fuzz.c
@@ -13,7 +13,7 @@
#include "qemu/osdep.h"
#include "standard-headers/linux/virtio_config.h"
-#include "tests/qtest/libqtest.h"
+#include "tests/qtest/libqos/libqtest.h"
#include "tests/qtest/libqos/virtio-net.h"
#include "fuzz.h"
#include "fork_fuzz.h"
@@ -61,7 +61,8 @@ static void virtio_net_fuzz_multi(QTestState *s,
* backend. Otherwise, always place the input on a virtqueue.
*/
if (vqa.rx && sockfds_initialized) {
- write(sockfds[0], Data, vqa.length);
+ int ignored = write(sockfds[0], Data, vqa.length);
+ (void) ignored;
} else {
vqa.rx = 0;
uint64_t req_addr = guest_alloc(t_alloc, vqa.length);
diff --git a/tests/qtest/fuzz/virtio_scsi_fuzz.c b/tests/qtest/fuzz/virtio_scsi_fuzz.c
index 3a9ea13736..6ff6fabe4a 100644
--- a/tests/qtest/fuzz/virtio_scsi_fuzz.c
+++ b/tests/qtest/fuzz/virtio_scsi_fuzz.c
@@ -12,10 +12,10 @@
#include "qemu/osdep.h"
-#include "tests/qtest/libqtest.h"
-#include "libqos/virtio-scsi.h"
-#include "libqos/virtio.h"
-#include "libqos/virtio-pci.h"
+#include "tests/qtest/libqos/libqtest.h"
+#include "tests/qtest/libqos/virtio-scsi.h"
+#include "tests/qtest/libqos/virtio.h"
+#include "tests/qtest/libqos/virtio-pci.h"
#include "standard-headers/linux/virtio_ids.h"
#include "standard-headers/linux/virtio_pci.h"
#include "standard-headers/linux/virtio_scsi.h"
diff --git a/tests/qtest/fw_cfg-test.c b/tests/qtest/fw_cfg-test.c
index 5dc807ba23..95b3907c18 100644
--- a/tests/qtest/fw_cfg-test.c
+++ b/tests/qtest/fw_cfg-test.c
@@ -12,7 +12,7 @@
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "standard-headers/linux/qemu_fw_cfg.h"
#include "libqos/fw_cfg.h"
#include "qemu/bswap.h"
diff --git a/tests/qtest/hd-geo-test.c b/tests/qtest/hd-geo-test.c
index 48e8e02d6e..f7b7cfbc2d 100644
--- a/tests/qtest/hd-geo-test.c
+++ b/tests/qtest/hd-geo-test.c
@@ -19,7 +19,7 @@
#include "qemu-common.h"
#include "qemu/bswap.h"
#include "qapi/qmp/qlist.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "libqos/fw_cfg.h"
#include "libqos/libqos.h"
#include "standard-headers/linux/qemu_fw_cfg.h"
diff --git a/tests/qtest/hexloader-test.c b/tests/qtest/hexloader-test.c
index 8b7aa2d72d..561502052a 100644
--- a/tests/qtest/hexloader-test.c
+++ b/tests/qtest/hexloader-test.c
@@ -10,7 +10,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
/* Load 'test.hex' and verify that the in-memory contents are as expected.
* 'test.hex' is a memory test pattern stored in Hexadecimal Object
diff --git a/tests/qtest/ide-test.c b/tests/qtest/ide-test.c
index 5cfd97f915..3f8081e77d 100644
--- a/tests/qtest/ide-test.c
+++ b/tests/qtest/ide-test.c
@@ -25,7 +25,7 @@
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "libqos/libqos.h"
#include "libqos/pci-pc.h"
#include "libqos/malloc-pc.h"
diff --git a/tests/qtest/ipoctal232-test.c b/tests/qtest/ipoctal232-test.c
index 53a8c9b13c..65ce10b81b 100644
--- a/tests/qtest/ipoctal232-test.c
+++ b/tests/qtest/ipoctal232-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/module.h"
#include "libqos/qgraph.h"
diff --git a/tests/qtest/ivshmem-test.c b/tests/qtest/ivshmem-test.c
index ecda256472..d5c8b9f128 100644
--- a/tests/qtest/ivshmem-test.c
+++ b/tests/qtest/ivshmem-test.c
@@ -13,7 +13,7 @@
#include "contrib/ivshmem-server/ivshmem-server.h"
#include "libqos/libqos-pc.h"
#include "libqos/libqos-spapr.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu-common.h"
#define TMPSHMSIZE (1 << 20)
diff --git a/tests/qtest/libqos/aarch64-xlnx-zcu102-machine.c b/tests/qtest/libqos/aarch64-xlnx-zcu102-machine.c
index 8f827aeb52..79631cc7a9 100644
--- a/tests/qtest/libqos/aarch64-xlnx-zcu102-machine.c
+++ b/tests/qtest/libqos/aarch64-xlnx-zcu102-machine.c
@@ -19,8 +19,8 @@
#include "qemu/osdep.h"
#include "libqtest.h"
#include "qemu/module.h"
-#include "libqos/malloc.h"
-#include "libqos/qgraph.h"
+#include "malloc.h"
+#include "qgraph.h"
#include "sdhci.h"
typedef struct QXlnxZCU102Machine QXlnxZCU102Machine;
diff --git a/tests/qtest/libqos/ahci.c b/tests/qtest/libqos/ahci.c
index cc1b08eabe..2946abc15a 100644
--- a/tests/qtest/libqos/ahci.c
+++ b/tests/qtest/libqos/ahci.c
@@ -25,8 +25,8 @@
#include "qemu/osdep.h"
#include "libqtest.h"
-#include "libqos/ahci.h"
-#include "libqos/pci-pc.h"
+#include "ahci.h"
+#include "pci-pc.h"
#include "qemu-common.h"
#include "qemu/host-utils.h"
@@ -579,7 +579,7 @@ void ahci_write_fis(AHCIQState *ahci, AHCICommand *cmd)
/* NCQ commands use exclusively 8 bit fields and needs no adjustment.
* Only the count field needs to be adjusted for non-NCQ commands.
* The auxiliary FIS fields are defined per-command and are not currently
- * implemented in libqos/ahci.o, but may or may not need to be flipped. */
+ * implemented in ahci.o, but may or may not need to be flipped. */
if (!cmd->props->ncq) {
tmp.count = cpu_to_le16(tmp.count);
}
diff --git a/tests/qtest/libqos/ahci.h b/tests/qtest/libqos/ahci.h
index 44ab1104b5..88835b6228 100644
--- a/tests/qtest/libqos/ahci.h
+++ b/tests/qtest/libqos/ahci.h
@@ -25,9 +25,9 @@
* THE SOFTWARE.
*/
-#include "libqos/libqos.h"
-#include "libqos/pci.h"
-#include "libqos/malloc-pc.h"
+#include "libqos.h"
+#include "pci.h"
+#include "malloc-pc.h"
/*** Supplementary PCI Config Space IDs & Masks ***/
#define PCI_DEVICE_ID_INTEL_Q35_AHCI (0x2922)
diff --git a/tests/qtest/libqos/arm-imx25-pdk-machine.c b/tests/qtest/libqos/arm-imx25-pdk-machine.c
index 0da3f19c0e..6692adfa4f 100644
--- a/tests/qtest/libqos/arm-imx25-pdk-machine.c
+++ b/tests/qtest/libqos/arm-imx25-pdk-machine.c
@@ -20,9 +20,9 @@
#include "qemu/osdep.h"
#include "libqtest.h"
-#include "libqos/malloc.h"
-#include "libqos/qgraph.h"
-#include "libqos/i2c.h"
+#include "malloc.h"
+#include "qgraph.h"
+#include "i2c.h"
#define ARM_PAGE_SIZE 4096
#define IMX25_PDK_RAM_START 0x80000000
diff --git a/tests/qtest/libqos/arm-n800-machine.c b/tests/qtest/libqos/arm-n800-machine.c
index 35f82070fa..ff2049c3a7 100644
--- a/tests/qtest/libqos/arm-n800-machine.c
+++ b/tests/qtest/libqos/arm-n800-machine.c
@@ -20,9 +20,9 @@
#include "qemu/osdep.h"
#include "libqtest.h"
-#include "libqos/malloc.h"
-#include "libqos/qgraph.h"
-#include "libqos/i2c.h"
+#include "malloc.h"
+#include "qgraph.h"
+#include "i2c.h"
#define ARM_PAGE_SIZE 4096
#define N800_RAM_START 0x80000000
diff --git a/tests/qtest/libqos/arm-raspi2-machine.c b/tests/qtest/libqos/arm-raspi2-machine.c
index 8480d80669..35bb4709a4 100644
--- a/tests/qtest/libqos/arm-raspi2-machine.c
+++ b/tests/qtest/libqos/arm-raspi2-machine.c
@@ -19,8 +19,8 @@
#include "qemu/osdep.h"
#include "libqtest.h"
#include "qemu/module.h"
-#include "libqos/malloc.h"
-#include "libqos/qgraph.h"
+#include "malloc.h"
+#include "qgraph.h"
#include "sdhci.h"
#define ARM_PAGE_SIZE 4096
diff --git a/tests/qtest/libqos/arm-sabrelite-machine.c b/tests/qtest/libqos/arm-sabrelite-machine.c
index f6e403b538..72425f0ad4 100644
--- a/tests/qtest/libqos/arm-sabrelite-machine.c
+++ b/tests/qtest/libqos/arm-sabrelite-machine.c
@@ -19,8 +19,8 @@
#include "qemu/osdep.h"
#include "libqtest.h"
#include "qemu/module.h"
-#include "libqos/malloc.h"
-#include "libqos/qgraph.h"
+#include "malloc.h"
+#include "qgraph.h"
#include "sdhci.h"
#define ARM_PAGE_SIZE 4096
diff --git a/tests/qtest/libqos/arm-smdkc210-machine.c b/tests/qtest/libqos/arm-smdkc210-machine.c
index eebac7feeb..321b8826d4 100644
--- a/tests/qtest/libqos/arm-smdkc210-machine.c
+++ b/tests/qtest/libqos/arm-smdkc210-machine.c
@@ -19,8 +19,8 @@
#include "qemu/osdep.h"
#include "libqtest.h"
#include "qemu/module.h"
-#include "libqos/malloc.h"
-#include "libqos/qgraph.h"
+#include "malloc.h"
+#include "qgraph.h"
#include "sdhci.h"
#define ARM_PAGE_SIZE 4096
diff --git a/tests/qtest/libqos/arm-virt-machine.c b/tests/qtest/libqos/arm-virt-machine.c
index 9316598f9e..e0f5932284 100644
--- a/tests/qtest/libqos/arm-virt-machine.c
+++ b/tests/qtest/libqos/arm-virt-machine.c
@@ -19,9 +19,9 @@
#include "qemu/osdep.h"
#include "libqtest.h"
#include "qemu/module.h"
-#include "libqos/malloc.h"
-#include "libqos/qgraph.h"
-#include "libqos/virtio-mmio.h"
+#include "malloc.h"
+#include "qgraph.h"
+#include "virtio-mmio.h"
#define ARM_PAGE_SIZE 4096
#define VIRTIO_MMIO_BASE_ADDR 0x0A003E00
diff --git a/tests/qtest/libqos/arm-xilinx-zynq-a9-machine.c b/tests/qtest/libqos/arm-xilinx-zynq-a9-machine.c
index 473acce993..56e53c745b 100644
--- a/tests/qtest/libqos/arm-xilinx-zynq-a9-machine.c
+++ b/tests/qtest/libqos/arm-xilinx-zynq-a9-machine.c
@@ -19,8 +19,8 @@
#include "qemu/osdep.h"
#include "libqtest.h"
#include "qemu/module.h"
-#include "libqos/malloc.h"
-#include "libqos/qgraph.h"
+#include "malloc.h"
+#include "qgraph.h"
#include "sdhci.h"
typedef struct QXilinxZynqA9Machine QXilinxZynqA9Machine;
diff --git a/tests/qtest/libqos/e1000e.c b/tests/qtest/libqos/e1000e.c
index e2927ed2da..a451f6168f 100644
--- a/tests/qtest/libqos/e1000e.c
+++ b/tests/qtest/libqos/e1000e.c
@@ -18,13 +18,13 @@
#include "qemu/osdep.h"
#include "libqtest.h"
-#include "libqos/pci-pc.h"
+#include "pci-pc.h"
#include "qemu/sockets.h"
#include "qemu/iov.h"
#include "qemu/module.h"
#include "qemu/bitops.h"
-#include "libqos/malloc.h"
-#include "libqos/qgraph.h"
+#include "malloc.h"
+#include "qgraph.h"
#include "e1000e.h"
#define E1000E_IMS (0x00d0)
diff --git a/tests/qtest/libqos/e1000e.h b/tests/qtest/libqos/e1000e.h
index 35183b2875..a22f5fdbad 100644
--- a/tests/qtest/libqos/e1000e.h
+++ b/tests/qtest/libqos/e1000e.h
@@ -19,7 +19,7 @@
#ifndef QGRAPH_E1000E_H
#define QGRAPH_E1000E_H
-#include "libqos/qgraph.h"
+#include "qgraph.h"
#include "pci.h"
#define E1000E_RX0_MSG_ID (0)
diff --git a/tests/qtest/libqos/fw_cfg.c b/tests/qtest/libqos/fw_cfg.c
index 1f46258f96..6b8e1babe5 100644
--- a/tests/qtest/libqos/fw_cfg.c
+++ b/tests/qtest/libqos/fw_cfg.c
@@ -13,7 +13,7 @@
*/
#include "qemu/osdep.h"
-#include "libqos/fw_cfg.h"
+#include "fw_cfg.h"
#include "libqtest.h"
#include "qemu/bswap.h"
#include "hw/nvram/fw_cfg.h"
diff --git a/tests/qtest/libqos/i2c-imx.c b/tests/qtest/libqos/i2c-imx.c
index f33ece55a3..8f9a7e3831 100644
--- a/tests/qtest/libqos/i2c-imx.c
+++ b/tests/qtest/libqos/i2c-imx.c
@@ -18,7 +18,7 @@
*/
#include "qemu/osdep.h"
-#include "libqos/i2c.h"
+#include "i2c.h"
#include "libqtest.h"
diff --git a/tests/qtest/libqos/i2c-omap.c b/tests/qtest/libqos/i2c-omap.c
index 9ae8214fa8..eb4e453485 100644
--- a/tests/qtest/libqos/i2c-omap.c
+++ b/tests/qtest/libqos/i2c-omap.c
@@ -7,7 +7,7 @@
* See the COPYING file in the top-level directory.
*/
#include "qemu/osdep.h"
-#include "libqos/i2c.h"
+#include "i2c.h"
#include "qemu/bswap.h"
diff --git a/tests/qtest/libqos/i2c.c b/tests/qtest/libqos/i2c.c
index 38f800dbab..ade1bdb40e 100644
--- a/tests/qtest/libqos/i2c.c
+++ b/tests/qtest/libqos/i2c.c
@@ -7,7 +7,7 @@
* See the COPYING file in the top-level directory.
*/
#include "qemu/osdep.h"
-#include "libqos/i2c.h"
+#include "i2c.h"
#include "libqtest.h"
void qi2c_send(QI2CDevice *i2cdev, const uint8_t *buf, uint16_t len)
diff --git a/tests/qtest/libqos/i2c.h b/tests/qtest/libqos/i2c.h
index c65f087834..1341bac1c5 100644
--- a/tests/qtest/libqos/i2c.h
+++ b/tests/qtest/libqos/i2c.h
@@ -10,7 +10,7 @@
#define LIBQOS_I2C_H
#include "libqtest.h"
-#include "libqos/qgraph.h"
+#include "qgraph.h"
typedef struct I2CAdapter I2CAdapter;
struct I2CAdapter {
diff --git a/tests/qtest/libqos/libqos-pc.c b/tests/qtest/libqos/libqos-pc.c
index d04abc548b..db420a596e 100644
--- a/tests/qtest/libqos/libqos-pc.c
+++ b/tests/qtest/libqos/libqos-pc.c
@@ -1,7 +1,7 @@
#include "qemu/osdep.h"
-#include "libqos/libqos-pc.h"
-#include "libqos/malloc-pc.h"
-#include "libqos/pci-pc.h"
+#include "libqos-pc.h"
+#include "malloc-pc.h"
+#include "pci-pc.h"
static QOSOps qos_ops = {
.alloc_init = pc_alloc_init,
diff --git a/tests/qtest/libqos/libqos-pc.h b/tests/qtest/libqos/libqos-pc.h
index a0e4c45516..1a9923ead4 100644
--- a/tests/qtest/libqos/libqos-pc.h
+++ b/tests/qtest/libqos/libqos-pc.h
@@ -1,7 +1,7 @@
#ifndef LIBQOS_PC_H
#define LIBQOS_PC_H
-#include "libqos/libqos.h"
+#include "libqos.h"
QOSState *qtest_pc_vboot(const char *cmdline_fmt, va_list ap);
QOSState *qtest_pc_boot(const char *cmdline_fmt, ...);
diff --git a/tests/qtest/libqos/libqos-spapr.c b/tests/qtest/libqos/libqos-spapr.c
index 8766d543ce..db0e87ba5c 100644
--- a/tests/qtest/libqos/libqos-spapr.c
+++ b/tests/qtest/libqos/libqos-spapr.c
@@ -1,7 +1,7 @@
#include "qemu/osdep.h"
-#include "libqos/libqos-spapr.h"
-#include "libqos/malloc-spapr.h"
-#include "libqos/pci-spapr.h"
+#include "libqos-spapr.h"
+#include "malloc-spapr.h"
+#include "pci-spapr.h"
static QOSOps qos_ops = {
.alloc_init = spapr_alloc_init,
diff --git a/tests/qtest/libqos/libqos-spapr.h b/tests/qtest/libqos/libqos-spapr.h
index 49bd72d20b..c61338917a 100644
--- a/tests/qtest/libqos/libqos-spapr.h
+++ b/tests/qtest/libqos/libqos-spapr.h
@@ -1,7 +1,7 @@
#ifndef LIBQOS_SPAPR_H
#define LIBQOS_SPAPR_H
-#include "libqos/libqos.h"
+#include "libqos.h"
QOSState *qtest_spapr_vboot(const char *cmdline_fmt, va_list ap);
QOSState *qtest_spapr_boot(const char *cmdline_fmt, ...);
diff --git a/tests/qtest/libqos/libqos.c b/tests/qtest/libqos/libqos.c
index f229eb2cb8..2251e864ef 100644
--- a/tests/qtest/libqos/libqos.c
+++ b/tests/qtest/libqos/libqos.c
@@ -2,8 +2,8 @@
#include <sys/wait.h>
#include "libqtest.h"
-#include "libqos/libqos.h"
-#include "libqos/pci.h"
+#include "libqos.h"
+#include "pci.h"
#include "qapi/qmp/qdict.h"
/*** Test Setup & Teardown ***/
diff --git a/tests/qtest/libqos/libqos.h b/tests/qtest/libqos/libqos.h
index 8e971c25a3..e0b2bfe7ca 100644
--- a/tests/qtest/libqos/libqos.h
+++ b/tests/qtest/libqos/libqos.h
@@ -2,8 +2,8 @@
#define LIBQOS_H
#include "libqtest.h"
-#include "libqos/pci.h"
-#include "libqos/malloc.h"
+#include "pci.h"
+#include "malloc.h"
typedef struct QOSState QOSState;
diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqos/libqtest.h
index f5cf93c386..f5cf93c386 100644
--- a/tests/qtest/libqtest.h
+++ b/tests/qtest/libqos/libqtest.h
diff --git a/tests/qtest/libqos/malloc-pc.c b/tests/qtest/libqos/malloc-pc.c
index 6f92ce4135..16ff9609cc 100644
--- a/tests/qtest/libqos/malloc-pc.c
+++ b/tests/qtest/libqos/malloc-pc.c
@@ -11,8 +11,8 @@
*/
#include "qemu/osdep.h"
-#include "libqos/malloc-pc.h"
-#include "libqos/fw_cfg.h"
+#include "malloc-pc.h"
+#include "fw_cfg.h"
#include "standard-headers/linux/qemu_fw_cfg.h"
diff --git a/tests/qtest/libqos/malloc-pc.h b/tests/qtest/libqos/malloc-pc.h
index 21e75ae004..d8d79853c8 100644
--- a/tests/qtest/libqos/malloc-pc.h
+++ b/tests/qtest/libqos/malloc-pc.h
@@ -13,7 +13,7 @@
#ifndef LIBQOS_MALLOC_PC_H
#define LIBQOS_MALLOC_PC_H
-#include "libqos/malloc.h"
+#include "malloc.h"
void pc_alloc_init(QGuestAllocator *s, QTestState *qts, QAllocOpts flags);
diff --git a/tests/qtest/libqos/malloc-spapr.c b/tests/qtest/libqos/malloc-spapr.c
index 2a6b7e3776..84862e4876 100644
--- a/tests/qtest/libqos/malloc-spapr.c
+++ b/tests/qtest/libqos/malloc-spapr.c
@@ -6,7 +6,7 @@
*/
#include "qemu/osdep.h"
-#include "libqos/malloc-spapr.h"
+#include "malloc-spapr.h"
#include "qemu-common.h"
diff --git a/tests/qtest/libqos/malloc-spapr.h b/tests/qtest/libqos/malloc-spapr.h
index e5fe9bfc4b..f99572fd71 100644
--- a/tests/qtest/libqos/malloc-spapr.h
+++ b/tests/qtest/libqos/malloc-spapr.h
@@ -8,7 +8,7 @@
#ifndef LIBQOS_MALLOC_SPAPR_H
#define LIBQOS_MALLOC_SPAPR_H
-#include "libqos/malloc.h"
+#include "malloc.h"
void spapr_alloc_init(QGuestAllocator *s, QTestState *qts, QAllocOpts flags);
diff --git a/tests/qtest/libqos/malloc.c b/tests/qtest/libqos/malloc.c
index 615422a5c4..f708b01432 100644
--- a/tests/qtest/libqos/malloc.c
+++ b/tests/qtest/libqos/malloc.c
@@ -11,7 +11,7 @@
*/
#include "qemu/osdep.h"
-#include "libqos/malloc.h"
+#include "malloc.h"
#include "qemu-common.h"
#include "qemu/host-utils.h"
diff --git a/tests/qtest/libqos/meson.build b/tests/qtest/libqos/meson.build
new file mode 100644
index 0000000000..19931b9248
--- /dev/null
+++ b/tests/qtest/libqos/meson.build
@@ -0,0 +1,57 @@
+libqos = static_library('qos',
+ files('../libqtest.c',
+ 'qgraph.c',
+ 'qos_external.c',
+ 'pci.c',
+ 'fw_cfg.c',
+ 'malloc.c',
+ 'libqos.c',
+
+ # spapr
+ 'malloc-spapr.c',
+ 'libqos-spapr.c',
+ 'rtas.c',
+ 'pci-spapr.c',
+
+ # pc
+ 'pci-pc.c',
+ 'malloc-pc.c',
+ 'libqos-pc.c',
+ 'ahci.c',
+
+ # usb
+ 'usb.c',
+
+ # qgraph devices:
+ 'e1000e.c',
+ 'i2c.c',
+ 'i2c-imx.c',
+ 'i2c-omap.c',
+ 'sdhci.c',
+ 'tpci200.c',
+ 'virtio.c',
+ 'virtio-9p.c',
+ 'virtio-balloon.c',
+ 'virtio-blk.c',
+ 'virtio-mmio.c',
+ 'virtio-net.c',
+ 'virtio-pci.c',
+ 'virtio-pci-modern.c',
+ 'virtio-rng.c',
+ 'virtio-scsi.c',
+ 'virtio-serial.c',
+
+ # qgraph machines:
+ 'aarch64-xlnx-zcu102-machine.c',
+ 'arm-imx25-pdk-machine.c',
+ 'arm-n800-machine.c',
+ 'arm-raspi2-machine.c',
+ 'arm-sabrelite-machine.c',
+ 'arm-smdkc210-machine.c',
+ 'arm-virt-machine.c',
+ 'arm-xilinx-zynq-a9-machine.c',
+ 'ppc64_pseries-machine.c',
+ 'x86_64_pc-machine.c',
+), build_by_default: false)
+
+qos = declare_dependency(link_whole: libqos)
diff --git a/tests/qtest/libqos/pci-pc.c b/tests/qtest/libqos/pci-pc.c
index 3bb2eb3ba8..f97844289f 100644
--- a/tests/qtest/libqos/pci-pc.c
+++ b/tests/qtest/libqos/pci-pc.c
@@ -12,7 +12,7 @@
#include "qemu/osdep.h"
#include "libqtest.h"
-#include "libqos/pci-pc.h"
+#include "pci-pc.h"
#include "qapi/qmp/qdict.h"
#include "hw/pci/pci_regs.h"
diff --git a/tests/qtest/libqos/pci-pc.h b/tests/qtest/libqos/pci-pc.h
index 4690005232..49ec9507f2 100644
--- a/tests/qtest/libqos/pci-pc.h
+++ b/tests/qtest/libqos/pci-pc.h
@@ -13,9 +13,9 @@
#ifndef LIBQOS_PCI_PC_H
#define LIBQOS_PCI_PC_H
-#include "libqos/pci.h"
-#include "libqos/malloc.h"
-#include "libqos/qgraph.h"
+#include "pci.h"
+#include "malloc.h"
+#include "qgraph.h"
typedef struct QPCIBusPC {
QOSGraphObject obj;
diff --git a/tests/qtest/libqos/pci-spapr.c b/tests/qtest/libqos/pci-spapr.c
index d6f8c01cb7..262226985f 100644
--- a/tests/qtest/libqos/pci-spapr.c
+++ b/tests/qtest/libqos/pci-spapr.c
@@ -7,9 +7,9 @@
#include "qemu/osdep.h"
#include "libqtest.h"
-#include "libqos/pci-spapr.h"
-#include "libqos/rtas.h"
-#include "libqos/qgraph.h"
+#include "pci-spapr.h"
+#include "rtas.h"
+#include "qgraph.h"
#include "hw/pci/pci_regs.h"
diff --git a/tests/qtest/libqos/pci-spapr.h b/tests/qtest/libqos/pci-spapr.h
index d9e25631c6..20a43718b7 100644
--- a/tests/qtest/libqos/pci-spapr.h
+++ b/tests/qtest/libqos/pci-spapr.h
@@ -8,9 +8,9 @@
#ifndef LIBQOS_PCI_SPAPR_H
#define LIBQOS_PCI_SPAPR_H
-#include "libqos/malloc.h"
-#include "libqos/pci.h"
-#include "libqos/qgraph.h"
+#include "malloc.h"
+#include "pci.h"
+#include "qgraph.h"
/* From include/hw/pci-host/spapr.h */
diff --git a/tests/qtest/libqos/pci.c b/tests/qtest/libqos/pci.c
index 2309a724e4..e1e96189c8 100644
--- a/tests/qtest/libqos/pci.c
+++ b/tests/qtest/libqos/pci.c
@@ -11,11 +11,11 @@
*/
#include "qemu/osdep.h"
-#include "libqos/pci.h"
+#include "pci.h"
#include "hw/pci/pci_regs.h"
#include "qemu/host-utils.h"
-#include "libqos/qgraph.h"
+#include "qgraph.h"
void qpci_device_foreach(QPCIBus *bus, int vendor_id, int device_id,
void (*func)(QPCIDevice *dev, int devfn, void *data),
diff --git a/tests/qtest/libqos/pci.h b/tests/qtest/libqos/pci.h
index 590c175190..ee64fdecbd 100644
--- a/tests/qtest/libqos/pci.h
+++ b/tests/qtest/libqos/pci.h
@@ -14,7 +14,7 @@
#define LIBQOS_PCI_H
#include "libqtest.h"
-#include "libqos/qgraph.h"
+#include "qgraph.h"
#define QPCI_PIO_LIMIT 0x10000
diff --git a/tests/qtest/libqos/ppc64_pseries-machine.c b/tests/qtest/libqos/ppc64_pseries-machine.c
index 5d7bd88f2f..24ca179976 100644
--- a/tests/qtest/libqos/ppc64_pseries-machine.c
+++ b/tests/qtest/libqos/ppc64_pseries-machine.c
@@ -18,10 +18,10 @@
#include "qemu/osdep.h"
#include "libqtest.h"
-#include "libqos/qgraph.h"
+#include "qgraph.h"
#include "pci-spapr.h"
#include "qemu/module.h"
-#include "libqos/malloc-spapr.h"
+#include "malloc-spapr.h"
typedef struct QSPAPR_pci_host QSPAPR_pci_host;
typedef struct Qppc64_pseriesMachine Qppc64_pseriesMachine;
diff --git a/tests/qtest/libqos/qgraph.c b/tests/qtest/libqos/qgraph.c
index eb0af8ab4a..fc49cfa879 100644
--- a/tests/qtest/libqos/qgraph.c
+++ b/tests/qtest/libqos/qgraph.c
@@ -19,8 +19,8 @@
#include "qemu/osdep.h"
#include "libqtest.h"
#include "qemu/queue.h"
-#include "libqos/qgraph_internal.h"
-#include "libqos/qgraph.h"
+#include "qgraph_internal.h"
+#include "qgraph.h"
#define QGRAPH_PRINT_DEBUG 0
#define QOS_ROOT ""
diff --git a/tests/qtest/libqos/qgraph.h b/tests/qtest/libqos/qgraph.h
index db1244eb59..5f63d352ca 100644
--- a/tests/qtest/libqos/qgraph.h
+++ b/tests/qtest/libqos/qgraph.h
@@ -106,7 +106,7 @@ typedef void *(*QOSBeforeTest) (GString *cmd_line, void *arg);
* <example>
* <title>Creating new driver an its interface</title>
* <programlisting>
- #include "libqos/qgraph.h"
+ #include "qgraph.h"
struct My_driver {
QOSGraphObject obj;
@@ -190,7 +190,7 @@ typedef void *(*QOSBeforeTest) (GString *cmd_line, void *arg);
* <example>
* <title>Creating new test</title>
* <programlisting>
- * #include "libqos/qgraph.h"
+ * #include "qgraph.h"
*
* static void my_test_function(void *obj, void *data)
* {
@@ -226,11 +226,11 @@ typedef void *(*QOSBeforeTest) (GString *cmd_line, void *arg);
* my_test <--consumed_by-- my_interface <--produces--+
*
* Assuming there the binary is
- * QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64
+ * QTEST_QEMU_BINARY=./qemu-system-x86_64
* a valid test path will be:
* "/x86_64/pc/other_node/my_driver/my_interface/my_test".
*
- * Additional examples are also in libqos/test-qgraph.c
+ * Additional examples are also in test-qgraph.c
*
* Command line:
* Command line is built by using node names and optional arguments
diff --git a/tests/qtest/libqos/qgraph_internal.h b/tests/qtest/libqos/qgraph_internal.h
index aa3123f0f2..968fa69450 100644
--- a/tests/qtest/libqos/qgraph_internal.h
+++ b/tests/qtest/libqos/qgraph_internal.h
@@ -20,11 +20,11 @@
#define QGRAPH_INTERNAL_H
/* This header is declaring additional helper functions defined in
- * libqos/qgraph.c
+ * qgraph.c
* It should not be included in tests
*/
-#include "libqos/qgraph.h"
+#include "qgraph.h"
typedef struct QOSGraphMachine QOSGraphMachine;
typedef enum QOSEdgeType QOSEdgeType;
diff --git a/tests/qtest/libqos/qos_external.c b/tests/qtest/libqos/qos_external.c
index 0dfc05cfb6..10ee0f75b2 100644
--- a/tests/qtest/libqos/qos_external.c
+++ b/tests/qtest/libqos/qos_external.c
@@ -24,10 +24,10 @@
#include "qapi/qmp/qstring.h"
#include "qemu/module.h"
#include "qapi/qmp/qlist.h"
-#include "libqos/malloc.h"
-#include "libqos/qgraph.h"
-#include "libqos/qgraph_internal.h"
-#include "libqos/qos_external.h"
+#include "malloc.h"
+#include "qgraph.h"
+#include "qgraph_internal.h"
+#include "qos_external.h"
static void machine_apply_to_node(const char *name)
{
diff --git a/tests/qtest/libqos/qos_external.h b/tests/qtest/libqos/qos_external.h
index 56a2f37fde..8446e3df0b 100644
--- a/tests/qtest/libqos/qos_external.h
+++ b/tests/qtest/libqos/qos_external.h
@@ -19,7 +19,9 @@
#ifndef QOS_EXTERNAL_H
#define QOS_EXTERNAL_H
-#include "libqos/malloc.h"
+#include "qgraph.h"
+
+#include "malloc.h"
#include "qapi/qapi-types-machine.h"
#include "qapi/qapi-types-qom.h"
diff --git a/tests/qtest/libqos/rtas.c b/tests/qtest/libqos/rtas.c
index d81ff4274d..db29d5554d 100644
--- a/tests/qtest/libqos/rtas.c
+++ b/tests/qtest/libqos/rtas.c
@@ -5,7 +5,7 @@
#include "qemu/osdep.h"
#include "libqtest.h"
-#include "libqos/rtas.h"
+#include "rtas.h"
static void qrtas_copy_args(QTestState *qts, uint64_t target_args,
uint32_t nargs, uint32_t *args)
diff --git a/tests/qtest/libqos/rtas.h b/tests/qtest/libqos/rtas.h
index 459e23aaf4..f38f99dfab 100644
--- a/tests/qtest/libqos/rtas.h
+++ b/tests/qtest/libqos/rtas.h
@@ -5,7 +5,7 @@
#ifndef LIBQOS_RTAS_H
#define LIBQOS_RTAS_H
-#include "libqos/malloc.h"
+#include "malloc.h"
int qrtas_get_time_of_day(QTestState *qts, QGuestAllocator *alloc,
struct tm *tm, uint32_t *ns);
diff --git a/tests/qtest/libqos/sdhci.c b/tests/qtest/libqos/sdhci.c
index fbf2e36aec..65f0d07fc5 100644
--- a/tests/qtest/libqos/sdhci.c
+++ b/tests/qtest/libqos/sdhci.c
@@ -18,7 +18,7 @@
#include "qemu/osdep.h"
#include "libqtest.h"
-#include "libqos/qgraph.h"
+#include "qgraph.h"
#include "pci.h"
#include "qemu/module.h"
#include "sdhci.h"
diff --git a/tests/qtest/libqos/sdhci.h b/tests/qtest/libqos/sdhci.h
index 1acd3096e2..22d647b1fd 100644
--- a/tests/qtest/libqos/sdhci.h
+++ b/tests/qtest/libqos/sdhci.h
@@ -19,7 +19,7 @@
#ifndef QGRAPH_QSDHCI_H
#define QGRAPH_QSDHCI_H
-#include "libqos/qgraph.h"
+#include "qgraph.h"
#include "pci.h"
typedef struct QSDHCI QSDHCI;
diff --git a/tests/qtest/libqos/tpci200.c b/tests/qtest/libqos/tpci200.c
index ae590a456e..1787b1f188 100644
--- a/tests/qtest/libqos/tpci200.c
+++ b/tests/qtest/libqos/tpci200.c
@@ -10,8 +10,8 @@
#include "qemu/osdep.h"
#include "libqtest.h"
#include "qemu/module.h"
-#include "libqos/qgraph.h"
-#include "libqos/pci.h"
+#include "qgraph.h"
+#include "pci.h"
typedef struct QTpci200 QTpci200;
typedef struct QIpack QIpack;
diff --git a/tests/qtest/libqos/usb.c b/tests/qtest/libqos/usb.c
index d7a9cb3c72..8b45b02984 100644
--- a/tests/qtest/libqos/usb.c
+++ b/tests/qtest/libqos/usb.c
@@ -14,7 +14,7 @@
#include "qemu/osdep.h"
#include "libqtest.h"
#include "hw/usb/uhci-regs.h"
-#include "libqos/usb.h"
+#include "usb.h"
void qusb_pci_init_one(QPCIBus *pcibus, struct qhc *hc, uint32_t devfn, int bar)
{
diff --git a/tests/qtest/libqos/usb.h b/tests/qtest/libqos/usb.h
index eeced39a2f..50030d7fb1 100644
--- a/tests/qtest/libqos/usb.h
+++ b/tests/qtest/libqos/usb.h
@@ -1,7 +1,7 @@
#ifndef LIBQOS_USB_H
#define LIBQOS_USB_H
-#include "libqos/pci-pc.h"
+#include "pci-pc.h"
struct qhc {
QPCIDevice *dev;
diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c
index c87b56132a..2e300063e3 100644
--- a/tests/qtest/libqos/virtio-9p.c
+++ b/tests/qtest/libqos/virtio-9p.c
@@ -20,8 +20,8 @@
#include "libqtest.h"
#include "qemu/module.h"
#include "standard-headers/linux/virtio_ids.h"
-#include "libqos/virtio-9p.h"
-#include "libqos/qgraph.h"
+#include "virtio-9p.h"
+#include "qgraph.h"
static QGuestAllocator *alloc;
diff --git a/tests/qtest/libqos/virtio-9p.h b/tests/qtest/libqos/virtio-9p.h
index be9621a5e3..b1e6badc4a 100644
--- a/tests/qtest/libqos/virtio-9p.h
+++ b/tests/qtest/libqos/virtio-9p.h
@@ -19,9 +19,9 @@
#ifndef TESTS_LIBQOS_VIRTIO_9P_H
#define TESTS_LIBQOS_VIRTIO_9P_H
-#include "libqos/qgraph.h"
-#include "libqos/virtio.h"
-#include "libqos/virtio-pci.h"
+#include "qgraph.h"
+#include "virtio.h"
+#include "virtio-pci.h"
typedef struct QVirtio9P QVirtio9P;
typedef struct QVirtio9PPCI QVirtio9PPCI;
diff --git a/tests/qtest/libqos/virtio-balloon.c b/tests/qtest/libqos/virtio-balloon.c
index 9745f4a83c..a3da5c234d 100644
--- a/tests/qtest/libqos/virtio-balloon.c
+++ b/tests/qtest/libqos/virtio-balloon.c
@@ -19,8 +19,8 @@
#include "qemu/osdep.h"
#include "libqtest.h"
#include "qemu/module.h"
-#include "libqos/qgraph.h"
-#include "libqos/virtio-balloon.h"
+#include "qgraph.h"
+#include "virtio-balloon.h"
/* virtio-balloon-device */
static void *qvirtio_balloon_get_driver(QVirtioBalloon *v_balloon,
diff --git a/tests/qtest/libqos/virtio-balloon.h b/tests/qtest/libqos/virtio-balloon.h
index 5b919303a6..309894c338 100644
--- a/tests/qtest/libqos/virtio-balloon.h
+++ b/tests/qtest/libqos/virtio-balloon.h
@@ -19,9 +19,9 @@
#ifndef TESTS_LIBQOS_VIRTIO_BALLOON_H
#define TESTS_LIBQOS_VIRTIO_BALLOON_H
-#include "libqos/qgraph.h"
-#include "libqos/virtio.h"
-#include "libqos/virtio-pci.h"
+#include "qgraph.h"
+#include "virtio.h"
+#include "virtio-pci.h"
typedef struct QVirtioBalloon QVirtioBalloon;
typedef struct QVirtioBalloonPCI QVirtioBalloonPCI;
diff --git a/tests/qtest/libqos/virtio-blk.c b/tests/qtest/libqos/virtio-blk.c
index 5fc69401be..5da02591bc 100644
--- a/tests/qtest/libqos/virtio-blk.c
+++ b/tests/qtest/libqos/virtio-blk.c
@@ -20,8 +20,8 @@
#include "libqtest.h"
#include "qemu/module.h"
#include "standard-headers/linux/virtio_blk.h"
-#include "libqos/qgraph.h"
-#include "libqos/virtio-blk.h"
+#include "qgraph.h"
+#include "virtio-blk.h"
#define PCI_SLOT 0x04
#define PCI_FN 0x00
diff --git a/tests/qtest/libqos/virtio-blk.h b/tests/qtest/libqos/virtio-blk.h
index 5170f13cfe..dcef38851e 100644
--- a/tests/qtest/libqos/virtio-blk.h
+++ b/tests/qtest/libqos/virtio-blk.h
@@ -19,9 +19,9 @@
#ifndef TESTS_LIBQOS_VIRTIO_BLK_H
#define TESTS_LIBQOS_VIRTIO_BLK_H
-#include "libqos/qgraph.h"
-#include "libqos/virtio.h"
-#include "libqos/virtio-pci.h"
+#include "qgraph.h"
+#include "virtio.h"
+#include "virtio-pci.h"
typedef struct QVirtioBlk QVirtioBlk;
typedef struct QVirtioBlkPCI QVirtioBlkPCI;
diff --git a/tests/qtest/libqos/virtio-mmio.c b/tests/qtest/libqos/virtio-mmio.c
index e0a2bd7bc6..75efda3029 100644
--- a/tests/qtest/libqos/virtio-mmio.c
+++ b/tests/qtest/libqos/virtio-mmio.c
@@ -10,10 +10,10 @@
#include "qemu/osdep.h"
#include "libqtest.h"
#include "qemu/module.h"
-#include "libqos/virtio.h"
-#include "libqos/virtio-mmio.h"
-#include "libqos/malloc.h"
-#include "libqos/qgraph.h"
+#include "virtio.h"
+#include "virtio-mmio.h"
+#include "malloc.h"
+#include "qgraph.h"
#include "standard-headers/linux/virtio_ring.h"
static uint8_t qvirtio_mmio_config_readb(QVirtioDevice *d, uint64_t off)
diff --git a/tests/qtest/libqos/virtio-mmio.h b/tests/qtest/libqos/virtio-mmio.h
index 0e45778b07..30803bc91c 100644
--- a/tests/qtest/libqos/virtio-mmio.h
+++ b/tests/qtest/libqos/virtio-mmio.h
@@ -10,8 +10,8 @@
#ifndef LIBQOS_VIRTIO_MMIO_H
#define LIBQOS_VIRTIO_MMIO_H
-#include "libqos/virtio.h"
-#include "libqos/qgraph.h"
+#include "virtio.h"
+#include "qgraph.h"
#define QVIRTIO_MMIO_MAGIC_VALUE 0x000
#define QVIRTIO_MMIO_VERSION 0x004
diff --git a/tests/qtest/libqos/virtio-net.c b/tests/qtest/libqos/virtio-net.c
index a9e253afe4..1cae07f60d 100644
--- a/tests/qtest/libqos/virtio-net.c
+++ b/tests/qtest/libqos/virtio-net.c
@@ -19,8 +19,8 @@
#include "qemu/osdep.h"
#include "libqtest.h"
#include "qemu/module.h"
-#include "libqos/qgraph.h"
-#include "libqos/virtio-net.h"
+#include "qgraph.h"
+#include "virtio-net.h"
#include "hw/virtio/virtio-net.h"
diff --git a/tests/qtest/libqos/virtio-net.h b/tests/qtest/libqos/virtio-net.h
index b8cbec04af..5ba2161de2 100644
--- a/tests/qtest/libqos/virtio-net.h
+++ b/tests/qtest/libqos/virtio-net.h
@@ -19,9 +19,9 @@
#ifndef TESTS_LIBQOS_VIRTIO_NET_H
#define TESTS_LIBQOS_VIRTIO_NET_H
-#include "libqos/qgraph.h"
-#include "libqos/virtio.h"
-#include "libqos/virtio-pci.h"
+#include "qgraph.h"
+#include "virtio.h"
+#include "virtio-pci.h"
typedef struct QVirtioNet QVirtioNet;
typedef struct QVirtioNetPCI QVirtioNetPCI;
diff --git a/tests/qtest/libqos/virtio-pci.c b/tests/qtest/libqos/virtio-pci.c
index 62851c29bb..cd3c0f5bf3 100644
--- a/tests/qtest/libqos/virtio-pci.c
+++ b/tests/qtest/libqos/virtio-pci.c
@@ -9,13 +9,13 @@
#include "qemu/osdep.h"
#include "libqtest.h"
-#include "libqos/virtio.h"
-#include "libqos/virtio-pci.h"
-#include "libqos/pci.h"
-#include "libqos/pci-pc.h"
-#include "libqos/malloc.h"
-#include "libqos/malloc-pc.h"
-#include "libqos/qgraph.h"
+#include "virtio.h"
+#include "virtio-pci.h"
+#include "pci.h"
+#include "pci-pc.h"
+#include "malloc.h"
+#include "malloc-pc.h"
+#include "qgraph.h"
#include "standard-headers/linux/virtio_ring.h"
#include "standard-headers/linux/virtio_pci.h"
diff --git a/tests/qtest/libqos/virtio-pci.h b/tests/qtest/libqos/virtio-pci.h
index 294d5567ee..f5115cacba 100644
--- a/tests/qtest/libqos/virtio-pci.h
+++ b/tests/qtest/libqos/virtio-pci.h
@@ -10,9 +10,9 @@
#ifndef LIBQOS_VIRTIO_PCI_H
#define LIBQOS_VIRTIO_PCI_H
-#include "libqos/virtio.h"
-#include "libqos/pci.h"
-#include "libqos/qgraph.h"
+#include "virtio.h"
+#include "pci.h"
+#include "qgraph.h"
typedef struct QVirtioPCIMSIXOps QVirtioPCIMSIXOps;
diff --git a/tests/qtest/libqos/virtio-rng.c b/tests/qtest/libqos/virtio-rng.c
index 46f8d95b1f..2e09dd7c48 100644
--- a/tests/qtest/libqos/virtio-rng.c
+++ b/tests/qtest/libqos/virtio-rng.c
@@ -19,8 +19,8 @@
#include "qemu/osdep.h"
#include "libqtest.h"
#include "qemu/module.h"
-#include "libqos/qgraph.h"
-#include "libqos/virtio-rng.h"
+#include "qgraph.h"
+#include "virtio-rng.h"
/* virtio-rng-device */
static void *qvirtio_rng_get_driver(QVirtioRng *v_rng,
diff --git a/tests/qtest/libqos/virtio-rng.h b/tests/qtest/libqos/virtio-rng.h
index 9342372efa..9ca102b599 100644
--- a/tests/qtest/libqos/virtio-rng.h
+++ b/tests/qtest/libqos/virtio-rng.h
@@ -19,9 +19,9 @@
#ifndef TESTS_LIBQOS_VIRTIO_RNG_H
#define TESTS_LIBQOS_VIRTIO_RNG_H
-#include "libqos/qgraph.h"
-#include "libqos/virtio.h"
-#include "libqos/virtio-pci.h"
+#include "qgraph.h"
+#include "virtio.h"
+#include "virtio-pci.h"
typedef struct QVirtioRng QVirtioRng;
typedef struct QVirtioRngPCI QVirtioRngPCI;
diff --git a/tests/qtest/libqos/virtio-scsi.c b/tests/qtest/libqos/virtio-scsi.c
index c8c3598428..5644e32fc3 100644
--- a/tests/qtest/libqos/virtio-scsi.c
+++ b/tests/qtest/libqos/virtio-scsi.c
@@ -20,8 +20,8 @@
#include "libqtest.h"
#include "qemu/module.h"
#include "standard-headers/linux/virtio_ids.h"
-#include "libqos/qgraph.h"
-#include "libqos/virtio-scsi.h"
+#include "qgraph.h"
+#include "virtio-scsi.h"
/* virtio-scsi-device */
static void *qvirtio_scsi_get_driver(QVirtioSCSI *v_scsi,
diff --git a/tests/qtest/libqos/virtio-scsi.h b/tests/qtest/libqos/virtio-scsi.h
index 9e3774d99a..531315e6ad 100644
--- a/tests/qtest/libqos/virtio-scsi.h
+++ b/tests/qtest/libqos/virtio-scsi.h
@@ -19,9 +19,9 @@
#ifndef TESTS_LIBQOS_VIRTIO_SCSI_H
#define TESTS_LIBQOS_VIRTIO_SCSI_H
-#include "libqos/qgraph.h"
-#include "libqos/virtio.h"
-#include "libqos/virtio-pci.h"
+#include "qgraph.h"
+#include "virtio.h"
+#include "virtio-pci.h"
typedef struct QVirtioSCSI QVirtioSCSI;
typedef struct QVirtioSCSIPCI QVirtioSCSIPCI;
diff --git a/tests/qtest/libqos/virtio-serial.c b/tests/qtest/libqos/virtio-serial.c
index b95654085d..ee34afd95a 100644
--- a/tests/qtest/libqos/virtio-serial.c
+++ b/tests/qtest/libqos/virtio-serial.c
@@ -19,8 +19,8 @@
#include "qemu/osdep.h"
#include "libqtest.h"
#include "qemu/module.h"
-#include "libqos/qgraph.h"
-#include "libqos/virtio-serial.h"
+#include "qgraph.h"
+#include "virtio-serial.h"
static void *qvirtio_serial_get_driver(QVirtioSerial *v_serial,
const char *interface)
diff --git a/tests/qtest/libqos/virtio-serial.h b/tests/qtest/libqos/virtio-serial.h
index 3328c6cf19..3db43b2bb8 100644
--- a/tests/qtest/libqos/virtio-serial.h
+++ b/tests/qtest/libqos/virtio-serial.h
@@ -19,9 +19,9 @@
#ifndef TESTS_LIBQOS_VIRTIO_SERIAL_H
#define TESTS_LIBQOS_VIRTIO_SERIAL_H
-#include "libqos/qgraph.h"
-#include "libqos/virtio.h"
-#include "libqos/virtio-pci.h"
+#include "qgraph.h"
+#include "virtio.h"
+#include "virtio-pci.h"
typedef struct QVirtioSerial QVirtioSerial;
typedef struct QVirtioSerialPCI QVirtioSerialPCI;
diff --git a/tests/qtest/libqos/virtio.c b/tests/qtest/libqos/virtio.c
index 9aa360620c..6fe7bf9555 100644
--- a/tests/qtest/libqos/virtio.c
+++ b/tests/qtest/libqos/virtio.c
@@ -10,7 +10,7 @@
#include "qemu/osdep.h"
#include "qemu/bswap.h"
#include "libqtest.h"
-#include "libqos/virtio.h"
+#include "virtio.h"
#include "standard-headers/linux/virtio_config.h"
#include "standard-headers/linux/virtio_ring.h"
diff --git a/tests/qtest/libqos/virtio.h b/tests/qtest/libqos/virtio.h
index 529ef7555a..b8bd06e1b8 100644
--- a/tests/qtest/libqos/virtio.h
+++ b/tests/qtest/libqos/virtio.h
@@ -10,7 +10,7 @@
#ifndef LIBQOS_VIRTIO_H
#define LIBQOS_VIRTIO_H
-#include "libqos/malloc.h"
+#include "malloc.h"
#include "standard-headers/linux/virtio_ring.h"
#define QVIRTIO_F_BAD_FEATURE 0x40000000ull
diff --git a/tests/qtest/libqos/x86_64_pc-machine.c b/tests/qtest/libqos/x86_64_pc-machine.c
index 0edb1c9144..ad96742a92 100644
--- a/tests/qtest/libqos/x86_64_pc-machine.c
+++ b/tests/qtest/libqos/x86_64_pc-machine.c
@@ -18,7 +18,7 @@
#include "qemu/osdep.h"
#include "libqtest.h"
-#include "libqos/qgraph.h"
+#include "qgraph.h"
#include "pci-pc.h"
#include "qemu/module.h"
#include "malloc-pc.h"
diff --git a/tests/qtest/libqtest-single.h b/tests/qtest/libqtest-single.h
index 6f1bb1331c..176979a2ce 100644
--- a/tests/qtest/libqtest-single.h
+++ b/tests/qtest/libqtest-single.h
@@ -11,7 +11,7 @@
#ifndef LIBQTEST_SINGLE_H
#define LIBQTEST_SINGLE_H
-#include "libqtest.h"
+#include "libqos/libqtest.h"
QTestState *global_qtest __attribute__((common, weak));
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index fd4680590d..26f1223642 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -20,7 +20,7 @@
#include <sys/wait.h>
#include <sys/un.h>
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu-common.h"
#include "qemu/ctype.h"
#include "qemu/cutils.h"
diff --git a/tests/qtest/m48t59-test.c b/tests/qtest/m48t59-test.c
index b94a1230f7..6db3234100 100644
--- a/tests/qtest/m48t59-test.c
+++ b/tests/qtest/m48t59-test.c
@@ -14,7 +14,7 @@
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#define RTC_SECONDS 0x9
#define RTC_MINUTES 0xa
diff --git a/tests/qtest/machine-none-test.c b/tests/qtest/machine-none-test.c
index 57107f1aec..aab06b9fc2 100644
--- a/tests/qtest/machine-none-test.c
+++ b/tests/qtest/machine-none-test.c
@@ -14,7 +14,7 @@
#include "qemu-common.h"
#include "qemu/cutils.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qapi/qmp/qdict.h"
diff --git a/tests/qtest/megasas-test.c b/tests/qtest/megasas-test.c
index d6796b9bd7..eae70ff95f 100644
--- a/tests/qtest/megasas-test.c
+++ b/tests/qtest/megasas-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/bswap.h"
#include "qemu/module.h"
#include "libqos/qgraph.h"
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
new file mode 100644
index 0000000000..8f8fdb1336
--- /dev/null
+++ b/tests/qtest/meson.build
@@ -0,0 +1,257 @@
+# All QTests for now are POSIX-only, but the dependencies are
+# really in libqtest, not in the testcases themselves.
+if not config_host.has_key('CONFIG_POSIX')
+ subdir_done()
+endif
+
+qtests_generic = [
+ 'cdrom-test',
+ 'device-introspect-test',
+ 'machine-none-test',
+ 'qmp-test',
+ 'qmp-cmd-test',
+ 'qom-test',
+ 'test-hmp',
+ 'qos-test',
+]
+if config_host.has_key('CONFIG_MODULES')
+ qtests_generic += [ 'modules-test' ]
+endif
+
+qtests_pci = \
+ (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_IVSHMEM_DEVICE') ? ['ivshmem-test'] : [])
+
+qtests_i386 = \
+ (config_host.has_key('CONFIG_SLIRP') ? ['pxe-test', 'test-netfilter'] : []) + \
+ (config_host.has_key('CONFIG_POSIX') ? ['test-filter-mirror'] : []) + \
+ (have_tools ? ['ahci-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_SGA') ? ['boot-serial-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_RTL8139_PCI') ? ['test-filter-redirector'] : []) + \
+ (config_all_devices.has_key('CONFIG_ISA_IPMI_KCS') ? ['ipmi-kcs-test'] : []) + \
+ (config_host.has_key('CONFIG_LINUX') and \
+ config_all_devices.has_key('CONFIG_ISA_IPMI_BT') ? ['ipmi-bt-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_WDT_IB700') ? ['wdt_ib700-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_PVPANIC') ? ['pvpanic-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_HDA') ? ['intel-hda-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_I82801B11') ? ['i82801b11-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_IOH3420') ? ['ioh3420-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_USB_UHCI') ? ['usb-hcd-uhci-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_USB_UHCI') and \
+ config_all_devices.has_key('CONFIG_USB_EHCI') ? ['usb-hcd-ehci-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_USB_XHCI_NEC') ? ['usb-hcd-xhci-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_TPM_CRB') ? ['tpm-crb-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_TPM_CRB') ? ['tpm-crb-swtpm-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_TPM_TIS_ISA') ? ['tpm-tis-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_TPM_TIS_ISA') ? ['tpm-tis-swtpm-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_RTL8139_PCI') ? ['rtl8139-test'] : []) + \
+ qtests_pci + \
+ ['fdc-test',
+ 'ide-test',
+ 'ahci-test',
+ 'hd-geo-test',
+ 'boot-order-test',
+ 'bios-tables-test',
+ 'rtc-test',
+ 'i440fx-test',
+ 'fw_cfg-test',
+ 'device-plug-test',
+ 'drive_del-test',
+ 'tco-test',
+ 'cpu-plug-test',
+ 'q35-test',
+ 'vmgenid-test',
+ 'migration-test',
+ 'test-x86-cpuid-compat',
+ 'numa-test']
+
+dbus_daemon = find_program('dbus-daemon', required: false)
+if dbus_daemon.found() and config_host.has_key('GDBUS_CODEGEN')
+ # Temporarily disabled due to Patchew failures:
+ #qtests_i386 += ['dbus-vmstate-test']
+ dbus_vmstate1 = custom_target('dbus-vmstate description',
+ output: ['dbus-vmstate1.h', 'dbus-vmstate1.c'],
+ input: files('dbus-vmstate1.xml'),
+ command: [config_host['GDBUS_CODEGEN'],
+ '@INPUT@',
+ '--interface-prefix', 'org.qemu',
+ '--generate-c-code', '@BASENAME@']).to_list()
+else
+ dbus_vmstate1 = []
+endif
+
+qtests_x86_64 = qtests_i386
+
+qtests_alpha = [ 'boot-serial-test' ] + \
+ (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : [])
+
+qtests_avr = [ 'boot-serial-test' ]
+
+qtests_hppa = [ 'boot-serial-test' ] + \
+ (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : [])
+
+qtests_m68k = [ 'boot-serial-test' ]
+qtests_microblaze = [ 'boot-serial-test' ]
+qtests_microblazeel = qtests_microblaze
+
+qtests_mips = \
+ (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : [])
+
+qtests_mips64 = \
+ (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : [])
+
+qtests_mips64el = \
+ (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : [])
+
+qtests_moxie = [ 'boot-serial-test' ]
+
+qtests_ppc = \
+ (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_M48T59') ? ['m48t59-test'] : []) + \
+ ['boot-order-test', 'prom-env-test', 'drive_del-test', 'boot-serial-test'] \
+
+qtests_ppc64 = \
+ (config_all_devices.has_key('CONFIG_PSERIES') ? ['device-plug-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_POWERNV') ? ['pnv-xscom-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_PSERIES') ? ['rtas-test'] : []) + \
+ (config_host.has_key('CONFIG_SLIRP') ? ['pxe-test', 'test-netfilter'] : []) + \
+ (config_all_devices.has_key('CONFIG_USB_UHCI') ? ['usb-hcd-uhci-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_USB_XHCI_NEC') ? ['usb-hcd-xhci-test'] : []) + \
+ (config_host.has_key('CONFIG_POSIX') ? ['test-filter-mirror'] : []) + \
+ qtests_pci + ['migration-test', 'numa-test', 'cpu-plug-test']
+
+qtests_sh4 = (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : [])
+qtests_sh4eb = (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : [])
+
+qtests_sparc = ['prom-env-test', 'm48t59-test', 'boot-serial-test']
+
+qtests_sparc64 = \
+ (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) + \
+ ['prom-env-test', 'boot-serial-test']
+
+qtests_arm = \
+ (config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \
+ ['arm-cpu-features',
+ 'microbit-test',
+ 'm25p80-test',
+ 'test-arm-mptimer',
+ 'boot-serial-test',
+ 'hexloader-test']
+
+# TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional
+qtests_aarch64 = \
+ (cpu != 'arm' ? ['bios-tables-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-test'] : []) + \
+ (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-swtpm-test'] : []) + \
+ ['numa-test',
+ 'boot-serial-test',
+ 'migration-test']
+
+qtests_s390x = \
+ (config_host.has_key('CONFIG_SLIRP') ? ['pxe-test', 'test-netfilter'] : []) + \
+ (config_host.has_key('CONFIG_POSIX') ? ['test-filter-mirror'] : []) + \
+ (config_host.has_key('CONFIG_POSIX') ? ['test-filter-redirector'] : []) + \
+ ['boot-serial-test',
+ 'drive_del-test',
+ 'device-plug-test',
+ 'virtio-ccw-test',
+ 'cpu-plug-test',
+ 'migration-test']
+
+qos_test_ss = ss.source_set()
+qos_test_ss.add(
+ 'ac97-test.c',
+ 'ds1338-test.c',
+ 'e1000-test.c',
+ 'e1000e-test.c',
+ 'eepro100-test.c',
+ 'es1370-test.c',
+ 'ipoctal232-test.c',
+ 'megasas-test.c',
+ 'ne2000-test.c',
+ 'tulip-test.c',
+ 'nvme-test.c',
+ 'pca9552-test.c',
+ 'pci-test.c',
+ 'pcnet-test.c',
+ 'sdhci-test.c',
+ 'spapr-phb-test.c',
+ 'tmp105-test.c',
+ 'usb-hcd-ohci-test.c',
+ 'virtio-test.c',
+ 'virtio-blk-test.c',
+ 'virtio-net-test.c',
+ 'virtio-rng-test.c',
+ 'virtio-scsi-test.c',
+ 'virtio-serial-test.c',
+ 'vmxnet3-test.c',
+)
+qos_test_ss.add(when: 'CONFIG_VIRTFS', if_true: files('virtio-9p-test.c'))
+qos_test_ss.add(when: 'CONFIG_VHOST_USER', if_true: files('vhost-user-test.c'))
+
+extra_qtest_deps = {
+ 'bios-tables-test': [io],
+ 'ivshmem-test': [rt],
+ 'qos-test': [chardev, io],
+ 'tpm-crb-swtpm-test': [io],
+ 'tpm-crb-test': [io],
+ 'tpm-tis-swtpm-test': [io],
+ 'tpm-tis-test': [io],
+ 'tpm-tis-device-swtpm-test': [io],
+ 'tpm-tis-device-test': [io],
+}
+extra_qtest_srcs = {
+ 'bios-tables-test': files('boot-sector.c', 'acpi-utils.c', 'tpm-emu.c'),
+ 'pxe-test': files('boot-sector.c'),
+ 'cdrom-test': files('boot-sector.c'),
+ 'migration-test': files('migration-helpers.c'),
+ 'ivshmem-test': files('../../contrib/ivshmem-server/ivshmem-server.c'),
+ 'dbus-vmstate-test': files('migration-helpers.c') + dbus_vmstate1,
+ 'vmgenid-test': files('boot-sector.c', 'acpi-utils.c'),
+ 'tpm-crb-swtpm-test': files('tpm-emu.c', 'tpm-util.c', 'tpm-tests.c'),
+ 'tpm-crb-test': files('tpm-emu.c', 'tpm-util.c', 'tpm-tests.c'),
+ 'tpm-tis-device-swtpm-test': files('tpm-emu.c', 'tpm-util.c', 'tpm-tis-util.c', 'tpm-tests.c'),
+ 'tpm-tis-device-test': files('tpm-emu.c', 'tpm-util.c', 'tpm-tis-util.c', 'tpm-tests.c'),
+ 'tpm-tis-swtpm-test': files('tpm-emu.c', 'tpm-util.c', 'tpm-tis-util.c', 'tpm-tests.c'),
+ 'tpm-tis-test': files('tpm-emu.c', 'tpm-util.c', 'tpm-tis-util.c', 'tpm-tests.c'),
+ 'qos-test': qos_test_ss.apply(config_host, strict: false).sources()
+}
+
+
+qtest_executables = {}
+foreach dir : target_dirs
+ if not dir.endswith('-softmmu')
+ continue
+ endif
+
+ target_base = dir.split('-')[0]
+ qtests = get_variable('qtests_' + target_base, []) + qtests_generic
+
+ qtest_env = environment()
+ qtest_env.set('QTEST_QEMU_IMG', './qemu-img')
+ qtest_env.set('G_TEST_DBUS_DAEMON', meson.source_root() / 'tests/dbus-vmstate-daemon.sh')
+ qtest_env.set('QTEST_QEMU_BINARY', './qemu-system-' + target_base)
+
+ foreach test : qtests
+ # Executables are shared across targets, declare them only the first time we
+ # encounter them
+ if not qtest_executables.has_key(test)
+ qtest_executables += {
+ test: executable(test,
+ files(test + '.c') + extra_qtest_srcs.get(test, []),
+ dependencies: [qemuutil, qos] + extra_qtest_deps.get(test, []))
+ }
+ endif
+ # FIXME: missing dependency on the emulator binary and qemu-img
+ test('qtest-@0@: @1@'.format(target_base, test),
+ qtest_executables[test],
+ env: qtest_env,
+ args: ['--tap', '-k'],
+ protocol: 'tap',
+ suite: ['qtest', 'qtest-' + target_base])
+ endforeach
+endforeach
diff --git a/tests/qtest/microbit-test.c b/tests/qtest/microbit-test.c
index 04e199ec33..2b255579df 100644
--- a/tests/qtest/microbit-test.c
+++ b/tests/qtest/microbit-test.c
@@ -16,7 +16,7 @@
#include "qemu/osdep.h"
#include "exec/hwaddr.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "hw/arm/nrf51.h"
#include "hw/char/nrf51_uart.h"
diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helpers.h
index a11808b3b7..d63bba9630 100644
--- a/tests/qtest/migration-helpers.h
+++ b/tests/qtest/migration-helpers.h
@@ -12,7 +12,7 @@
#ifndef MIGRATION_HELPERS_H_
#define MIGRATION_HELPERS_H_
-#include "libqtest.h"
+#include "libqos/libqtest.h"
extern bool got_stop;
diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index 21ea5ba1d2..00a233cd8c 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -12,7 +12,7 @@
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qapi/error.h"
#include "qapi/qmp/qdict.h"
#include "qemu/module.h"
@@ -25,7 +25,7 @@
#include "qapi/qobject-output-visitor.h"
#include "migration-helpers.h"
-#include "migration/migration-test.h"
+#include "tests/migration/migration-test.h"
/* TODO actually test the results and get rid of this */
#define qtest_qmp_discard_response(...) qobject_unref(qtest_qmp(__VA_ARGS__))
diff --git a/tests/qtest/modules-test.c b/tests/qtest/modules-test.c
index 88217686e1..c238b3f422 100644
--- a/tests/qtest/modules-test.c
+++ b/tests/qtest/modules-test.c
@@ -1,5 +1,5 @@
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
const char common_args[] = "-nodefaults -machine none";
diff --git a/tests/qtest/ne2000-test.c b/tests/qtest/ne2000-test.c
index 3fc0e555d5..43cfc4535a 100644
--- a/tests/qtest/ne2000-test.c
+++ b/tests/qtest/ne2000-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/module.h"
#include "libqos/qgraph.h"
#include "libqos/pci.h"
diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c
index e1ed6d4322..b25ebf97d8 100644
--- a/tests/qtest/numa-test.c
+++ b/tests/qtest/numa-test.c
@@ -10,7 +10,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qlist.h"
diff --git a/tests/qtest/nvme-test.c b/tests/qtest/nvme-test.c
index ff0442150c..d32c953a38 100644
--- a/tests/qtest/nvme-test.c
+++ b/tests/qtest/nvme-test.c
@@ -10,7 +10,7 @@
#include "qemu/osdep.h"
#include "qemu/module.h"
#include "qemu/units.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "libqos/qgraph.h"
#include "libqos/pci.h"
diff --git a/tests/qtest/pca9552-test.c b/tests/qtest/pca9552-test.c
index d80ed93cd3..42a1312665 100644
--- a/tests/qtest/pca9552-test.c
+++ b/tests/qtest/pca9552-test.c
@@ -9,7 +9,7 @@
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "libqos/qgraph.h"
#include "libqos/i2c.h"
#include "hw/misc/pca9552_regs.h"
diff --git a/tests/qtest/pci-test.c b/tests/qtest/pci-test.c
index 4b2092b949..e15d4d94d1 100644
--- a/tests/qtest/pci-test.c
+++ b/tests/qtest/pci-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/module.h"
#include "libqos/qgraph.h"
#include "libqos/pci.h"
diff --git a/tests/qtest/pcnet-test.c b/tests/qtest/pcnet-test.c
index 900944fa7e..7583aeb3c3 100644
--- a/tests/qtest/pcnet-test.c
+++ b/tests/qtest/pcnet-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/module.h"
#include "libqos/qgraph.h"
#include "libqos/pci.h"
diff --git a/tests/qtest/pflash-cfi02-test.c b/tests/qtest/pflash-cfi02-test.c
index 17aa669b2e..afb702b565 100644
--- a/tests/qtest/pflash-cfi02-test.c
+++ b/tests/qtest/pflash-cfi02-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
/*
* To test the pflash_cfi02 device, we run QEMU with the musicpal machine with
diff --git a/tests/qtest/pnv-xscom-test.c b/tests/qtest/pnv-xscom-test.c
index 2c46d5cf6d..c8d4043362 100644
--- a/tests/qtest/pnv-xscom-test.c
+++ b/tests/qtest/pnv-xscom-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
typedef enum PnvChipType {
PNV_CHIP_POWER8E, /* AKA Murano (default) */
diff --git a/tests/qtest/prom-env-test.c b/tests/qtest/prom-env-test.c
index 60e6ec3153..f41d80154a 100644
--- a/tests/qtest/prom-env-test.c
+++ b/tests/qtest/prom-env-test.c
@@ -20,7 +20,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "libqos/libqos-spapr.h"
#define MAGIC 0xcafec0de
diff --git a/tests/qtest/pvpanic-test.c b/tests/qtest/pvpanic-test.c
index ff9176adf3..e57639481e 100644
--- a/tests/qtest/pvpanic-test.c
+++ b/tests/qtest/pvpanic-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qapi/qmp/qdict.h"
static void test_panic(void)
diff --git a/tests/qtest/pxe-test.c b/tests/qtest/pxe-test.c
index 1161a773a4..32bbae33c5 100644
--- a/tests/qtest/pxe-test.c
+++ b/tests/qtest/pxe-test.c
@@ -15,7 +15,7 @@
#include "qemu/osdep.h"
#include <glib/gstdio.h>
#include "qemu-common.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "boot-sector.h"
#include "libqos/libqos-spapr.h"
diff --git a/tests/qtest/q35-test.c b/tests/qtest/q35-test.c
index c922d81bc0..b7cf144990 100644
--- a/tests/qtest/q35-test.c
+++ b/tests/qtest/q35-test.c
@@ -10,7 +10,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "libqos/pci.h"
#include "libqos/pci-pc.h"
#include "hw/pci-host/q35.h"
diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c
index f7b1aa7fdc..f34e68858a 100644
--- a/tests/qtest/qmp-cmd-test.c
+++ b/tests/qtest/qmp-cmd-test.c
@@ -11,7 +11,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qapi/error.h"
#include "qapi/qapi-visit-introspect.h"
#include "qapi/qmp/qdict.h"
diff --git a/tests/qtest/qmp-test.c b/tests/qtest/qmp-test.c
index 1a8876b6ca..5950c3ebbb 100644
--- a/tests/qtest/qmp-test.c
+++ b/tests/qtest/qmp-test.c
@@ -11,7 +11,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qapi/error.h"
#include "qapi/qapi-visit-control.h"
#include "qapi/qmp/qdict.h"
diff --git a/tests/qtest/qom-test.c b/tests/qtest/qom-test.c
index 1acf0d7369..eb34af843b 100644
--- a/tests/qtest/qom-test.c
+++ b/tests/qtest/qom-test.c
@@ -13,7 +13,7 @@
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qlist.h"
#include "qemu/cutils.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
static void test_properties(QTestState *qts, const char *path, bool recurse)
{
diff --git a/tests/qtest/rtas-test.c b/tests/qtest/rtas-test.c
index 167b42db38..16751dbd2f 100644
--- a/tests/qtest/rtas-test.c
+++ b/tests/qtest/rtas-test.c
@@ -1,6 +1,6 @@
#include "qemu/osdep.h"
#include "qemu/cutils.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "libqos/libqos-spapr.h"
#include "libqos/rtas.h"
@@ -31,7 +31,7 @@ int main(int argc, char *argv[])
g_test_init(&argc, &argv, NULL);
if (strcmp(arch, "ppc64")) {
- g_printerr("RTAS requires ppc64-softmmu/qemu-system-ppc64\n");
+ g_printerr("RTAS requires qemu-system-ppc64\n");
exit(EXIT_FAILURE);
}
qtest_add_func("rtas/get-time-of-day", test_rtas_get_time_of_day);
diff --git a/tests/qtest/sdhci-test.c b/tests/qtest/sdhci-test.c
index 6275e7626c..a110cfe321 100644
--- a/tests/qtest/sdhci-test.c
+++ b/tests/qtest/sdhci-test.c
@@ -10,7 +10,7 @@
#include "qemu/osdep.h"
#include "hw/registerfields.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/module.h"
#include "libqos/pci-pc.h"
#include "hw/pci/pci.h"
diff --git a/tests/qtest/spapr-phb-test.c b/tests/qtest/spapr-phb-test.c
index 093dc22f2f..ea8d596507 100644
--- a/tests/qtest/spapr-phb-test.c
+++ b/tests/qtest/spapr-phb-test.c
@@ -9,7 +9,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/module.h"
#include "libqos/qgraph.h"
diff --git a/tests/qtest/tco-test.c b/tests/qtest/tco-test.c
index 254f735370..47bc7ad301 100644
--- a/tests/qtest/tco-test.c
+++ b/tests/qtest/tco-test.c
@@ -9,7 +9,7 @@
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "libqos/pci.h"
#include "libqos/pci-pc.h"
#include "qapi/qmp/qdict.h"
diff --git a/tests/qtest/test-filter-mirror.c b/tests/qtest/test-filter-mirror.c
index 1e3ced84a9..bc0dee64dd 100644
--- a/tests/qtest/test-filter-mirror.c
+++ b/tests/qtest/test-filter-mirror.c
@@ -10,7 +10,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qapi/qmp/qdict.h"
#include "qemu/iov.h"
#include "qemu/sockets.h"
diff --git a/tests/qtest/test-filter-redirector.c b/tests/qtest/test-filter-redirector.c
index e4d53220fd..829db8c2ea 100644
--- a/tests/qtest/test-filter-redirector.c
+++ b/tests/qtest/test-filter-redirector.c
@@ -52,7 +52,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qapi/qmp/qdict.h"
#include "qemu/iov.h"
#include "qemu/sockets.h"
diff --git a/tests/qtest/test-hmp.c b/tests/qtest/test-hmp.c
index d5e7ebd176..aea1384bac 100644
--- a/tests/qtest/test-hmp.c
+++ b/tests/qtest/test-hmp.c
@@ -15,7 +15,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
static int verbose;
diff --git a/tests/qtest/tpm-crb-swtpm-test.c b/tests/qtest/tpm-crb-swtpm-test.c
index 55fdb5657d..1d82a48c04 100644
--- a/tests/qtest/tpm-crb-swtpm-test.c
+++ b/tests/qtest/tpm-crb-swtpm-test.c
@@ -15,7 +15,7 @@
#include "qemu/osdep.h"
#include <glib/gstdio.h>
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/module.h"
#include "tpm-tests.h"
#include "hw/acpi/tpm.h"
diff --git a/tests/qtest/tpm-tis-device-swtpm-test.c b/tests/qtest/tpm-tis-device-swtpm-test.c
index 7b20035142..f7126eff9e 100644
--- a/tests/qtest/tpm-tis-device-swtpm-test.c
+++ b/tests/qtest/tpm-tis-device-swtpm-test.c
@@ -16,7 +16,7 @@
#include "qemu/osdep.h"
#include <glib/gstdio.h>
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/module.h"
#include "tpm-tests.h"
#include "hw/acpi/tpm.h"
diff --git a/tests/qtest/tpm-tis-swtpm-test.c b/tests/qtest/tpm-tis-swtpm-test.c
index 90131cb3c4..fa590e68f1 100644
--- a/tests/qtest/tpm-tis-swtpm-test.c
+++ b/tests/qtest/tpm-tis-swtpm-test.c
@@ -15,7 +15,7 @@
#include "qemu/osdep.h"
#include <glib/gstdio.h>
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/module.h"
#include "tpm-tests.h"
#include "hw/acpi/tpm.h"
diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c
index 58a9593745..e2b29ef0f8 100644
--- a/tests/qtest/tpm-util.c
+++ b/tests/qtest/tpm-util.c
@@ -15,7 +15,7 @@
#include "qemu/osdep.h"
#include "hw/acpi/tpm.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "tpm-util.h"
#include "qapi/qmp/qdict.h"
diff --git a/tests/qtest/tulip-test.c b/tests/qtest/tulip-test.c
index 2fb6c4d5a7..da16cbfafc 100644
--- a/tests/qtest/tulip-test.c
+++ b/tests/qtest/tulip-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/module.h"
#include "libqos/qgraph.h"
#include "libqos/pci.h"
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index 2167322985..de30b717b6 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -578,6 +578,7 @@ static bool fs_dirents_contain_name(struct V9fsDirent *e, const char* name)
return false;
}
+/* basic readdir test where reply fits into a single response message */
static void fs_readdir(void *obj, void *data, QGuestAllocator *t_alloc)
{
QVirtio9P *v9p = obj;
@@ -631,6 +632,89 @@ static void fs_readdir(void *obj, void *data, QGuestAllocator *t_alloc)
g_free(wnames[0]);
}
+/* readdir test where overall request is split over several messages */
+static void fs_readdir_split(void *obj, void *data, QGuestAllocator *t_alloc,
+ uint32_t count)
+{
+ QVirtio9P *v9p = obj;
+ alloc = t_alloc;
+ char *const wnames[] = { g_strdup(QTEST_V9FS_SYNTH_READDIR_DIR) };
+ uint16_t nqid;
+ v9fs_qid qid;
+ uint32_t nentries, npartialentries;
+ struct V9fsDirent *entries, *tail, *partialentries;
+ P9Req *req;
+ int fid;
+ uint64_t offset;
+
+ fs_attach(v9p, NULL, t_alloc);
+
+ fid = 1;
+ offset = 0;
+ entries = NULL;
+ nentries = 0;
+ tail = NULL;
+
+ req = v9fs_twalk(v9p, 0, fid, 1, wnames, 0);
+ v9fs_req_wait_for_reply(req, NULL);
+ v9fs_rwalk(req, &nqid, NULL);
+ g_assert_cmpint(nqid, ==, 1);
+
+ req = v9fs_tlopen(v9p, fid, O_DIRECTORY, 0);
+ v9fs_req_wait_for_reply(req, NULL);
+ v9fs_rlopen(req, &qid, NULL);
+
+ /*
+ * send as many Treaddir requests as required to get all directory
+ * entries
+ */
+ while (true) {
+ npartialentries = 0;
+ partialentries = NULL;
+
+ req = v9fs_treaddir(v9p, fid, offset, count, 0);
+ v9fs_req_wait_for_reply(req, NULL);
+ v9fs_rreaddir(req, &count, &npartialentries, &partialentries);
+ if (npartialentries > 0 && partialentries) {
+ if (!entries) {
+ entries = partialentries;
+ nentries = npartialentries;
+ tail = partialentries;
+ } else {
+ tail->next = partialentries;
+ nentries += npartialentries;
+ }
+ while (tail->next) {
+ tail = tail->next;
+ }
+ offset = tail->offset;
+ } else {
+ break;
+ }
+ }
+
+ g_assert_cmpint(
+ nentries, ==,
+ QTEST_V9FS_SYNTH_READDIR_NFILES + 2 /* "." and ".." */
+ );
+
+ /*
+ * Check all file names exist in returned entries, ignore their order
+ * though.
+ */
+ g_assert_cmpint(fs_dirents_contain_name(entries, "."), ==, true);
+ g_assert_cmpint(fs_dirents_contain_name(entries, ".."), ==, true);
+ for (int i = 0; i < QTEST_V9FS_SYNTH_READDIR_NFILES; ++i) {
+ char *name = g_strdup_printf(QTEST_V9FS_SYNTH_READDIR_FILE, i);
+ g_assert_cmpint(fs_dirents_contain_name(entries, name), ==, true);
+ g_free(name);
+ }
+
+ v9fs_free_dirents(entries);
+
+ g_free(wnames[0]);
+}
+
static void fs_walk_no_slash(void *obj, void *data, QGuestAllocator *t_alloc)
{
QVirtio9P *v9p = obj;
@@ -793,6 +877,24 @@ static void fs_flush_ignored(void *obj, void *data, QGuestAllocator *t_alloc)
g_free(wnames[0]);
}
+static void fs_readdir_split_128(void *obj, void *data,
+ QGuestAllocator *t_alloc)
+{
+ fs_readdir_split(obj, data, t_alloc, 128);
+}
+
+static void fs_readdir_split_256(void *obj, void *data,
+ QGuestAllocator *t_alloc)
+{
+ fs_readdir_split(obj, data, t_alloc, 256);
+}
+
+static void fs_readdir_split_512(void *obj, void *data,
+ QGuestAllocator *t_alloc)
+{
+ fs_readdir_split(obj, data, t_alloc, 512);
+}
+
static void register_virtio_9p_test(void)
{
qos_add_test("config", "virtio-9p", pci_config, NULL);
@@ -810,6 +912,12 @@ static void register_virtio_9p_test(void)
qos_add_test("fs/flush/ignored", "virtio-9p", fs_flush_ignored,
NULL);
qos_add_test("fs/readdir/basic", "virtio-9p", fs_readdir, NULL);
+ qos_add_test("fs/readdir/split_512", "virtio-9p",
+ fs_readdir_split_512, NULL);
+ qos_add_test("fs/readdir/split_256", "virtio-9p",
+ fs_readdir_split_256, NULL);
+ qos_add_test("fs/readdir/split_128", "virtio-9p",
+ fs_readdir_split_128, NULL);
}
libqos_init(register_virtio_9p_test);
diff --git a/tests/qtest/virtio-rng-test.c b/tests/qtest/virtio-rng-test.c
index 092ba13068..e6b8cd8e0c 100644
--- a/tests/qtest/virtio-rng-test.c
+++ b/tests/qtest/virtio-rng-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/module.h"
#include "libqos/qgraph.h"
#include "libqos/virtio-rng.h"
diff --git a/tests/qtest/virtio-test.c b/tests/qtest/virtio-test.c
index f7c6afdcf1..6313417630 100644
--- a/tests/qtest/virtio-test.c
+++ b/tests/qtest/virtio-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/module.h"
#include "libqos/qgraph.h"
#include "libqos/pci.h"
diff --git a/tests/qtest/vmgenid-test.c b/tests/qtest/vmgenid-test.c
index efba76e716..6781a51447 100644
--- a/tests/qtest/vmgenid-test.c
+++ b/tests/qtest/vmgenid-test.c
@@ -14,7 +14,7 @@
#include "hw/acpi/acpi-defs.h"
#include "boot-sector.h"
#include "acpi-utils.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qapi/qmp/qdict.h"
#define VGID_GUID "324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87"
diff --git a/tests/qtest/vmxnet3-test.c b/tests/qtest/vmxnet3-test.c
index a81025252c..97c23fd3a8 100644
--- a/tests/qtest/vmxnet3-test.c
+++ b/tests/qtest/vmxnet3-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qemu/module.h"
#include "libqos/qgraph.h"
#include "libqos/pci.h"
diff --git a/tests/qtest/wdt_ib700-test.c b/tests/qtest/wdt_ib700-test.c
index 797288d939..6c36e43fb8 100644
--- a/tests/qtest/wdt_ib700-test.c
+++ b/tests/qtest/wdt_ib700-test.c
@@ -8,7 +8,7 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qapi/qmp/qdict.h"
#include "qemu/timer.h"
diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
index b617f2ac7e..e7249915e7 100644
--- a/tests/tcg/aarch64/Makefile.target
+++ b/tests/tcg/aarch64/Makefile.target
@@ -19,7 +19,7 @@ run-fcvt: fcvt
# Pauth Tests
ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_ARMV8_3),)
-AARCH64_TESTS += pauth-1 pauth-2 pauth-4
+AARCH64_TESTS += pauth-1 pauth-2 pauth-4 pauth-5
pauth-%: CFLAGS += -march=armv8.3-a
run-pauth-%: QEMU_OPTS += -cpu max
run-plugin-pauth-%: QEMU_OPTS += -cpu max
diff --git a/tests/tcg/aarch64/pauth-5.c b/tests/tcg/aarch64/pauth-5.c
new file mode 100644
index 0000000000..67c257918b
--- /dev/null
+++ b/tests/tcg/aarch64/pauth-5.c
@@ -0,0 +1,33 @@
+#include <assert.h>
+
+static int x;
+
+int main()
+{
+ int *p0 = &x, *p1, *p2, *p3;
+ unsigned long salt = 0;
+
+ /*
+ * With TBI enabled and a 48-bit VA, there are 7 bits of auth, and so
+ * a 1/128 chance of auth = pac(ptr,key,salt) producing zero.
+ * Find a salt that creates auth != 0.
+ */
+ do {
+ salt++;
+ asm("pacda %0, %1" : "=r"(p1) : "r"(salt), "0"(p0));
+ } while (p0 == p1);
+
+ /*
+ * This pac must fail, because the input pointer bears an encryption,
+ * and so is not properly extended within bits [55:47]. This will
+ * toggle bit 54 in the output...
+ */
+ asm("pacda %0, %1" : "=r"(p2) : "r"(salt), "0"(p1));
+
+ /* ... so that the aut must fail, setting bit 53 in the output ... */
+ asm("autda %0, %1" : "=r"(p3) : "r"(salt), "0"(p2));
+
+ /* ... which means this equality must not hold. */
+ assert(p3 != p0);
+ return 0;
+}
diff --git a/tests/tcg/configure.sh b/tests/tcg/configure.sh
index 102578caa5..7d714f902a 100755
--- a/tests/tcg/configure.sh
+++ b/tests/tcg/configure.sh
@@ -193,11 +193,11 @@ for target in $target_list; do
case $target in
*-linux-user | *-bsd-user)
echo "CONFIG_USER_ONLY=y" >> $config_target_mak
- echo "QEMU=\$(BUILD_DIR)/$target/qemu-$arch" >> $config_target_mak
+ echo "QEMU=\$(BUILD_DIR)/qemu-$arch" >> $config_target_mak
;;
*-softmmu)
echo "CONFIG_SOFTMMU=y" >> $config_target_mak
- echo "QEMU=\$(BUILD_DIR)/$target/qemu-system-$arch" >> $config_target_mak
+ echo "QEMU=\$(BUILD_DIR)/qemu-system-$arch" >> $config_target_mak
;;
esac
diff --git a/tests/tcg/xtensa/fpu.h b/tests/tcg/xtensa/fpu.h
new file mode 100644
index 0000000000..42e3217473
--- /dev/null
+++ b/tests/tcg/xtensa/fpu.h
@@ -0,0 +1,142 @@
+#if XCHAL_HAVE_DFP || XCHAL_HAVE_FP_DIV
+#define DFPU 1
+#else
+#define DFPU 0
+#endif
+
+#define FCR_RM_NEAREST 0
+#define FCR_RM_TRUNC 1
+#define FCR_RM_CEIL 2
+#define FCR_RM_FLOOR 3
+
+#define FSR__ 0x00000000
+#define FSR_I 0x00000080
+#define FSR_U 0x00000100
+#define FSR_O 0x00000200
+#define FSR_Z 0x00000400
+#define FSR_V 0x00000800
+
+#define FSR_UI (FSR_U | FSR_I)
+#define FSR_OI (FSR_O | FSR_I)
+
+#define F32_0 0x00000000
+#define F32_0_5 0x3f000000
+#define F32_1 0x3f800000
+#define F32_MAX 0x7f7fffff
+#define F32_PINF 0x7f800000
+#define F32_NINF 0xff800000
+
+#define F32_DNAN 0x7fc00000
+#define F32_SNAN(v) (0x7f800000 | (v))
+#define F32_QNAN(v) (0x7fc00000 | (v))
+
+#define F32_MINUS 0x80000000
+
+#define F64_0 0x0000000000000000
+#define F64_MIN_NORM 0x0010000000000000
+#define F64_1 0x3ff0000000000000
+#define F64_MAX_2 0x7fe0000000000000
+#define F64_MAX 0x7fefffffffffffff
+#define F64_PINF 0x7ff0000000000000
+#define F64_NINF 0xfff0000000000000
+
+#define F64_DNAN 0x7ff8000000000000
+#define F64_SNAN(v) (0x7ff0000000000000 | (v))
+#define F64_QNAN(v) (0x7ff8000000000000 | (v))
+
+#define F64_MINUS 0x8000000000000000
+
+.macro test_op1_rm op, fr0, fr1, v0, r, sr
+ movi a2, 0
+ wur a2, fsr
+ movfp \fr0, \v0
+ \op \fr1, \fr0
+ check_res \fr1, \r, \sr
+.endm
+
+.macro test_op2_rm op, fr0, fr1, fr2, v0, v1, r, sr
+ movi a2, 0
+ wur a2, fsr
+ movfp \fr0, \v0
+ movfp \fr1, \v1
+ \op \fr2, \fr0, \fr1
+ check_res \fr2, \r, \sr
+.endm
+
+.macro test_op3_rm op, fr0, fr1, fr2, fr3, v0, v1, v2, r, sr
+ movi a2, 0
+ wur a2, fsr
+ movfp \fr0, \v0
+ movfp \fr1, \v1
+ movfp \fr2, \v2
+ \op \fr0, \fr1, \fr2
+ check_res \fr3, \r, \sr
+.endm
+
+.macro test_op1_ex op, fr0, fr1, v0, rm, r, sr
+ movi a2, \rm
+ wur a2, fcr
+ test_op1_rm \op, \fr0, \fr1, \v0, \r, \sr
+ movi a2, (\rm) | 0x7c
+ wur a2, fcr
+ test_op1_rm \op, \fr0, \fr1, \v0, \r, \sr
+.endm
+
+.macro test_op2_ex op, fr0, fr1, fr2, v0, v1, rm, r, sr
+ movi a2, \rm
+ wur a2, fcr
+ test_op2_rm \op, \fr0, \fr1, \fr2, \v0, \v1, \r, \sr
+ movi a2, (\rm) | 0x7c
+ wur a2, fcr
+ test_op2_rm \op, \fr0, \fr1, \fr2, \v0, \v1, \r, \sr
+.endm
+
+.macro test_op3_ex op, fr0, fr1, fr2, fr3, v0, v1, v2, rm, r, sr
+ movi a2, \rm
+ wur a2, fcr
+ test_op3_rm \op, \fr0, \fr1, \fr2, \fr3, \v0, \v1, \v2, \r, \sr
+ movi a2, (\rm) | 0x7c
+ wur a2, fcr
+ test_op3_rm \op, \fr0, \fr1, \fr2, \fr3, \v0, \v1, \v2, \r, \sr
+.endm
+
+.macro test_op1 op, fr0, fr1, v0, r0, r1, r2, r3, sr0, sr1, sr2, sr3
+ test_op1_ex \op, \fr0, \fr1, \v0, 0, \r0, \sr0
+ test_op1_ex \op, \fr0, \fr1, \v0, 1, \r1, \sr1
+ test_op1_ex \op, \fr0, \fr1, \v0, 2, \r2, \sr2
+ test_op1_ex \op, \fr0, \fr1, \v0, 3, \r3, \sr3
+.endm
+
+.macro test_op2 op, fr0, fr1, fr2, v0, v1, r0, r1, r2, r3, sr0, sr1, sr2, sr3
+ test_op2_ex \op, \fr0, \fr1, \fr2, \v0, \v1, 0, \r0, \sr0
+ test_op2_ex \op, \fr0, \fr1, \fr2, \v0, \v1, 1, \r1, \sr1
+ test_op2_ex \op, \fr0, \fr1, \fr2, \v0, \v1, 2, \r2, \sr2
+ test_op2_ex \op, \fr0, \fr1, \fr2, \v0, \v1, 3, \r3, \sr3
+.endm
+
+.macro test_op3 op, fr0, fr1, fr2, fr3, v0, v1, v2, r0, r1, r2, r3, sr0, sr1, sr2, sr3
+ test_op3_ex \op, \fr0, \fr1, \fr2, \fr3, \v0, \v1, \v2, 0, \r0, \sr0
+ test_op3_ex \op, \fr0, \fr1, \fr2, \fr3, \v0, \v1, \v2, 1, \r1, \sr1
+ test_op3_ex \op, \fr0, \fr1, \fr2, \fr3, \v0, \v1, \v2, 2, \r2, \sr2
+ test_op3_ex \op, \fr0, \fr1, \fr2, \fr3, \v0, \v1, \v2, 3, \r3, \sr3
+.endm
+
+.macro test_op2_cpe op
+ set_vector kernel, 2f
+ movi a2, 0
+ wsr a2, cpenable
+1:
+ \op f2, f0, f1
+ test_fail
+2:
+ rsr a2, excvaddr
+ movi a3, 1b
+ assert eq, a2, a3
+ rsr a2, exccause
+ movi a3, 32
+ assert eq, a2, a3
+
+ set_vector kernel, 0
+ movi a2, 1
+ wsr a2, cpenable
+.endm
diff --git a/tests/tcg/xtensa/macros.inc b/tests/tcg/xtensa/macros.inc
index aa8f95bce8..f88937c7bf 100644
--- a/tests/tcg/xtensa/macros.inc
+++ b/tests/tcg/xtensa/macros.inc
@@ -3,7 +3,7 @@
.macro test_suite name
.data
status: .word result
-result: .space 256
+result: .space 1024
.text
.global main
.align 4
@@ -25,9 +25,9 @@ main:
movi a3, 0
beqz a2, 2f
1:
- l8ui a1, a0, 0
+ l32i a1, a0, 0
or a3, a3, a1
- addi a0, a0, 1
+ addi a0, a0, 4
addi a2, a2, -1
bnez a2, 1b
2:
@@ -65,7 +65,7 @@ test_\name:
reset_ps
movi a2, status
l32i a3, a2, 0
- addi a3, a3, 1
+ addi a3, a3, 4
s32i a3, a2, 0
.endm
@@ -78,7 +78,7 @@ test_\name:
movi a2, status
l32i a2, a2, 0
movi a3, 1
- s8i a3, a2, 0
+ s32i a3, a2, 0
#ifdef DEBUG
print failed
#endif
diff --git a/tests/tcg/xtensa/test_dfp0_arith.S b/tests/tcg/xtensa/test_dfp0_arith.S
new file mode 100644
index 0000000000..53bf8122d0
--- /dev/null
+++ b/tests/tcg/xtensa/test_dfp0_arith.S
@@ -0,0 +1,162 @@
+#include "macros.inc"
+#include "fpu.h"
+
+test_suite fp0_arith
+
+#if XCHAL_HAVE_DFP
+
+.macro movfp fr, v
+ movi a2, ((\v) >> 32) & 0xffffffff
+ movi a3, ((\v) & 0xffffffff)
+ wfrd \fr, a2, a3
+.endm
+
+.macro check_res fr, r, sr
+ rfrd a2, \fr
+ dump a2
+ movi a3, ((\r) >> 32) & 0xffffffff
+ assert eq, a2, a3
+ rfr a2, \fr
+ dump a2
+ movi a3, ((\r) & 0xffffffff)
+ assert eq, a2, a3
+ rur a2, fsr
+ movi a3, \sr
+ assert eq, a2, a3
+.endm
+
+test add_d
+ movi a2, 1
+ wsr a2, cpenable
+
+ /* MAX_FLOAT + MAX_FLOAT = +inf/MAX_FLOAT */
+ test_op2 add.d, f6, f7, f8, F64_MAX, F64_MAX, \
+ F64_PINF, F64_MAX, F64_PINF, F64_MAX, \
+ FSR_OI, FSR_OI, FSR_OI, FSR_OI
+test_end
+
+test add_d_inf
+ /* 1 + +inf = +inf */
+ test_op2 add.d, f6, f7, f8, F64_1, F64_PINF, \
+ F64_PINF, F64_PINF, F64_PINF, F64_PINF, \
+ FSR__, FSR__, FSR__, FSR__
+
+ /* +inf + -inf = default NaN */
+ test_op2 add.d, f0, f1, f2, F64_PINF, F64_NINF, \
+ F64_DNAN, F64_DNAN, F64_DNAN, F64_DNAN, \
+ FSR_V, FSR_V, FSR_V, FSR_V
+test_end
+
+test add_d_nan_dfpu
+ /* 1 + QNaN = QNaN */
+ test_op2 add.d, f9, f10, f11, F64_1, F64_QNAN(1), \
+ F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), \
+ FSR__, FSR__, FSR__, FSR__
+ /* 1 + SNaN = QNaN */
+ test_op2 add.d, f12, f13, f14, F64_1, F64_SNAN(1), \
+ F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), \
+ FSR_V, FSR_V, FSR_V, FSR_V
+
+ /* SNaN1 + SNaN2 = QNaN2 */
+ test_op2 add.d, f15, f0, f1, F64_SNAN(1), F64_SNAN(2), \
+ F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), \
+ FSR_V, FSR_V, FSR_V, FSR_V
+ /* QNaN1 + SNaN2 = QNaN2 */
+ test_op2 add.d, f5, f6, f7, F64_QNAN(1), F64_SNAN(2), \
+ F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), \
+ FSR_V, FSR_V, FSR_V, FSR_V
+ /* SNaN1 + QNaN2 = QNaN2 */
+ test_op2 add.d, f8, f9, f10, F64_SNAN(1), F64_QNAN(2), \
+ F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), \
+ FSR_V, FSR_V, FSR_V, FSR_V
+test_end
+
+test sub_d
+ /* norm - norm = denorm */
+ test_op2 sub.d, f6, f7, f8, F64_MIN_NORM | 1, F64_MIN_NORM, \
+ 0x00000001, 0x00000001, 0x00000001, 0x00000001, \
+ FSR__, FSR__, FSR__, FSR__
+test_end
+
+test mul_d
+ test_op2 mul.d, f0, f1, f2, F64_1 | 1, F64_1 | 1, \
+ F64_1 | 2, F64_1 | 2, F64_1 | 3, F64_1 | 2, \
+ FSR_I, FSR_I, FSR_I, FSR_I
+ /* MAX_FLOAT/2 * MAX_FLOAT/2 = +inf/MAX_FLOAT */
+ test_op2 mul.d, f6, f7, f8, F64_MAX_2, F64_MAX_2, \
+ F64_PINF, F64_MAX, F64_PINF, F64_MAX, \
+ FSR_OI, FSR_OI, FSR_OI, FSR_OI
+ /* min norm * min norm = 0/denorm */
+ test_op2 mul.d, f6, f7, f8, F64_MIN_NORM, F64_MIN_NORM, \
+ F64_0, F64_0, 0x00000001, F64_0, \
+ FSR_UI, FSR_UI, FSR_UI, FSR_UI
+ /* inf * 0 = default NaN */
+ test_op2 mul.d, f6, f7, f8, F64_PINF, F64_0, \
+ F64_DNAN, F64_DNAN, F64_DNAN, F64_DNAN, \
+ FSR_V, FSR_V, FSR_V, FSR_V
+test_end
+
+test madd_d
+ test_op3 madd.d, f0, f1, f2, f0, F64_0, F64_1 | 1, F64_1 | 1, \
+ F64_1 | 2, F64_1 | 2, F64_1 | 3, F64_1 | 2, \
+ FSR_I, FSR_I, FSR_I, FSR_I
+test_end
+
+test madd_d_precision
+ test_op3 madd.d, f0, f1, f2, f0, \
+ F64_MINUS | F64_1 | 2, F64_1 | 1, F64_1 | 1, \
+ 0x3970000000000000, 0x3970000000000000, 0x3970000000000000, 0x3970000000000000, \
+ FSR__, FSR__, FSR__, FSR__
+test_end
+
+test madd_d_nan_dfpu
+ /* DFPU madd/msub NaN1, NaN2, NaN3 priority: NaN1, NaN3, NaN2 */
+ test_op3 madd.d, f0, f1, f2, f0, F64_QNAN(1), F64_1, F64_1, \
+ F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), \
+ FSR__, FSR__, FSR__, FSR__
+ test_op3 madd.d, f0, f1, f2, f0, F64_1, F64_QNAN(2), F64_1, \
+ F64_QNAN(2), F64_QNAN(2), F64_QNAN(2), F64_QNAN(2), \
+ FSR__, FSR__, FSR__, FSR__
+ test_op3 madd.d, f0, f1, f2, f0, F64_1, F64_1, F64_QNAN(3), \
+ F64_QNAN(3), F64_QNAN(3), F64_QNAN(3), F64_QNAN(3), \
+ FSR__, FSR__, FSR__, FSR__
+
+ test_op3 madd.d, f0, f1, f2, f0, F64_QNAN(1), F64_QNAN(2), F64_1, \
+ F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), \
+ FSR__, FSR__, FSR__, FSR__
+ test_op3 madd.d, f0, f1, f2, f0, F64_QNAN(1), F64_1, F64_QNAN(3), \
+ F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), \
+ FSR__, FSR__, FSR__, FSR__
+ test_op3 madd.d, f0, f1, f2, f0, F64_1, F64_QNAN(2), F64_QNAN(3), \
+ F64_QNAN(3), F64_QNAN(3), F64_QNAN(3), F64_QNAN(3), \
+ FSR__, FSR__, FSR__, FSR__
+
+ test_op3 madd.d, f0, f1, f2, f0, F64_QNAN(1), F64_QNAN(2), F64_QNAN(3), \
+ F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), \
+ FSR__, FSR__, FSR__, FSR__
+
+ /* inf * 0 = default NaN */
+ test_op3 madd.d, f0, f1, f2, f0, F64_1, F64_PINF, F64_0, \
+ F64_DNAN, F64_DNAN, F64_DNAN, F64_DNAN, \
+ FSR_V, FSR_V, FSR_V, FSR_V
+ /* inf * 0 + SNaN1 = QNaN1 */
+ test_op3 madd.d, f0, f1, f2, f0, F64_SNAN(1), F64_PINF, F64_0, \
+ F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), \
+ FSR_V, FSR_V, FSR_V, FSR_V
+ /* inf * 0 + QNaN1 = QNaN1 */
+ test_op3 madd.d, f0, f1, f2, f0, F64_QNAN(1), F64_PINF, F64_0, \
+ F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), \
+ FSR_V, FSR_V, FSR_V, FSR_V
+
+ /* madd/msub SNaN turns to QNaN and sets Invalid flag */
+ test_op3 madd.d, f0, f1, f2, f0, F64_SNAN(1), F64_1, F64_1, \
+ F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), \
+ FSR_V, FSR_V, FSR_V, FSR_V
+ test_op3 madd.d, f0, f1, f2, f0, F64_QNAN(1), F64_SNAN(2), F64_1, \
+ F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), F64_QNAN(1), \
+ FSR_V, FSR_V, FSR_V, FSR_V
+test_end
+
+#endif
+
+test_suite_end
diff --git a/tests/tcg/xtensa/test_fp0_arith.S b/tests/tcg/xtensa/test_fp0_arith.S
index 253d033a33..7eefc1da40 100644
--- a/tests/tcg/xtensa/test_fp0_arith.S
+++ b/tests/tcg/xtensa/test_fp0_arith.S
@@ -1,4 +1,5 @@
#include "macros.inc"
+#include "fpu.h"
test_suite fp0_arith
@@ -9,84 +10,18 @@ test_suite fp0_arith
wfr \fr, a2
.endm
-.macro check_res fr, r
+.macro check_res fr, r, sr
rfr a2, \fr
dump a2
movi a3, \r
assert eq, a2, a3
rur a2, fsr
- assert eqi, a2, 0
-.endm
-
-.macro test_op2_rm op, fr0, fr1, fr2, v0, v1, r
- movi a2, 0
- wur a2, fsr
- movfp \fr0, \v0
- movfp \fr1, \v1
- \op \fr2, \fr0, \fr1
- check_res \fr2, \r
-.endm
-
-.macro test_op3_rm op, fr0, fr1, fr2, fr3, v0, v1, v2, r
- movi a2, 0
- wur a2, fsr
- movfp \fr0, \v0
- movfp \fr1, \v1
- movfp \fr2, \v2
- \op \fr0, \fr1, \fr2
- check_res \fr3, \r
-.endm
-
-.macro test_op2_ex op, fr0, fr1, fr2, v0, v1, rm, r
- movi a2, \rm
- wur a2, fcr
- test_op2_rm \op, \fr0, \fr1, \fr2, \v0, \v1, \r
- movi a2, (\rm) | 0x7c
- wur a2, fcr
- test_op2_rm \op, \fr0, \fr1, \fr2, \v0, \v1, \r
-.endm
-
-.macro test_op3_ex op, fr0, fr1, fr2, fr3, v0, v1, v2, rm, r
- movi a2, \rm
- wur a2, fcr
- test_op3_rm \op, \fr0, \fr1, \fr2, \fr3, \v0, \v1, \v2, \r
- movi a2, (\rm) | 0x7c
- wur a2, fcr
- test_op3_rm \op, \fr0, \fr1, \fr2, \fr3, \v0, \v1, \v2, \r
-.endm
-
-.macro test_op2 op, fr0, fr1, fr2, v0, v1, r0, r1, r2, r3
- test_op2_ex \op, \fr0, \fr1, \fr2, \v0, \v1, 0, \r0
- test_op2_ex \op, \fr0, \fr1, \fr2, \v0, \v1, 1, \r1
- test_op2_ex \op, \fr0, \fr1, \fr2, \v0, \v1, 2, \r2
- test_op2_ex \op, \fr0, \fr1, \fr2, \v0, \v1, 3, \r3
-.endm
-
-.macro test_op3 op, fr0, fr1, fr2, fr3, v0, v1, v2, r0, r1, r2, r3
- test_op3_ex \op, \fr0, \fr1, \fr2, \fr3, \v0, \v1, \v2, 0, \r0
- test_op3_ex \op, \fr0, \fr1, \fr2, \fr3, \v0, \v1, \v2, 1, \r1
- test_op3_ex \op, \fr0, \fr1, \fr2, \fr3, \v0, \v1, \v2, 2, \r2
- test_op3_ex \op, \fr0, \fr1, \fr2, \fr3, \v0, \v1, \v2, 3, \r3
-.endm
-
-.macro test_op2_cpe op
- set_vector kernel, 2f
- movi a2, 0
- wsr a2, cpenable
-1:
- \op f2, f0, f1
- test_fail
-2:
- rsr a2, excvaddr
- movi a3, 1b
- assert eq, a2, a3
- rsr a2, exccause
- movi a3, 32
+#if DFPU
+ movi a3, \sr
assert eq, a2, a3
-
- set_vector kernel, 0
- movi a2, 1
- wsr a2, cpenable
+#else
+ assert eqi, a2, 0
+#endif
.endm
test add_s
@@ -94,78 +29,231 @@ test add_s
wsr a2, cpenable
test_op2 add.s, f0, f1, f2, 0x3fc00000, 0x34400000, \
- 0x3fc00002, 0x3fc00001, 0x3fc00002, 0x3fc00001
+ 0x3fc00002, 0x3fc00001, 0x3fc00002, 0x3fc00001, \
+ FSR_I, FSR_I, FSR_I, FSR_I
test_op2 add.s, f3, f4, f5, 0x3fc00000, 0x34a00000, \
- 0x3fc00002, 0x3fc00002, 0x3fc00003, 0x3fc00002
+ 0x3fc00002, 0x3fc00002, 0x3fc00003, 0x3fc00002, \
+ FSR_I, FSR_I, FSR_I, FSR_I
/* MAX_FLOAT + MAX_FLOAT = +inf/MAX_FLOAT */
test_op2 add.s, f6, f7, f8, 0x7f7fffff, 0x7f7fffff, \
- 0x7f800000, 0x7f7fffff, 0x7f800000, 0x7f7fffff
+ 0x7f800000, 0x7f7fffff, 0x7f800000, 0x7f7fffff, \
+ FSR_OI, FSR_OI, FSR_OI, FSR_OI
test_end
test add_s_inf
/* 1 + +inf = +inf */
test_op2 add.s, f6, f7, f8, 0x3fc00000, 0x7f800000, \
- 0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000
+ 0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000, \
+ FSR__, FSR__, FSR__, FSR__
/* +inf + -inf = default NaN */
test_op2 add.s, f0, f1, f2, 0x7f800000, 0xff800000, \
- 0x7fc00000, 0x7fc00000, 0x7fc00000, 0x7fc00000
+ 0x7fc00000, 0x7fc00000, 0x7fc00000, 0x7fc00000, \
+ FSR_V, FSR_V, FSR_V, FSR_V
test_end
-test add_s_nan
- /* 1 + NaN = NaN */
+#if DFPU
+test add_s_nan_dfpu
+ /* 1 + QNaN = QNaN */
test_op2 add.s, f9, f10, f11, 0x3fc00000, 0x7fc00001, \
- 0x7fc00001, 0x7fc00001, 0x7fc00001, 0x7fc00001
+ 0x7fc00001, 0x7fc00001, 0x7fc00001, 0x7fc00001, \
+ FSR__, FSR__, FSR__, FSR__
+ /* 1 + SNaN = QNaN */
test_op2 add.s, f12, f13, f14, 0x3fc00000, 0x7f800001, \
- 0x7f800001, 0x7f800001, 0x7f800001, 0x7f800001
+ 0x7fc00001, 0x7fc00001, 0x7fc00001, 0x7fc00001, \
+ FSR_V, FSR_V, FSR_V, FSR_V
- /* NaN1 + NaN2 = NaN1 */
+ /* SNaN1 + SNaN2 = QNaN2 */
+ test_op2 add.s, f15, f0, f1, 0x7f800001, 0x7fbfffff, \
+ 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, \
+ FSR_V, FSR_V, FSR_V, FSR_V
+ test_op2 add.s, f2, f3, f4, 0x7fbfffff, 0x7f800001, \
+ 0x7fc00001, 0x7fc00001, 0x7fc00001, 0x7fc00001, \
+ FSR_V, FSR_V, FSR_V, FSR_V
+ /* QNaN1 + SNaN2 = QNaN2 */
+ test_op2 add.s, f5, f6, f7, 0x7fc00001, 0x7fbfffff, \
+ 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, \
+ FSR_V, FSR_V, FSR_V, FSR_V
+ /* SNaN1 + QNaN2 = QNaN2 */
+ test_op2 add.s, f8, f9, f10, 0x7fbfffff, 0x7fc00001, \
+ 0x7fc00001, 0x7fc00001, 0x7fc00001, 0x7fc00001, \
+ FSR_V, FSR_V, FSR_V, FSR_V
+test_end
+#else
+test add_s_nan_fpu2k
+ /* 1 + QNaN = QNaN */
+ test_op2 add.s, f9, f10, f11, 0x3fc00000, 0x7fc00001, \
+ 0x7fc00001, 0x7fc00001, 0x7fc00001, 0x7fc00001, \
+ FSR__, FSR__, FSR__, FSR__
+ /* 1 + SNaN = SNaN */
+ test_op2 add.s, f12, f13, f14, 0x3fc00000, 0x7f800001, \
+ 0x7f800001, 0x7f800001, 0x7f800001, 0x7f800001, \
+ FSR__, FSR__, FSR__, FSR__
+ /* SNaN1 + SNaN2 = SNaN1 */
test_op2 add.s, f15, f0, f1, 0x7f800001, 0x7fbfffff, \
- 0x7f800001, 0x7f800001, 0x7f800001, 0x7f800001
+ 0x7f800001, 0x7f800001, 0x7f800001, 0x7f800001, \
+ FSR__, FSR__, FSR__, FSR__
test_op2 add.s, f2, f3, f4, 0x7fbfffff, 0x7f800001, \
- 0x7fbfffff, 0x7fbfffff, 0x7fbfffff, 0x7fbfffff
+ 0x7fbfffff, 0x7fbfffff, 0x7fbfffff, 0x7fbfffff, \
+ FSR__, FSR__, FSR__, FSR__
+ /* QNaN1 + SNaN2 = QNaN1 */
test_op2 add.s, f5, f6, f7, 0x7fc00001, 0x7fbfffff, \
- 0x7fc00001, 0x7fc00001, 0x7fc00001, 0x7fc00001
+ 0x7fc00001, 0x7fc00001, 0x7fc00001, 0x7fc00001, \
+ FSR__, FSR__, FSR__, FSR__
+ /* SNaN1 + QNaN2 = SNaN1 */
test_op2 add.s, f8, f9, f10, 0x7fbfffff, 0x7fc00001, \
- 0x7fbfffff, 0x7fbfffff, 0x7fbfffff, 0x7fbfffff
+ 0x7fbfffff, 0x7fbfffff, 0x7fbfffff, 0x7fbfffff, \
+ FSR__, FSR__, FSR__, FSR__
test_end
+#endif
test sub_s
test_op2 sub.s, f0, f1, f0, 0x3f800001, 0x33800000, \
- 0x3f800000, 0x3f800000, 0x3f800001, 0x3f800000
+ 0x3f800000, 0x3f800000, 0x3f800001, 0x3f800000, \
+ FSR_I, FSR_I, FSR_I, FSR_I
test_op2 sub.s, f0, f1, f1, 0x3f800002, 0x33800000, \
- 0x3f800002, 0x3f800001, 0x3f800002, 0x3f800001
+ 0x3f800002, 0x3f800001, 0x3f800002, 0x3f800001, \
+ FSR_I, FSR_I, FSR_I, FSR_I
/* norm - norm = denorm */
test_op2 sub.s, f6, f7, f8, 0x00800001, 0x00800000, \
- 0x00000001, 0x00000001, 0x00000001, 0x00000001
+ 0x00000001, 0x00000001, 0x00000001, 0x00000001, \
+ FSR__, FSR__, FSR__, FSR__
test_end
test mul_s
test_op2 mul.s, f0, f1, f2, 0x3f800001, 0x3f800001, \
- 0x3f800002, 0x3f800002, 0x3f800003, 0x3f800002
-
+ 0x3f800002, 0x3f800002, 0x3f800003, 0x3f800002, \
+ FSR_I, FSR_I, FSR_I, FSR_I
/* MAX_FLOAT/2 * MAX_FLOAT/2 = +inf/MAX_FLOAT */
test_op2 mul.s, f6, f7, f8, 0x7f000000, 0x7f000000, \
- 0x7f800000, 0x7f7fffff, 0x7f800000, 0x7f7fffff
+ 0x7f800000, 0x7f7fffff, 0x7f800000, 0x7f7fffff, \
+ FSR_OI, FSR_OI, FSR_OI, FSR_OI
/* min norm * min norm = 0/denorm */
test_op2 mul.s, f6, f7, f8, 0x00800001, 0x00800000, \
- 0x00000000, 0x00000000, 0x00000001, 0x00000000
-
+ 0x00000000, 0x00000000, 0x00000001, 0x00000000, \
+ FSR_UI, FSR_UI, FSR_UI, FSR_UI
/* inf * 0 = default NaN */
test_op2 mul.s, f6, f7, f8, 0x7f800000, 0x00000000, \
- 0x7fc00000, 0x7fc00000, 0x7fc00000, 0x7fc00000
+ 0x7fc00000, 0x7fc00000, 0x7fc00000, 0x7fc00000, \
+ FSR_V, FSR_V, FSR_V, FSR_V
test_end
test madd_s
test_op3 madd.s, f0, f1, f2, f0, 0, 0x3f800001, 0x3f800001, \
- 0x3f800002, 0x3f800002, 0x3f800003, 0x3f800002
+ 0x3f800002, 0x3f800002, 0x3f800003, 0x3f800002, \
+ FSR_I, FSR_I, FSR_I, FSR_I
+test_end
+
+test madd_s_precision
+ test_op3 madd.s, f0, f1, f2, f0, 0xbf800002, 0x3f800001, 0x3f800001, \
+ 0x28800000, 0x28800000, 0x28800000, 0x28800000, \
+ FSR__, FSR__, FSR__, FSR__
+test_end
+
+#if DFPU
+test madd_s_nan_dfpu
+ /* DFPU madd/msub NaN1, NaN2, NaN3 priority: NaN1, NaN3, NaN2 */
+ test_op3 madd.s, f0, f1, f2, f0, F32_QNAN(1), F32_1, F32_1, \
+ F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), \
+ FSR__, FSR__, FSR__, FSR__
+ test_op3 madd.s, f0, f1, f2, f0, F32_1, F32_QNAN(2), F32_1, \
+ F32_QNAN(2), F32_QNAN(2), F32_QNAN(2), F32_QNAN(2), \
+ FSR__, FSR__, FSR__, FSR__
+ test_op3 madd.s, f0, f1, f2, f0, F32_1, F32_1, F32_QNAN(3), \
+ F32_QNAN(3), F32_QNAN(3), F32_QNAN(3), F32_QNAN(3), \
+ FSR__, FSR__, FSR__, FSR__
+
+ test_op3 madd.s, f0, f1, f2, f0, F32_QNAN(1), F32_QNAN(2), F32_1, \
+ F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), \
+ FSR__, FSR__, FSR__, FSR__
+ test_op3 madd.s, f0, f1, f2, f0, F32_QNAN(1), F32_1, F32_QNAN(3), \
+ F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), \
+ FSR__, FSR__, FSR__, FSR__
+ test_op3 madd.s, f0, f1, f2, f0, F32_1, F32_QNAN(2), F32_QNAN(3), \
+ F32_QNAN(3), F32_QNAN(3), F32_QNAN(3), F32_QNAN(3), \
+ FSR__, FSR__, FSR__, FSR__
+
+ test_op3 madd.s, f0, f1, f2, f0, F32_QNAN(1), F32_QNAN(2), F32_QNAN(3), \
+ F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), \
+ FSR__, FSR__, FSR__, FSR__
+
+ /* inf * 0 = default NaN */
+ test_op3 madd.s, f0, f1, f2, f0, F32_1, F32_PINF, F32_0, \
+ F32_DNAN, F32_DNAN, F32_DNAN, F32_DNAN, \
+ FSR_V, FSR_V, FSR_V, FSR_V
+ /* inf * 0 + SNaN1 = QNaN1 */
+ test_op3 madd.s, f0, f1, f2, f0, F32_SNAN(1), F32_PINF, F32_0, \
+ F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), \
+ FSR_V, FSR_V, FSR_V, FSR_V
+ /* inf * 0 + QNaN1 = QNaN1 */
+ test_op3 madd.s, f0, f1, f2, f0, F32_QNAN(1), F32_PINF, F32_0, \
+ F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), \
+ FSR_V, FSR_V, FSR_V, FSR_V
+
+ /* madd/msub SNaN turns to QNaN and sets Invalid flag */
+ test_op3 madd.s, f0, f1, f2, f0, F32_SNAN(1), F32_1, F32_1, \
+ F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), \
+ FSR_V, FSR_V, FSR_V, FSR_V
+ test_op3 madd.s, f0, f1, f2, f0, F32_QNAN(1), F32_SNAN(2), F32_1, \
+ F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), \
+ FSR_V, FSR_V, FSR_V, FSR_V
+test_end
+#else
+test madd_s_nan_fpu2k
+ /* FPU2000 madd/msub NaN1, NaN2, NaN3 priority: NaN2, NaN3, NaN1 */
+ test_op3 madd.s, f0, f1, f2, f0, F32_QNAN(1), F32_1, F32_1, \
+ F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), \
+ FSR__, FSR__, FSR__, FSR__
+ test_op3 madd.s, f0, f1, f2, f0, F32_1, F32_QNAN(2), F32_1, \
+ F32_QNAN(2), F32_QNAN(2), F32_QNAN(2), F32_QNAN(2), \
+ FSR__, FSR__, FSR__, FSR__
+ test_op3 madd.s, f0, f1, f2, f0, F32_1, F32_1, F32_QNAN(3), \
+ F32_QNAN(3), F32_QNAN(3), F32_QNAN(3), F32_QNAN(3), \
+ FSR__, FSR__, FSR__, FSR__
+
+ test_op3 madd.s, f0, f1, f2, f0, F32_QNAN(1), F32_QNAN(2), F32_1, \
+ F32_QNAN(2), F32_QNAN(2), F32_QNAN(2), F32_QNAN(2), \
+ FSR__, FSR__, FSR__, FSR__
+ test_op3 madd.s, f0, f1, f2, f0, F32_QNAN(1), F32_1, F32_QNAN(3), \
+ F32_QNAN(3), F32_QNAN(3), F32_QNAN(3), F32_QNAN(3), \
+ FSR__, FSR__, FSR__, FSR__
+ test_op3 madd.s, f0, f1, f2, f0, F32_1, F32_QNAN(2), F32_QNAN(3), \
+ F32_QNAN(2), F32_QNAN(2), F32_QNAN(2), F32_QNAN(2), \
+ FSR__, FSR__, FSR__, FSR__
+
+ test_op3 madd.s, f0, f1, f2, f0, F32_QNAN(1), F32_QNAN(2), F32_QNAN(3), \
+ F32_QNAN(2), F32_QNAN(2), F32_QNAN(2), F32_QNAN(2), \
+ FSR__, FSR__, FSR__, FSR__
+
+ /* inf * 0 = default NaN */
+ test_op3 madd.s, f0, f1, f2, f0, F32_1, F32_PINF, F32_0, \
+ F32_DNAN, F32_DNAN, F32_DNAN, F32_DNAN, \
+ FSR__, FSR__, FSR__, FSR__
+ /* inf * 0 + SNaN1 = SNaN1 */
+ test_op3 madd.s, f0, f1, f2, f0, F32_SNAN(1), F32_PINF, F32_0, \
+ F32_SNAN(1), F32_SNAN(1), F32_SNAN(1), F32_SNAN(1), \
+ FSR__, FSR__, FSR__, FSR__
+ /* inf * 0 + QNaN1 = QNaN1 */
+ test_op3 madd.s, f0, f1, f2, f0, F32_QNAN(1), F32_PINF, F32_0, \
+ F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), F32_QNAN(1), \
+ FSR__, FSR__, FSR__, FSR__
+
+ /* madd/msub SNaN is preserved */
+ test_op3 madd.s, f0, f1, f2, f0, F32_SNAN(1), F32_1, F32_1, \
+ F32_SNAN(1), F32_SNAN(1), F32_SNAN(1), F32_SNAN(1), \
+ FSR__, FSR__, FSR__, FSR__
+ test_op3 madd.s, f0, f1, f2, f0, F32_QNAN(1), F32_SNAN(2), F32_1, \
+ F32_SNAN(2), F32_SNAN(2), F32_SNAN(2), F32_SNAN(2), \
+ FSR__, FSR__, FSR__, FSR__
test_end
+#endif
test msub_s
test_op3 msub.s, f0, f1, f2, f0, 0x3f800000, 0x3f800001, 0x3f800001, \
- 0xb4800000, 0xb4800000, 0xb4800000, 0xb4800001
+ 0xb4800000, 0xb4800000, 0xb4800000, 0xb4800001, \
+ FSR_I, FSR_I, FSR_I, FSR_I
test_end
#endif
diff --git a/tests/tcg/xtensa/test_fp0_conv.S b/tests/tcg/xtensa/test_fp0_conv.S
index 147e3d5062..cfee6e5179 100644
--- a/tests/tcg/xtensa/test_fp0_conv.S
+++ b/tests/tcg/xtensa/test_fp0_conv.S
@@ -1,4 +1,5 @@
#include "macros.inc"
+#include "fpu.h"
test_suite fp0_conv
@@ -9,7 +10,7 @@ test_suite fp0_conv
wfr \fr, a2
.endm
-.macro test_ftoi_ex op, r0, fr0, v, c, r
+.macro test_ftoi_ex op, r0, fr0, v, c, r, sr
movi a2, 0
wur a2, fsr
movfp \fr0, \v
@@ -18,20 +19,25 @@ test_suite fp0_conv
movi a3, \r
assert eq, \r0, a3
rur a2, fsr
+#if DFPU
+ movi a3, \sr
+ assert eq, a2, a3
+#else
assert eqi, a2, 0
+#endif
.endm
-.macro test_ftoi op, r0, fr0, v, c, r
+.macro test_ftoi op, r0, fr0, v, c, r, sr
movi a2, 0
wur a2, fcr
- test_ftoi_ex \op, \r0, \fr0, \v, \c, \r
+ test_ftoi_ex \op, \r0, \fr0, \v, \c, \r, \sr
movi a2, 0x7c
wur a2, fcr
- test_ftoi_ex \op, \r0, \fr0, \v, \c, \r
+ test_ftoi_ex \op, \r0, \fr0, \v, \c, \r, \sr
.endm
-.macro test_itof_ex op, fr0, ar0, v, c, r
+.macro test_itof_ex op, fr0, ar0, v, c, r, sr
movi a2, 0
wur a2, fsr
movi \ar0, \v
@@ -42,23 +48,28 @@ test_suite fp0_conv
movi a3, \r
assert eq, a2, a3
rur a2, fsr
+#if DFPU
+ movi a3, \sr
+ assert eq, a2, a3
+#else
assert eqi, a2, 0
+#endif
.endm
-.macro test_itof_rm op, fr0, ar0, v, c, rm, r
+.macro test_itof_rm op, fr0, ar0, v, c, rm, r, sr
movi a2, \rm
wur a2, fcr
- test_itof_ex \op, \fr0, \ar0, \v, \c, \r
+ test_itof_ex \op, \fr0, \ar0, \v, \c, \r, \sr
movi a2, (\rm) | 0x7c
wur a2, fcr
- test_itof_ex \op, \fr0, \ar0, \v, \c, \r
+ test_itof_ex \op, \fr0, \ar0, \v, \c, \r, \sr
.endm
-.macro test_itof op, fr0, ar0, v, c, r0, r1, r2, r3
- test_itof_rm \op, \fr0, \ar0, \v, \c, 0, \r0
- test_itof_rm \op, \fr0, \ar0, \v, \c, 1, \r1
- test_itof_rm \op, \fr0, \ar0, \v, \c, 2, \r2
- test_itof_rm \op, \fr0, \ar0, \v, \c, 3, \r3
+.macro test_itof op, fr0, ar0, v, c, r0, r1, r2, r3, sr
+ test_itof_rm \op, \fr0, \ar0, \v, \c, 0, \r0, \sr
+ test_itof_rm \op, \fr0, \ar0, \v, \c, 1, \r1, \sr
+ test_itof_rm \op, \fr0, \ar0, \v, \c, 2, \r2, \sr
+ test_itof_rm \op, \fr0, \ar0, \v, \c, 3, \r3, \sr
.endm
test round_s
@@ -66,237 +77,237 @@ test round_s
wsr a2, cpenable
/* NaN */
- test_ftoi round.s, a2, f0, 0xffc00001, 0, 0x7fffffff
- test_ftoi round.s, a2, f0, 0xff800001, 0, 0x7fffffff
+ test_ftoi round.s, a2, f0, 0xffc00001, 0, 0x7fffffff, FSR_V
+ test_ftoi round.s, a2, f0, 0xff800001, 0, 0x7fffffff, FSR_V
/* -inf */
- test_ftoi round.s, a2, f0, 0xff800000, 0, 0x80000000
+ test_ftoi round.s, a2, f0, 0xff800000, 0, 0x80000000, FSR_V
/* negative overflow */
- test_ftoi round.s, a2, f0, 0xceffffff, 1, 0x80000000
- test_ftoi round.s, a2, f0, 0xcf000000, 0, 0x80000000
- test_ftoi round.s, a2, f0, 0xceffffff, 0, 0x80000080
+ test_ftoi round.s, a2, f0, 0xceffffff, 1, 0x80000000, FSR_V
+ test_ftoi round.s, a2, f0, 0xcf000000, 0, 0x80000000, FSR__
+ test_ftoi round.s, a2, f0, 0xceffffff, 0, 0x80000080, FSR__
/* negative */
- test_ftoi round.s, a2, f0, 0xbfa00000, 1, -2 /* -1.25 * 2 */
- test_ftoi round.s, a2, f0, 0xbfc00000, 0, -2 /* -1.5 */
- test_ftoi round.s, a2, f0, 0xbf800000, 1, -2 /* -1 * 2 */
- test_ftoi round.s, a2, f0, 0xbf800000, 0, -1 /* -1 */
- test_ftoi round.s, a2, f0, 0xbf400000, 0, -1 /* -0.75 */
- test_ftoi round.s, a2, f0, 0xbf000000, 0, 0 /* -0.5 */
+ test_ftoi round.s, a2, f0, 0xbfa00000, 1, -2, FSR_I /* -1.25 * 2 */
+ test_ftoi round.s, a2, f0, 0xbfc00000, 0, -2, FSR_I /* -1.5 */
+ test_ftoi round.s, a2, f0, 0xbf800000, 1, -2, FSR__ /* -1 * 2 */
+ test_ftoi round.s, a2, f0, 0xbf800000, 0, -1, FSR__ /* -1 */
+ test_ftoi round.s, a2, f0, 0xbf400000, 0, -1, FSR_I /* -0.75 */
+ test_ftoi round.s, a2, f0, 0xbf000000, 0, 0, FSR_I /* -0.5 */
/* positive */
- test_ftoi round.s, a2, f0, 0x3f000000, 0, 0 /* 0.5 */
- test_ftoi round.s, a2, f0, 0x3f400000, 0, 1 /* 0.75 */
- test_ftoi round.s, a2, f0, 0x3f800000, 0, 1 /* 1 */
- test_ftoi round.s, a2, f0, 0x3f800000, 1, 2 /* 1 * 2 */
- test_ftoi round.s, a2, f0, 0x3fc00000, 0, 2 /* 1.5 */
- test_ftoi round.s, a2, f0, 0x3fa00000, 1, 2 /* 1.25 * 2 */
+ test_ftoi round.s, a2, f0, 0x3f000000, 0, 0, FSR_I /* 0.5 */
+ test_ftoi round.s, a2, f0, 0x3f400000, 0, 1, FSR_I /* 0.75 */
+ test_ftoi round.s, a2, f0, 0x3f800000, 0, 1, FSR__ /* 1 */
+ test_ftoi round.s, a2, f0, 0x3f800000, 1, 2, FSR__ /* 1 * 2 */
+ test_ftoi round.s, a2, f0, 0x3fc00000, 0, 2, FSR_I /* 1.5 */
+ test_ftoi round.s, a2, f0, 0x3fa00000, 1, 2, FSR_I /* 1.25 * 2 */
/* positive overflow */
- test_ftoi round.s, a2, f0, 0x4effffff, 0, 0x7fffff80
- test_ftoi round.s, a2, f0, 0x4f000000, 0, 0x7fffffff
- test_ftoi round.s, a2, f0, 0x4effffff, 1, 0x7fffffff
+ test_ftoi round.s, a2, f0, 0x4effffff, 0, 0x7fffff80, FSR__
+ test_ftoi round.s, a2, f0, 0x4f000000, 0, 0x7fffffff, FSR_V
+ test_ftoi round.s, a2, f0, 0x4effffff, 1, 0x7fffffff, FSR_V
/* +inf */
- test_ftoi round.s, a2, f0, 0x7f800000, 0, 0x7fffffff
+ test_ftoi round.s, a2, f0, 0x7f800000, 0, 0x7fffffff, FSR_V
/* NaN */
- test_ftoi round.s, a2, f0, 0x7f800001, 0, 0x7fffffff
- test_ftoi round.s, a2, f0, 0x7fc00000, 0, 0x7fffffff
+ test_ftoi round.s, a2, f0, 0x7f800001, 0, 0x7fffffff, FSR_V
+ test_ftoi round.s, a2, f0, 0x7fc00000, 0, 0x7fffffff, FSR_V
test_end
test trunc_s
/* NaN */
- test_ftoi trunc.s, a2, f0, 0xffc00001, 0, 0x7fffffff
- test_ftoi trunc.s, a2, f0, 0xff800001, 0, 0x7fffffff
+ test_ftoi trunc.s, a2, f0, 0xffc00001, 0, 0x7fffffff, FSR_V
+ test_ftoi trunc.s, a2, f0, 0xff800001, 0, 0x7fffffff, FSR_V
/* -inf */
- test_ftoi trunc.s, a2, f0, 0xff800000, 0, 0x80000000
+ test_ftoi trunc.s, a2, f0, 0xff800000, 0, 0x80000000, FSR_V
/* negative overflow */
- test_ftoi trunc.s, a2, f0, 0xceffffff, 1, 0x80000000
- test_ftoi trunc.s, a2, f0, 0xcf000000, 0, 0x80000000
- test_ftoi trunc.s, a2, f0, 0xceffffff, 0, 0x80000080
+ test_ftoi trunc.s, a2, f0, 0xceffffff, 1, 0x80000000, FSR_V
+ test_ftoi trunc.s, a2, f0, 0xcf000000, 0, 0x80000000, FSR__
+ test_ftoi trunc.s, a2, f0, 0xceffffff, 0, 0x80000080, FSR__
/* negative */
- test_ftoi trunc.s, a2, f0, 0xbfa00000, 1, -2 /* -1.25 * 2 */
- test_ftoi trunc.s, a2, f0, 0xbfc00000, 0, -1 /* -1.5 */
- test_ftoi trunc.s, a2, f0, 0xbf800000, 1, -2 /* -1 * 2 */
- test_ftoi trunc.s, a2, f0, 0xbf800000, 0, -1 /* -1 */
- test_ftoi trunc.s, a2, f0, 0xbf400000, 0, 0 /* -0.75 */
- test_ftoi trunc.s, a2, f0, 0xbf000000, 0, 0 /* -0.5 */
+ test_ftoi trunc.s, a2, f0, 0xbfa00000, 1, -2, FSR_I /* -1.25 * 2 */
+ test_ftoi trunc.s, a2, f0, 0xbfc00000, 0, -1, FSR_I /* -1.5 */
+ test_ftoi trunc.s, a2, f0, 0xbf800000, 1, -2, FSR__ /* -1 * 2 */
+ test_ftoi trunc.s, a2, f0, 0xbf800000, 0, -1, FSR__ /* -1 */
+ test_ftoi trunc.s, a2, f0, 0xbf400000, 0, 0, FSR_I /* -0.75 */
+ test_ftoi trunc.s, a2, f0, 0xbf000000, 0, 0, FSR_I /* -0.5 */
/* positive */
- test_ftoi trunc.s, a2, f0, 0x3f000000, 0, 0 /* 0.5 */
- test_ftoi trunc.s, a2, f0, 0x3f400000, 0, 0 /* 0.75 */
- test_ftoi trunc.s, a2, f0, 0x3f800000, 0, 1 /* 1 */
- test_ftoi trunc.s, a2, f0, 0x3f800000, 1, 2 /* 1 * 2 */
- test_ftoi trunc.s, a2, f0, 0x3fc00000, 0, 1 /* 1.5 */
- test_ftoi trunc.s, a2, f0, 0x3fa00000, 1, 2 /* 1.25 * 2 */
+ test_ftoi trunc.s, a2, f0, 0x3f000000, 0, 0, FSR_I /* 0.5 */
+ test_ftoi trunc.s, a2, f0, 0x3f400000, 0, 0, FSR_I /* 0.75 */
+ test_ftoi trunc.s, a2, f0, 0x3f800000, 0, 1, FSR__ /* 1 */
+ test_ftoi trunc.s, a2, f0, 0x3f800000, 1, 2, FSR__ /* 1 * 2 */
+ test_ftoi trunc.s, a2, f0, 0x3fc00000, 0, 1, FSR_I /* 1.5 */
+ test_ftoi trunc.s, a2, f0, 0x3fa00000, 1, 2, FSR_I /* 1.25 * 2 */
/* positive overflow */
- test_ftoi trunc.s, a2, f0, 0x4effffff, 0, 0x7fffff80
- test_ftoi trunc.s, a2, f0, 0x4f000000, 0, 0x7fffffff
- test_ftoi trunc.s, a2, f0, 0x4effffff, 1, 0x7fffffff
+ test_ftoi trunc.s, a2, f0, 0x4effffff, 0, 0x7fffff80, FSR__
+ test_ftoi trunc.s, a2, f0, 0x4f000000, 0, 0x7fffffff, FSR_V
+ test_ftoi trunc.s, a2, f0, 0x4effffff, 1, 0x7fffffff, FSR_V
/* +inf */
- test_ftoi trunc.s, a2, f0, 0x7f800000, 0, 0x7fffffff
+ test_ftoi trunc.s, a2, f0, 0x7f800000, 0, 0x7fffffff, FSR_V
/* NaN */
- test_ftoi trunc.s, a2, f0, 0x7f800001, 0, 0x7fffffff
- test_ftoi trunc.s, a2, f0, 0x7fc00000, 0, 0x7fffffff
+ test_ftoi trunc.s, a2, f0, 0x7f800001, 0, 0x7fffffff, FSR_V
+ test_ftoi trunc.s, a2, f0, 0x7fc00000, 0, 0x7fffffff, FSR_V
test_end
test floor_s
/* NaN */
- test_ftoi floor.s, a2, f0, 0xffc00001, 0, 0x7fffffff
- test_ftoi floor.s, a2, f0, 0xff800001, 0, 0x7fffffff
+ test_ftoi floor.s, a2, f0, 0xffc00001, 0, 0x7fffffff, FSR_V
+ test_ftoi floor.s, a2, f0, 0xff800001, 0, 0x7fffffff, FSR_V
/* -inf */
- test_ftoi floor.s, a2, f0, 0xff800000, 0, 0x80000000
+ test_ftoi floor.s, a2, f0, 0xff800000, 0, 0x80000000, FSR_V
/* negative overflow */
- test_ftoi floor.s, a2, f0, 0xceffffff, 1, 0x80000000
- test_ftoi floor.s, a2, f0, 0xcf000000, 0, 0x80000000
- test_ftoi floor.s, a2, f0, 0xceffffff, 0, 0x80000080
+ test_ftoi floor.s, a2, f0, 0xceffffff, 1, 0x80000000, FSR_V
+ test_ftoi floor.s, a2, f0, 0xcf000000, 0, 0x80000000, FSR__
+ test_ftoi floor.s, a2, f0, 0xceffffff, 0, 0x80000080, FSR__
/* negative */
- test_ftoi floor.s, a2, f0, 0xbfa00000, 1, -3 /* -1.25 * 2 */
- test_ftoi floor.s, a2, f0, 0xbfc00000, 0, -2 /* -1.5 */
- test_ftoi floor.s, a2, f0, 0xbf800000, 1, -2 /* -1 * 2 */
- test_ftoi floor.s, a2, f0, 0xbf800000, 0, -1 /* -1 */
- test_ftoi floor.s, a2, f0, 0xbf400000, 0, -1 /* -0.75 */
- test_ftoi floor.s, a2, f0, 0xbf000000, 0, -1 /* -0.5 */
+ test_ftoi floor.s, a2, f0, 0xbfa00000, 1, -3, FSR_I /* -1.25 * 2 */
+ test_ftoi floor.s, a2, f0, 0xbfc00000, 0, -2, FSR_I /* -1.5 */
+ test_ftoi floor.s, a2, f0, 0xbf800000, 1, -2, FSR__ /* -1 * 2 */
+ test_ftoi floor.s, a2, f0, 0xbf800000, 0, -1, FSR__ /* -1 */
+ test_ftoi floor.s, a2, f0, 0xbf400000, 0, -1, FSR_I /* -0.75 */
+ test_ftoi floor.s, a2, f0, 0xbf000000, 0, -1, FSR_I /* -0.5 */
/* positive */
- test_ftoi floor.s, a2, f0, 0x3f000000, 0, 0 /* 0.5 */
- test_ftoi floor.s, a2, f0, 0x3f400000, 0, 0 /* 0.75 */
- test_ftoi floor.s, a2, f0, 0x3f800000, 0, 1 /* 1 */
- test_ftoi floor.s, a2, f0, 0x3f800000, 1, 2 /* 1 * 2 */
- test_ftoi floor.s, a2, f0, 0x3fc00000, 0, 1 /* 1.5 */
- test_ftoi floor.s, a2, f0, 0x3fa00000, 1, 2 /* 1.25 * 2 */
+ test_ftoi floor.s, a2, f0, 0x3f000000, 0, 0, FSR_I /* 0.5 */
+ test_ftoi floor.s, a2, f0, 0x3f400000, 0, 0, FSR_I /* 0.75 */
+ test_ftoi floor.s, a2, f0, 0x3f800000, 0, 1, FSR__ /* 1 */
+ test_ftoi floor.s, a2, f0, 0x3f800000, 1, 2, FSR__ /* 1 * 2 */
+ test_ftoi floor.s, a2, f0, 0x3fc00000, 0, 1, FSR_I /* 1.5 */
+ test_ftoi floor.s, a2, f0, 0x3fa00000, 1, 2, FSR_I /* 1.25 * 2 */
/* positive overflow */
- test_ftoi floor.s, a2, f0, 0x4effffff, 0, 0x7fffff80
- test_ftoi floor.s, a2, f0, 0x4f000000, 0, 0x7fffffff
- test_ftoi floor.s, a2, f0, 0x4effffff, 1, 0x7fffffff
+ test_ftoi floor.s, a2, f0, 0x4effffff, 0, 0x7fffff80, FSR__
+ test_ftoi floor.s, a2, f0, 0x4f000000, 0, 0x7fffffff, FSR_V
+ test_ftoi floor.s, a2, f0, 0x4effffff, 1, 0x7fffffff, FSR_V
/* +inf */
- test_ftoi floor.s, a2, f0, 0x7f800000, 0, 0x7fffffff
+ test_ftoi floor.s, a2, f0, 0x7f800000, 0, 0x7fffffff, FSR_V
/* NaN */
- test_ftoi floor.s, a2, f0, 0x7f800001, 0, 0x7fffffff
- test_ftoi floor.s, a2, f0, 0x7fc00000, 0, 0x7fffffff
+ test_ftoi floor.s, a2, f0, 0x7f800001, 0, 0x7fffffff, FSR_V
+ test_ftoi floor.s, a2, f0, 0x7fc00000, 0, 0x7fffffff, FSR_V
test_end
test ceil_s
/* NaN */
- test_ftoi ceil.s, a2, f0, 0xffc00001, 0, 0x7fffffff
- test_ftoi ceil.s, a2, f0, 0xff800001, 0, 0x7fffffff
+ test_ftoi ceil.s, a2, f0, 0xffc00001, 0, 0x7fffffff, FSR_V
+ test_ftoi ceil.s, a2, f0, 0xff800001, 0, 0x7fffffff, FSR_V
/* -inf */
- test_ftoi ceil.s, a2, f0, 0xff800000, 0, 0x80000000
+ test_ftoi ceil.s, a2, f0, 0xff800000, 0, 0x80000000, FSR_V
/* negative overflow */
- test_ftoi ceil.s, a2, f0, 0xceffffff, 1, 0x80000000
- test_ftoi ceil.s, a2, f0, 0xcf000000, 0, 0x80000000
- test_ftoi ceil.s, a2, f0, 0xceffffff, 0, 0x80000080
+ test_ftoi ceil.s, a2, f0, 0xceffffff, 1, 0x80000000, FSR_V
+ test_ftoi ceil.s, a2, f0, 0xcf000000, 0, 0x80000000, FSR__
+ test_ftoi ceil.s, a2, f0, 0xceffffff, 0, 0x80000080, FSR__
/* negative */
- test_ftoi ceil.s, a2, f0, 0xbfa00000, 1, -2 /* -1.25 * 2 */
- test_ftoi ceil.s, a2, f0, 0xbfc00000, 0, -1 /* -1.5 */
- test_ftoi ceil.s, a2, f0, 0xbf800000, 1, -2 /* -1 * 2 */
- test_ftoi ceil.s, a2, f0, 0xbf800000, 0, -1 /* -1 */
- test_ftoi ceil.s, a2, f0, 0xbf400000, 0, 0 /* -0.75 */
- test_ftoi ceil.s, a2, f0, 0xbf000000, 0, 0 /* -0.5 */
+ test_ftoi ceil.s, a2, f0, 0xbfa00000, 1, -2, FSR_I /* -1.25 * 2 */
+ test_ftoi ceil.s, a2, f0, 0xbfc00000, 0, -1, FSR_I /* -1.5 */
+ test_ftoi ceil.s, a2, f0, 0xbf800000, 1, -2, FSR__ /* -1 * 2 */
+ test_ftoi ceil.s, a2, f0, 0xbf800000, 0, -1, FSR__ /* -1 */
+ test_ftoi ceil.s, a2, f0, 0xbf400000, 0, 0, FSR_I /* -0.75 */
+ test_ftoi ceil.s, a2, f0, 0xbf000000, 0, 0, FSR_I /* -0.5 */
/* positive */
- test_ftoi ceil.s, a2, f0, 0x3f000000, 0, 1 /* 0.5 */
- test_ftoi ceil.s, a2, f0, 0x3f400000, 0, 1 /* 0.75 */
- test_ftoi ceil.s, a2, f0, 0x3f800000, 0, 1 /* 1 */
- test_ftoi ceil.s, a2, f0, 0x3f800000, 1, 2 /* 1 * 2 */
- test_ftoi ceil.s, a2, f0, 0x3fc00000, 0, 2 /* 1.5 */
- test_ftoi ceil.s, a2, f0, 0x3fa00000, 1, 3 /* 1.25 * 2 */
+ test_ftoi ceil.s, a2, f0, 0x3f000000, 0, 1, FSR_I /* 0.5 */
+ test_ftoi ceil.s, a2, f0, 0x3f400000, 0, 1, FSR_I /* 0.75 */
+ test_ftoi ceil.s, a2, f0, 0x3f800000, 0, 1, FSR__ /* 1 */
+ test_ftoi ceil.s, a2, f0, 0x3f800000, 1, 2, FSR__ /* 1 * 2 */
+ test_ftoi ceil.s, a2, f0, 0x3fc00000, 0, 2, FSR_I /* 1.5 */
+ test_ftoi ceil.s, a2, f0, 0x3fa00000, 1, 3, FSR_I /* 1.25 * 2 */
/* positive overflow */
- test_ftoi ceil.s, a2, f0, 0x4effffff, 0, 0x7fffff80
- test_ftoi ceil.s, a2, f0, 0x4f000000, 0, 0x7fffffff
- test_ftoi ceil.s, a2, f0, 0x4effffff, 1, 0x7fffffff
+ test_ftoi ceil.s, a2, f0, 0x4effffff, 0, 0x7fffff80, FSR__
+ test_ftoi ceil.s, a2, f0, 0x4f000000, 0, 0x7fffffff, FSR_V
+ test_ftoi ceil.s, a2, f0, 0x4effffff, 1, 0x7fffffff, FSR_V
/* +inf */
- test_ftoi ceil.s, a2, f0, 0x7f800000, 0, 0x7fffffff
+ test_ftoi ceil.s, a2, f0, 0x7f800000, 0, 0x7fffffff, FSR_V
/* NaN */
- test_ftoi ceil.s, a2, f0, 0x7f800001, 0, 0x7fffffff
- test_ftoi ceil.s, a2, f0, 0x7fc00000, 0, 0x7fffffff
+ test_ftoi ceil.s, a2, f0, 0x7f800001, 0, 0x7fffffff, FSR_V
+ test_ftoi ceil.s, a2, f0, 0x7fc00000, 0, 0x7fffffff, FSR_V
test_end
test utrunc_s
/* NaN */
- test_ftoi utrunc.s, a2, f0, 0xffc00001, 0, 0xffffffff
- test_ftoi utrunc.s, a2, f0, 0xff800001, 0, 0xffffffff
+ test_ftoi utrunc.s, a2, f0, 0xffc00001, 0, 0xffffffff, FSR_V
+ test_ftoi utrunc.s, a2, f0, 0xff800001, 0, 0xffffffff, FSR_V
/* -inf */
- test_ftoi utrunc.s, a2, f0, 0xff800000, 0, 0x80000000
+ test_ftoi utrunc.s, a2, f0, 0xff800000, 0, 0x80000000, FSR_V
/* negative overflow */
- test_ftoi utrunc.s, a2, f0, 0xceffffff, 1, 0x80000000
- test_ftoi utrunc.s, a2, f0, 0xcf000000, 0, 0x80000000
- test_ftoi utrunc.s, a2, f0, 0xceffffff, 0, 0x80000080
+ test_ftoi utrunc.s, a2, f0, 0xceffffff, 1, 0x80000000, FSR_V
+ test_ftoi utrunc.s, a2, f0, 0xcf000000, 0, 0x80000000, FSR_V
+ test_ftoi utrunc.s, a2, f0, 0xceffffff, 0, 0x80000080, FSR_V
/* negative */
- test_ftoi utrunc.s, a2, f0, 0xbfa00000, 1, -2 /* -1.25 * 2 */
- test_ftoi utrunc.s, a2, f0, 0xbfc00000, 0, -1 /* -1.5 */
- test_ftoi utrunc.s, a2, f0, 0xbf800000, 1, -2 /* -1 * 2 */
- test_ftoi utrunc.s, a2, f0, 0xbf800000, 0, -1 /* -1 */
- test_ftoi utrunc.s, a2, f0, 0xbf400000, 0, 0 /* -0.75 */
- test_ftoi utrunc.s, a2, f0, 0xbf000000, 0, 0 /* -0.5 */
+ test_ftoi utrunc.s, a2, f0, 0xbfa00000, 1, -2, FSR_V /* -1.25 * 2 */
+ test_ftoi utrunc.s, a2, f0, 0xbfc00000, 0, -1, FSR_V /* -1.5 */
+ test_ftoi utrunc.s, a2, f0, 0xbf800000, 1, -2, FSR_V /* -1 * 2 */
+ test_ftoi utrunc.s, a2, f0, 0xbf800000, 0, -1, FSR_V /* -1 */
+ test_ftoi utrunc.s, a2, f0, 0xbf400000, 0, 0, FSR_I /* -0.75 */
+ test_ftoi utrunc.s, a2, f0, 0xbf000000, 0, 0, FSR_I /* -0.5 */
/* positive */
- test_ftoi utrunc.s, a2, f0, 0x3f000000, 0, 0 /* 0.5 */
- test_ftoi utrunc.s, a2, f0, 0x3f400000, 0, 0 /* 0.75 */
- test_ftoi utrunc.s, a2, f0, 0x3f800000, 0, 1 /* 1 */
- test_ftoi utrunc.s, a2, f0, 0x3f800000, 1, 2 /* 1 * 2 */
- test_ftoi utrunc.s, a2, f0, 0x3fc00000, 0, 1 /* 1.5 */
- test_ftoi utrunc.s, a2, f0, 0x3fa00000, 1, 2 /* 1.25 * 2 */
+ test_ftoi utrunc.s, a2, f0, 0x3f000000, 0, 0, FSR_I /* 0.5 */
+ test_ftoi utrunc.s, a2, f0, 0x3f400000, 0, 0, FSR_I /* 0.75 */
+ test_ftoi utrunc.s, a2, f0, 0x3f800000, 0, 1, FSR__ /* 1 */
+ test_ftoi utrunc.s, a2, f0, 0x3f800000, 1, 2, FSR__ /* 1 * 2 */
+ test_ftoi utrunc.s, a2, f0, 0x3fc00000, 0, 1, FSR_I /* 1.5 */
+ test_ftoi utrunc.s, a2, f0, 0x3fa00000, 1, 2, FSR_I /* 1.25 * 2 */
/* positive overflow */
- test_ftoi utrunc.s, a2, f0, 0x4effffff, 0, 0x7fffff80
- test_ftoi utrunc.s, a2, f0, 0x4f000000, 0, 0x80000000
- test_ftoi utrunc.s, a2, f0, 0x4effffff, 1, 0xffffff00
- test_ftoi utrunc.s, a2, f0, 0x4f800000, 1, 0xffffffff
+ test_ftoi utrunc.s, a2, f0, 0x4effffff, 0, 0x7fffff80, FSR__
+ test_ftoi utrunc.s, a2, f0, 0x4f000000, 0, 0x80000000, FSR__
+ test_ftoi utrunc.s, a2, f0, 0x4effffff, 1, 0xffffff00, FSR__
+ test_ftoi utrunc.s, a2, f0, 0x4f800000, 1, 0xffffffff, FSR_V
/* +inf */
- test_ftoi utrunc.s, a2, f0, 0x7f800000, 0, 0xffffffff
+ test_ftoi utrunc.s, a2, f0, 0x7f800000, 0, 0xffffffff, FSR_V
/* NaN */
- test_ftoi utrunc.s, a2, f0, 0x7f800001, 0, 0xffffffff
- test_ftoi utrunc.s, a2, f0, 0x7fc00000, 0, 0xffffffff
+ test_ftoi utrunc.s, a2, f0, 0x7f800001, 0, 0xffffffff, FSR_V
+ test_ftoi utrunc.s, a2, f0, 0x7fc00000, 0, 0xffffffff, FSR_V
test_end
test float_s
test_itof float.s, f0, a2, -1, 0, \
- 0xbf800000, 0xbf800000, 0xbf800000, 0xbf800000
- test_itof float.s, f0, a2, 0, 0, 0, 0, 0, 0
+ 0xbf800000, 0xbf800000, 0xbf800000, 0xbf800000, FSR__
+ test_itof float.s, f0, a2, 0, 0, 0, 0, 0, 0, FSR__
test_itof float.s, f0, a2, 1, 1, \
- 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000
+ 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, FSR__
test_itof float.s, f0, a2, 1, 0, \
- 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000
+ 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, FSR__
test_itof float.s, f0, a2, 0x7fffffff, 0, \
- 0x4f000000, 0x4effffff, 0x4f000000, 0x4effffff
+ 0x4f000000, 0x4effffff, 0x4f000000, 0x4effffff, FSR_I
test_end
test ufloat_s
- test_itof ufloat.s, f0, a2, 0, 0, 0, 0, 0, 0
+ test_itof ufloat.s, f0, a2, 0, 0, 0, 0, 0, 0, FSR__
test_itof ufloat.s, f0, a2, 1, 1, \
- 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000
+ 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, FSR__
test_itof ufloat.s, f0, a2, 1, 0, \
- 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000
+ 0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000, FSR__
test_itof ufloat.s, f0, a2, 0x7fffffff, 0, \
- 0x4f000000, 0x4effffff, 0x4f000000, 0x4effffff
+ 0x4f000000, 0x4effffff, 0x4f000000, 0x4effffff, FSR_I
test_itof ufloat.s, f0, a2, 0xffffffff, 0, \
- 0x4f800000, 0x4f7fffff, 0x4f800000, 0x4f7fffff
+ 0x4f800000, 0x4f7fffff, 0x4f800000, 0x4f7fffff, FSR_I
test_end
#endif
diff --git a/tests/tcg/xtensa/test_fp0_div.S b/tests/tcg/xtensa/test_fp0_div.S
new file mode 100644
index 0000000000..c3e7ad7bb5
--- /dev/null
+++ b/tests/tcg/xtensa/test_fp0_div.S
@@ -0,0 +1,82 @@
+#include "macros.inc"
+#include "fpu.h"
+
+test_suite fp0_div
+
+#if XCHAL_HAVE_FP_DIV
+
+.macro divs_seq q, a, b, r, y, y0, an, bn, e, ex
+ div0.s \y0, \b
+ nexp01.s \bn, \b
+ const.s \e, 1
+ maddn.s \e, \bn, \y0
+ mov.s \y, \y0
+ mov.s \ex, \b
+ nexp01.s \an, \a
+ maddn.s \y, \e, \y0
+ const.s \e, 1
+ const.s \q, 0
+ neg.s \r, \an
+ maddn.s \e, \bn, \y
+ maddn.s \q, \r, \y0
+ mkdadj.s \ex, \a
+ maddn.s \y, \e, \y
+ maddn.s \r, \bn, \q
+ const.s \e, 1
+ maddn.s \e, \bn, \y
+ maddn.s \q, \r, \y
+ neg.s \r, \an
+ maddn.s \y, \e, \y
+ maddn.s \r, \bn, \q
+ addexpm.s \q, \ex
+ addexp.s \y, \ex
+ divn.s \q, \r, \y
+.endm
+
+.macro div_s fr0, fr1, fr2
+ divs_seq \fr0, \fr1, \fr2, f9, f10, f11, f12, f13, f14, f15
+.endm
+
+.macro movfp fr, v
+ movi a2, \v
+ wfr \fr, a2
+.endm
+
+.macro check_res fr, r, sr
+ rfr a2, \fr
+ dump a2
+ movi a3, \r
+ assert eq, a2, a3
+ rur a2, fsr
+ movi a3, \sr
+ assert eq, a2, a3
+.endm
+
+test div_s
+ movi a2, 1
+ wsr a2, cpenable
+
+ test_op2 div_s, f0, f1, f2, 0x40000000, 0x40400000, \
+ 0x3f2aaaab, 0x3f2aaaaa, 0x3f2aaaab, 0x3f2aaaaa, \
+ FSR_I, FSR_I, FSR_I, FSR_I
+ test_op2 div_s, f3, f4, f5, F32_1, F32_0, \
+ F32_PINF, F32_PINF, F32_PINF, F32_PINF, \
+ FSR_Z, FSR_Z, FSR_Z, FSR_Z
+ test_op2 div_s, f6, f7, f8, F32_0, F32_0, \
+ F32_DNAN, F32_DNAN, F32_DNAN, F32_DNAN, \
+ FSR_V, FSR_V, FSR_V, FSR_V
+
+ /* MAX_FLOAT / 0.5 = +inf/MAX_FLOAT */
+ test_op2 div_s, f0, f1, f2, F32_MAX, F32_0_5, \
+ F32_PINF, F32_MAX, F32_PINF, F32_MAX, \
+ FSR_OI, FSR_OI, FSR_OI, FSR_OI
+
+ /* 0.5 / MAX_FLOAT = denorm */
+ test_op2 div_s, f0, f1, f2, F32_0_5, F32_MAX, \
+ 0x00100000, 0x00100000, 0x00100001, 0x00100000, \
+ FSR_UI, FSR_UI, FSR_UI, FSR_UI
+test_end
+
+#endif
+
+test_suite_end
diff --git a/tests/tcg/xtensa/test_fp0_sqrt.S b/tests/tcg/xtensa/test_fp0_sqrt.S
new file mode 100644
index 0000000000..585973dce6
--- /dev/null
+++ b/tests/tcg/xtensa/test_fp0_sqrt.S
@@ -0,0 +1,76 @@
+#include "macros.inc"
+#include "fpu.h"
+
+test_suite fp0_sqrt
+
+#if XCHAL_HAVE_FP_SQRT
+
+.macro sqrt_seq r, a, y, t1, hn, h2, t5, h
+ sqrt0.s \y, \a
+ const.s \t1, 0
+ maddn.s \t1, \y, \y
+ nexp01.s \hn, \a
+ const.s \r, 3
+ addexp.s \hn, \r
+ maddn.s \r, \t1, \hn
+ nexp01.s \t1, \a
+ neg.s \h2, \t1
+ maddn.s \y, \r, \y
+ const.s \r, 0
+ const.s \t5, 0
+ const.s \h, 0
+ maddn.s \r, \h2, \y
+ maddn.s \t5, \y, \hn
+ const.s \hn, 3
+ maddn.s \h, \hn, \y
+ maddn.s \t1, \r, \r
+ maddn.s \hn, \t5, \y
+ neg.s \y, \h
+ maddn.s \r, \t1, \y
+ maddn.s \h, \hn, \h
+ mksadj.s \y, \a
+ nexp01.s \a, \a
+ maddn.s \a, \r, \r
+ neg.s \t1, \h
+ addexpm.s \r, \y
+ addexp.s \t1, \y
+ divn.s \r, \a, \t1
+.endm
+
+.macro sqrt_s fr0, fr1
+ sqrt_seq \fr0, \fr1, f10, f11, f12, f13, f14, f15
+.endm
+
+.macro movfp fr, v
+ movi a2, \v
+ wfr \fr, a2
+.endm
+
+.macro check_res fr, r, sr
+ rfr a2, \fr
+ dump a2
+ movi a3, \r
+ assert eq, a2, a3
+ rur a2, fsr
+ movi a3, \sr
+ assert eq, a2, a3
+.endm
+
+test sqrt_s
+ movi a2, 1
+ wsr a2, cpenable
+
+ test_op1 sqrt_s, f0, f1, 0x40000000, \
+ 0x3fb504f3, 0x3fb504f3, 0x3fb504f4, 0x3fb504f3, \
+ FSR_I, FSR_I, FSR_I, FSR_I
+ test_op1 sqrt_s, f3, f4, F32_1, \
+ F32_1, F32_1, F32_1, F32_1, \
+ FSR__, FSR__, FSR__, FSR__
+ test_op1 sqrt_s, f6, f7, F32_MINUS | F32_1, \
+ F32_DNAN, F32_DNAN, F32_DNAN, F32_DNAN, \
+ FSR_V, FSR_V, FSR_V, FSR_V
+test_end
+
+#endif
+
+test_suite_end
diff --git a/tests/tcg/xtensa/test_fp1.S b/tests/tcg/xtensa/test_fp1.S
index 6e182e5964..77336a3fcf 100644
--- a/tests/tcg/xtensa/test_fp1.S
+++ b/tests/tcg/xtensa/test_fp1.S
@@ -1,4 +1,5 @@
#include "macros.inc"
+#include "fpu.h"
test_suite fp1
@@ -9,7 +10,7 @@ test_suite fp1
wfr \fr, a2
.endm
-.macro test_ord_ex op, br, fr0, fr1, v0, v1, r
+.macro test_ord_ex op, br, fr0, fr1, v0, v1, r, sr
movi a2, 0
wur a2, fsr
movfp \fr0, \v0
@@ -20,65 +21,70 @@ test_suite fp1
movt a2, a3, \br
assert eqi, a2, \r
rur a2, fsr
+#if DFPU
+ movi a3, \sr
+ assert eq, a2, a3
+#else
assert eqi, a2, 0
+#endif
.endm
-.macro test_ord op, br, fr0, fr1, v0, v1, r
+.macro test_ord op, br, fr0, fr1, v0, v1, r, sr
movi a2, 0
wur a2, fcr
- test_ord_ex \op, \br, \fr0, \fr1, \v0, \v1, \r
+ test_ord_ex \op, \br, \fr0, \fr1, \v0, \v1, \r, \sr
movi a2, 0x7c
wur a2, fcr
- test_ord_ex \op, \br, \fr0, \fr1, \v0, \v1, \r
+ test_ord_ex \op, \br, \fr0, \fr1, \v0, \v1, \r, \sr
.endm
-.macro test_ord_all op, aa, ab, ba, aPI, PIa, aN, Na, II, IN, NI
- test_ord \op b0, f0, f1, 0x3f800000, 0x3f800000, \aa
- test_ord \op b1, f2, f3, 0x3f800000, 0x3fc00000, \ab
- test_ord \op b2, f4, f5, 0x3fc00000, 0x3f800000, \ba
- test_ord \op b3, f6, f7, 0x3f800000, 0x7f800000, \aPI
- test_ord \op b4, f8, f9, 0x7f800000, 0x3f800000, \PIa
- test_ord \op b5, f10, f11, 0x3f800000, 0xffc00001, \aN
- test_ord \op b6, f12, f13, 0x3f800000, 0xff800001, \aN
- test_ord \op b7, f14, f15, 0x3f800000, 0x7f800001, \aN
- test_ord \op b8, f0, f1, 0x3f800000, 0x7fc00000, \aN
- test_ord \op b9, f2, f3, 0xffc00001, 0x3f800000, \Na
- test_ord \op b10, f4, f5, 0xff800001, 0x3f800000, \Na
- test_ord \op b11, f6, f7, 0x7f800001, 0x3f800000, \Na
- test_ord \op b12, f8, f9, 0x7fc00000, 0x3f800000, \Na
- test_ord \op b13, f10, f11, 0x7f800000, 0x7f800000, \II
- test_ord \op b14, f12, f13, 0x7f800000, 0x7fc00000, \IN
- test_ord \op b15, f14, f15, 0x7fc00000, 0x7f800000, \NI
+.macro test_ord_all op, aa, ab, ba, aPI, PIa, aN, Na, II, IN, NI, qnan_sr
+ test_ord \op b0, f0, f1, 0x3f800000, 0x3f800000, \aa, FSR__ /* ord == ord */
+ test_ord \op b1, f2, f3, 0x3f800000, 0x3fc00000, \ab, FSR__ /* ord < ord */
+ test_ord \op b2, f4, f5, 0x3fc00000, 0x3f800000, \ba, FSR__ /* ord > ord */
+ test_ord \op b3, f6, f7, 0x3f800000, 0x7f800000, \aPI, FSR__ /* ord +INF */
+ test_ord \op b4, f8, f9, 0x7f800000, 0x3f800000, \PIa, FSR__ /* +INF ord */
+ test_ord \op b5, f10, f11, 0x3f800000, 0xffc00001, \aN, \qnan_sr /* ord -QNaN */
+ test_ord \op b6, f12, f13, 0x3f800000, 0xff800001, \aN, FSR_V /* ord -SNaN */
+ test_ord \op b7, f14, f15, 0x3f800000, 0x7f800001, \aN, FSR_V /* ord +SNaN */
+ test_ord \op b8, f0, f1, 0x3f800000, 0x7fc00000, \aN, \qnan_sr /* ord +QNaN */
+ test_ord \op b9, f2, f3, 0xffc00001, 0x3f800000, \Na, \qnan_sr /* -QNaN ord */
+ test_ord \op b10, f4, f5, 0xff800001, 0x3f800000, \Na, FSR_V /* -SNaN ord */
+ test_ord \op b11, f6, f7, 0x7f800001, 0x3f800000, \Na, FSR_V /* +SNaN ord */
+ test_ord \op b12, f8, f9, 0x7fc00000, 0x3f800000, \Na, \qnan_sr /* +QNaN ord */
+ test_ord \op b13, f10, f11, 0x7f800000, 0x7f800000, \II, FSR__ /* +INF +INF */
+ test_ord \op b14, f12, f13, 0x7f800000, 0x7fc00000, \IN, \qnan_sr /* +INF +QNaN */
+ test_ord \op b15, f14, f15, 0x7fc00000, 0x7f800000, \NI, \qnan_sr /* +QNaN +INF */
.endm
test un_s
movi a2, 1
wsr a2, cpenable
- test_ord_all un.s, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1
+ test_ord_all un.s, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, FSR__
test_end
test oeq_s
- test_ord_all oeq.s, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0
+ test_ord_all oeq.s, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, FSR__
test_end
test ueq_s
- test_ord_all ueq.s, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1
+ test_ord_all ueq.s, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, FSR__
test_end
test olt_s
- test_ord_all olt.s, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0
+ test_ord_all olt.s, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, FSR_V
test_end
test ult_s
- test_ord_all ult.s, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1
+ test_ord_all ult.s, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, FSR__
test_end
test ole_s
- test_ord_all ole.s, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0
+ test_ord_all ole.s, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, FSR_V
test_end
test ule_s
- test_ord_all ule.s, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1
+ test_ord_all ule.s, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, FSR__
test_end
.macro test_cond op, fr0, fr1, cr, v0, v1, r
diff --git a/tests/tcg/xtensa/test_lsc.S b/tests/tcg/xtensa/test_lsc.S
index 0578bf19e7..348822bdd3 100644
--- a/tests/tcg/xtensa/test_lsc.S
+++ b/tests/tcg/xtensa/test_lsc.S
@@ -1,4 +1,5 @@
#include "macros.inc"
+#include "fpu.h"
test_suite lsc
@@ -9,9 +10,14 @@ test lsi
wsr a2, cpenable
movi a2, 1f
- lsi f0, a2, 0
lsi f1, a2, 4
+#if DFPU
+ lsi f2, a2, 8
+ lsip f0, a2, 8
+#else
+ lsi f0, a2, 0
lsiu f2, a2, 8
+#endif
movi a3, 1f + 8
assert eq, a2, a3
rfr a2, f0
@@ -34,13 +40,18 @@ test ssi
movi a2, 1f
movi a3, 0x40800000
wfr f3, a3
- ssi f3, a2, 0
movi a3, 0x40a00000
wfr f4, a3
- ssi f4, a2, 4
movi a3, 0x40c00000
wfr f5, a3
+ ssi f4, a2, 4
+#if DFPU
+ ssi f5, a2, 8
+ ssip f3, a2, 8
+#else
+ ssi f3, a2, 0
ssiu f5, a2, 8
+#endif
movi a3, 1f + 8
assert eq, a2, a3
l32i a4, a2, -8
@@ -62,11 +73,16 @@ test_end
test lsx
movi a2, 1f
movi a3, 0
+ movi a4, 4
+ movi a5, 8
+ lsx f7, a2, a4
+#if DFPU
+ lsx f8, a2, a5
+ lsxp f6, a2, a5
+#else
lsx f6, a2, a3
- movi a3, 4
- lsx f7, a2, a3
- movi a3, 8
- lsxu f8, a2, a3
+ lsxu f8, a2, a5
+#endif
movi a3, 1f + 8
assert eq, a2, a3
rfr a2, f6
@@ -87,18 +103,23 @@ test_end
test ssx
movi a2, 1f
- movi a3, 0
movi a4, 0x41200000
wfr f9, a4
- ssx f9, a2, a3
- movi a3, 4
movi a4, 0x41300000
wfr f10, a4
- ssx f10, a2, a3
- movi a3, 8
movi a4, 0x41400000
wfr f11, a4
- ssxu f11, a2, a3
+ movi a3, 0
+ movi a4, 4
+ movi a5, 8
+ ssx f10, a2, a4
+#if DFPU
+ ssx f11, a2, a5
+ ssxp f9, a2, a5
+#else
+ ssx f9, a2, a3
+ ssxu f11, a2, a5
+#endif
movi a3, 1f + 8
assert eq, a2, a3
l32i a4, a2, -8
@@ -119,4 +140,127 @@ test_end
#endif
+#if XCHAL_HAVE_DFP
+
+#if XCHAL_HAVE_BE
+#define F64_HIGH_OFF 0
+#else
+#define F64_HIGH_OFF 4
+#endif
+
+.macro movdf fr, hi, lo
+ movi a2, \hi
+ movi a3, \lo
+ wfrd \fr, a2, a3
+.endm
+
+test ldi
+ movi a2, 1
+ wsr a2, cpenable
+
+ movi a2, 1f
+ ldi f1, a2, 8
+ ldi f2, a2, 16
+ ldip f0, a2, 16
+ movi a3, 1f + 16
+ assert eq, a2, a3
+ rfrd a2, f0
+ movi a3, 0x3ff00000
+ assert eq, a2, a3
+ rfrd a2, f1
+ movi a3, 0x40000000
+ assert eq, a2, a3
+ rfrd a2, f2
+ movi a3, 0x40080000
+ assert eq, a2, a3
+.data
+ .align 8
+1:
+.double 1, 2, 3
+.text
+test_end
+
+test sdi
+ movdf f3, 0x40800000, 0
+ movdf f4, 0x40a00000, 0
+ movdf f5, 0x40c00000, 0
+ movi a2, 1f
+ sdi f4, a2, 8
+ sdi f5, a2, 16
+ sdip f3, a2, 16
+ movi a3, 1f + 16
+ assert eq, a2, a3
+ l32i a4, a2, -16 + F64_HIGH_OFF
+ movi a3, 0x40800000
+ assert eq, a4, a3
+ l32i a4, a2, -8 + F64_HIGH_OFF
+ movi a3, 0x40a00000
+ assert eq, a4, a3
+ l32i a4, a2, F64_HIGH_OFF
+ movi a3, 0x40c00000
+ assert eq, a4, a3
+.data
+ .align 8
+1:
+.double 0, 0, 0
+.text
+test_end
+
+test ldx
+ movi a2, 1f
+ movi a3, 0
+ movi a4, 8
+ movi a5, 16
+ ldx f7, a2, a4
+ ldx f8, a2, a5
+ ldxp f6, a2, a5
+ movi a3, 1f + 16
+ assert eq, a2, a3
+ rfrd a2, f6
+ movi a3, 0x401c0000
+ assert eq, a2, a3
+ rfrd a2, f7
+ movi a3, 0x40200000
+ assert eq, a2, a3
+ rfrd a2, f8
+ movi a3, 0x40220000
+ assert eq, a2, a3
+.data
+ .align 8
+1:
+.double 7, 8, 9
+.text
+test_end
+
+test sdx
+ movdf f9, 0x41200000, 0
+ movdf f10, 0x41300000, 0
+ movdf f11, 0x41400000, 0
+ movi a2, 1f
+ movi a3, 0
+ movi a4, 8
+ movi a5, 16
+ sdx f10, a2, a4
+ sdx f11, a2, a5
+ sdxp f9, a2, a5
+ movi a3, 1f + 16
+ assert eq, a2, a3
+ l32i a4, a2, -16 + F64_HIGH_OFF
+ movi a3, 0x41200000
+ assert eq, a4, a3
+ l32i a4, a2, -8 + F64_HIGH_OFF
+ movi a3, 0x41300000
+ assert eq, a4, a3
+ l32i a4, a2, F64_HIGH_OFF
+ movi a3, 0x41400000
+ assert eq, a4, a3
+.data
+ .align 8
+1:
+.double 0, 0, 0
+.text
+test_end
+
+#endif
+
test_suite_end
diff --git a/tests/test-char.c b/tests/test-char.c
index 614bdac2df..d35cc839bc 100644
--- a/tests/test-char.c
+++ b/tests/test-char.c
@@ -1200,7 +1200,7 @@ static void char_serial_test(void)
/* test tty alias */
qemu_opt_set(opts, "backend", "tty", &error_abort);
- chr = qemu_chr_new_from_opts(opts, NULL, NULL);
+ chr = qemu_chr_new_from_opts(opts, NULL, &error_abort);
g_assert_nonnull(chr);
object_unparent(OBJECT(chr));
diff --git a/tests/test-qga.c b/tests/test-qga.c
index d2b2435bb4..4ac4c22109 100644
--- a/tests/test-qga.c
+++ b/tests/test-qga.c
@@ -4,7 +4,7 @@
#include <sys/socket.h>
#include <sys/un.h>
-#include "libqtest.h"
+#include "libqos/libqtest.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qlist.h"
@@ -61,8 +61,8 @@ fixture_setup(TestFixture *fixture, gconstpointer data, gchar **envp)
path = g_build_filename(fixture->test_dir, "sock", NULL);
cwd = g_get_current_dir();
- cmd = g_strdup_printf("%s%cqemu-ga -m unix-listen -t %s -p %s %s %s",
- cwd, G_DIR_SEPARATOR,
+ cmd = g_strdup_printf("%s%cqga%cqemu-ga -m unix-listen -t %s -p %s %s %s",
+ cwd, G_DIR_SEPARATOR, G_DIR_SEPARATOR,
fixture->test_dir, path,
getenv("QTEST_LOG") ? "-v" : "",
extra_arg ?: "");
@@ -699,8 +699,8 @@ static void test_qga_config(gconstpointer data)
GKeyFile *kf;
cwd = g_get_current_dir();
- cmd = g_strdup_printf("%s%cqemu-ga -D",
- cwd, G_DIR_SEPARATOR);
+ cmd = g_strdup_printf("%s%cqga%cqemu-ga -D",
+ cwd, G_DIR_SEPARATOR, G_DIR_SEPARATOR);
g_free(cwd);
g_shell_parse_argv(cmd, NULL, &argv, &error);
g_free(cmd);
diff --git a/tests/test-qgraph.c b/tests/test-qgraph.c
index 5c7e457075..267291c6ed 100644
--- a/tests/test-qgraph.c
+++ b/tests/test-qgraph.c
@@ -17,9 +17,8 @@
*/
#include "qemu/osdep.h"
-#include "libqtest.h"
-#include "libqos/qgraph.h"
-#include "libqos/qgraph_internal.h"
+#include "qtest/libqos/qgraph.h"
+#include "qtest/libqos/qgraph_internal.h"
#define MACHINE_PC "x86_64/pc"
#define MACHINE_RASPI2 "arm/raspi2"
diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c
index 2ca1e99f17..af9f5c0c70 100644
--- a/tests/test-util-sockets.c
+++ b/tests/test-util-sockets.c
@@ -64,7 +64,8 @@ int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp)
return dup(mon_fd);
}
-/* Syms in libqemustub.a are discarded at .o file granularity.
+/*
+ * Syms of stubs in libqemuutil.a are discarded at .o file granularity.
* To replace monitor_get_fd() we must ensure everything in
* stubs/monitor.c is defined, to make sure monitor.o is discarded
* otherwise we get duplicate syms at link time.
@@ -312,6 +313,7 @@ static void test_socket_unix_abstract_good(void)
g_thread_join(serv);
g_free(abstract_sock_name);
+ g_rand_free(r);
}
#endif
diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include
index f21948c46a..61f893ffdc 100644
--- a/tests/vm/Makefile.include
+++ b/tests/vm/Makefile.include
@@ -2,6 +2,8 @@
.PHONY: vm-build-all vm-clean-all
+EFI_AARCH64 = $(wildcard $(BUILD_DIR)/pc-bios/edk2-aarch64-code.fd)
+
IMAGES := freebsd netbsd openbsd centos fedora
ifneq ($(GENISOIMAGE),)
IMAGES += ubuntu.i386 centos
@@ -15,6 +17,10 @@ IMAGE_FILES := $(patsubst %, $(IMAGES_DIR)/%.img, $(IMAGES))
.PRECIOUS: $(IMAGE_FILES)
+ifneq ($(PYTHON),)
+HAVE_PYTHON_YAML = $(shell $(PYTHON) -c "import yaml" 2> /dev/null && echo yes)
+endif
+
# 'vm-help' target was historically named 'vm-test'
vm-help vm-test:
@echo "vm-help: Test QEMU in preconfigured virtual machines"
@@ -54,7 +60,7 @@ endif
@echo " QEMU_LOCAL=1 - Use QEMU binary local to this build."
@echo " QEMU=/path/to/qemu - Change path to QEMU binary"
@echo " QEMU_IMG=/path/to/qemu-img - Change path to qemu-img tool"
-ifeq ($(PYTHON_YAML),yes)
+ifeq ($(HAVE_PYTHON_YAML),yes)
@echo " QEMU_CONFIG=/path/conf.yml - Change path to VM configuration .yml file."
else
@echo " (install python3-yaml to enable support for yaml file to configure a VM.)"
diff --git a/tests/vm/freebsd b/tests/vm/freebsd
index 29252fa4a6..5f866e09c4 100755
--- a/tests/vm/freebsd
+++ b/tests/vm/freebsd
@@ -33,11 +33,13 @@ class FreeBSDVM(basevm.BaseVM):
"pkgconf",
"bzip2",
"python37",
+ "py37-setuptools",
# gnu tools
"bash",
"gmake",
"gsed",
+ "gettext",
# libs: crypto
"gnutls",
diff --git a/tests/vm/netbsd b/tests/vm/netbsd
index 2e87199211..ffb65a89be 100755
--- a/tests/vm/netbsd
+++ b/tests/vm/netbsd
@@ -31,11 +31,13 @@ class NetBSDVM(basevm.BaseVM):
"pkgconf",
"xz",
"python37",
+ "py37-setuptools",
# gnu tools
"bash",
"gmake",
"gsed",
+ "gettext",
# libs: crypto
"gnutls",
diff --git a/tests/vm/openbsd b/tests/vm/openbsd
index dfe633e453..8356646f21 100755
--- a/tests/vm/openbsd
+++ b/tests/vm/openbsd
@@ -30,11 +30,13 @@ class OpenBSDVM(basevm.BaseVM):
"git",
"pkgconf",
"bzip2", "xz",
+ "py3-setuptools",
# gnu tools
"bash",
"gmake",
"gsed",
+ "gettext",
# libs: usb
"libusb1",