SCSI, qdev, qtest, meson patches for 2020-10-10
Subsystems (4)
The following changes since commit 4a7c0bd9dcb08798c6f82e55b5a3423f7ee669f1:
Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-5.2-20201009' into staging (2020-10-09 15:48:04 +0100)
are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to 1340ff2adb2624e61c5fcb0eb1889b932b76f669:
meson: identify more sections of meson.build (2020-10-09 13:19:50 -0400)
----------------------------------------------------------------
* qtest documentation improvements (Eduardo, myself)
* libqtest event buffering (Maxim)
* use RCU for list of children of a bus (Maxim)
* move more files to softmmu/ (myself)
* meson.build cleanups, qemu-storage-daemon fix (Philippe)
----------------------------------------------------------------
Eduardo Habkost (3):
docs: Move QTest documentation to its own document docs/devel/qtest: Include protocol spec in document docs/devel/qtest: Include libqtest API reference
Huacai Chen (1):
meson.build: Re-enable KVM support for MIPS
Marc-André Lureau (1):
build-sys: fix git version from -version
Maxim Levitsky (11):
qtest: rename qtest_qmp_receive to qtest_qmp_receive_dict
qtest: Reintroduce qtest_qmp_receive
qtest: remove qtest_qmp_receive_success
qtest: switch users back to qtest_qmp_receive scsi/scsi_bus: switch search direction in scsi_device_find
device_core: use drain_call_rcu in in qmp_device_add
device-core: use RCU for list of children of a bus
device-core: use atomic_set on .realized property scsi/scsi_bus: Add scsi_device_get
virtio-scsi: use scsi_device_get
scsi/scsi_bus: fix races in REPORT LUNS
Paolo Bonzini (13):
softmmu: move more files to softmmu/
exec: split out non-softmmu-specific parts
qom: fix objects with improper parent type
configure: fix performance regression due to PIC objects
qtest: unify extra_qtest_srcs and extra_qtest_deps docs/devel: update instruction on how to add new unit tests
device-plug-test: use qtest_qmp to send the device_del command
qtest: check that drives are really appearing and disappearing qemu-iotests, qtest: rewrite test 067 as a qtest
qdev: add "check if address free" callback for buses
scsi: switch to bus->check_address
scsi/scsi-bus: scsi_device_find: don't return unrealized devices
meson: identify more sections of meson.build
Philippe Mathieu-Daudé (10):
meson.build: Add comments to clarify code organization meson.build: Sort sourcesets alphabetically
hw/core: Move the creation of the library to the main meson.build
chardev: Move the creation of the library to the main meson.build
migration: Move the creation of the library to the main meson.build
io: Move the creation of the library to the main meson.build
crypto: Move the creation of the library to the main meson.build
authz: Move the creation of the library to the main meson.build
qom: Move the creation of the library to the main meson.build hw/nvram: Always register FW_CFG_DATA_GENERATOR_INTERFACE
.gitlab-ci.yml | 2 +- MAINTAINERS | 16 +- authz/meson.build | 10 - chardev/meson.build | 6 - configure | 1 + cpu.c | 452 ++++++++++++++++++++++++++++++ crypto/meson.build | 10 - docs/devel/index.rst | 1 + docs/devel/qtest.rst | 84 ++++++ docs/devel/testing.rst | 64 +---- hw/core/bus.c | 28 +- hw/core/meson.build | 6 - hw/core/qdev.c | 73 +++-- hw/net/virtio-net.c | 2 +- hw/nvram/fw_cfg-interface.c | 23 ++ hw/nvram/fw_cfg.c | 7 - hw/nvram/meson.build | 3 + hw/scsi/scsi-bus.c | 262 +++++++++++------- hw/scsi/virtio-scsi.c | 27 +- hw/sd/core.c | 3 +- include/exec/cpu-common.h | 3 + include/hw/acpi/vmgenid.h | 2 +- include/hw/misc/vmcoreinfo.h | 2 +- include/hw/qdev-core.h | 24 +- include/hw/scsi/scsi.h | 1 + include/net/can_host.h | 2 +- io/meson.build | 10 - meson.build | 126 +++++++-- migration/meson.build | 8 +- qom/meson.build | 8 - scripts/coccinelle/qom-parent-type.cocci | 26 ++ scripts/qemu-version.sh | 2 +- bootdevice.c => softmmu/bootdevice.c | 0 device_tree.c => softmmu/device_tree.c | 0 dma-helpers.c => softmmu/dma-helpers.c | 0 softmmu/meson.build | 11 + exec.c => softmmu/physmem.c | 454 +------------------------------ qdev-monitor.c => softmmu/qdev-monitor.c | 12 + qemu-seccomp.c => softmmu/qemu-seccomp.c | 0 softmmu/qtest.c | 71 ++++- tpm.c => softmmu/tpm.c | 0 tests/qemu-iotests/067 | 157 ----------- tests/qemu-iotests/067.out | 414 ---------------------------- tests/qemu-iotests/group | 2 +- tests/qtest/device-plug-test.c | 32 +-- tests/qtest/drive_del-test.c | 244 +++++++++++++++-- tests/qtest/libqos/libqtest.h | 54 ++-- tests/qtest/libqtest.c | 110 ++++---- tests/qtest/meson.build | 59 ++-- tests/qtest/migration-helpers.c | 25 +- tests/qtest/pvpanic-test.c | 4 +- tests/qtest/qmp-test.c | 18 +- tests/qtest/tpm-util.c | 8 +- 53 files changed, 1472 insertions(+), 1497 deletions(-) create mode 100644 cpu.c create mode 100644 docs/devel/qtest.rst create mode 100644 hw/nvram/fw_cfg-interface.c create mode 100644 scripts/coccinelle/qom-parent-type.cocci rename bootdevice.c => softmmu/bootdevice.c (100%) rename device_tree.c => softmmu/device_tree.c (100%) rename dma-helpers.c => softmmu/dma-helpers.c (100%) rename exec.c => softmmu/physmem.c (91%) rename qdev-monitor.c => softmmu/qdev-monitor.c (98%) rename qemu-seccomp.c => softmmu/qemu-seccomp.c (100%) rename tpm.c => softmmu/tpm.c (100%) delete mode 100755 tests/qemu-iotests/067 delete mode 100644 tests/qemu-iotests/067.out
Signature · 1 line
2.26.2
[PULL 01/39] meson.build: Add comments to clarify code organization
From: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <[email protected]>
--- meson.build | 8 ++++++++ 1 file changed, 8 insertions(+)
meson.build +8 -0
@@ -1446,6 +1446,10 @@ qemu_syms = custom_target('qemu.syms', output: 'qemu.syms', capture: true, command: [undefsym, nm, '@INPUT@']) +######################## +# Library dependencies # +######################## + block_ss = block_ss.apply(config_host, strict: false) libblock = static_library('block', block_ss.sources() + genh, dependencies: block_ss.dependencies(),
@@ -1465,6 +1469,10 @@ libqmp = static_library('qmp', qmp_ss.sources() + genh, qmp = declare_dependency(link_whole: [libqmp]) +########### +# Targets # +########### + foreach m : block_mods + softmmu_mods shared_module(m.name(), name_prefix: '',
Signature · 1 line
2.26.2
[PULL 04/39] chardev: Move the creation of the library to the main meson.build
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Be consistent creating all the libraries in the main meson.build file.
Message-Id: <[email protected]>
--- chardev/meson.build | 6 ------ meson.build | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-)
chardev/meson.build +0 -6
@@ -1,4 +1,3 @@ -chardev_ss = ss.source_set() chardev_ss.add(files( 'char-fe.c', 'char-file.c',
@@ -25,11 +24,6 @@ chardev_ss.add(when: 'CONFIG_WIN32', if_true: files( )) chardev_ss = chardev_ss.apply(config_host, strict: false) -libchardev = static_library('chardev', chardev_ss.sources() + genh, - name_suffix: 'fa', - build_by_default: false) - -chardev = declare_dependency(link_whole: libchardev) softmmu_ss.add(files('chardev-sysemu.c', 'msmouse.c', 'wctablet.c', 'testdev.c')) softmmu_ss.add(when: ['CONFIG_SPICE', spice], if_true: files('spice.c'))
meson.build +7 -0
@@ -1185,6 +1185,7 @@ sphinx_extn_depends = [ meson.source_root() / 'docs/sphinx/depfile.py', blockdev_ss = ss.source_set() block_ss = ss.source_set() bsd_user_ss = ss.source_set() +chardev_ss = ss.source_set() common_ss = ss.source_set() linux_user_ss = ss.source_set() qmp_ss = ss.source_set()
@@ -1469,6 +1470,12 @@ libqmp = static_library('qmp', qmp_ss.sources() + genh, qmp = declare_dependency(link_whole: [libqmp]) +libchardev = static_library('chardev', chardev_ss.sources() + genh, + name_suffix: 'fa', + build_by_default: false) + +chardev = declare_dependency(link_whole: libchardev) + libhwcore = static_library('hwcore', sources: hwcore_files + genh, name_suffix: 'fa', build_by_default: false)
Signature · 1 line
2.26.2
[PULL 09/39] qom: Move the creation of the library to the main meson.build
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Be consistent creating all the libraries in the main meson.build file.
Message-Id: <[email protected]>
--- meson.build | 8 ++++++++ qom/meson.build | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-)
meson.build +8 -0
@@ -1192,6 +1192,7 @@ crypto_ss = ss.source_set() io_ss = ss.source_set() linux_user_ss = ss.source_set() qmp_ss = ss.source_set() +qom_ss = ss.source_set() softmmu_ss = ss.source_set() specific_fuzz_ss = ss.source_set() specific_ss = ss.source_set()
@@ -1454,6 +1455,13 @@ qemu_syms = custom_target('qemu.syms', output: 'qemu.syms', # Library dependencies # ######################## +qom_ss = qom_ss.apply(config_host, strict: false) +libqom = static_library('qom', qom_ss.sources() + genh, + dependencies: [qom_ss.dependencies()], + name_suffix: 'fa') + +qom = declare_dependency(link_whole: libqom) + authz_ss = authz_ss.apply(config_host, strict: false) libauthz = static_library('authz', authz_ss.sources() + genh, dependencies: [authz_ss.dependencies()],
qom/meson.build +0 -8
@@ -1,4 +1,3 @@ -qom_ss = ss.source_set() qom_ss.add(genh) qom_ss.add(files( 'container.c',
@@ -9,10 +8,3 @@ qom_ss.add(files( qmp_ss.add(files('qom-qmp-cmds.c')) softmmu_ss.add(files('qom-hmp-cmds.c')) - -qom_ss = qom_ss.apply(config_host, strict: false) -libqom = static_library('qom', qom_ss.sources() + genh, - dependencies: [qom_ss.dependencies()], - name_suffix: 'fa') - -qom = declare_dependency(link_whole: libqom)
Signature · 1 line
2.26.2
[PULL 05/39] migration: Move the creation of the library to the main meson.build
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Be consistent creating all the libraries in the main meson.build file.
Message-Id: <[email protected]>
--- meson.build | 7 +++++++ migration/meson.build | 8 +------- 2 files changed, 8 insertions(+), 7 deletions(-)
meson.build +7 -0
@@ -1451,6 +1451,13 @@ qemu_syms = custom_target('qemu.syms', output: 'qemu.syms', # Library dependencies # ######################## +libmigration = static_library('migration', sources: migration_files + genh, + name_suffix: 'fa', + build_by_default: false) +migration = declare_dependency(link_with: libmigration, + dependencies: [zlib, qom, io]) +softmmu_ss.add(migration) + block_ss = block_ss.apply(config_host, strict: false) libblock = static_library('block', block_ss.sources() + genh, dependencies: block_ss.dependencies(),
migration/meson.build +1 -7
@@ -8,13 +8,7 @@ migration_files = files( 'qemu-file.c', 'qjson.c', ) - -libmigration = static_library('migration', sources: migration_files + genh, - name_suffix: 'fa', - build_by_default: false) -migration = declare_dependency(link_with: libmigration, - dependencies: [zlib, qom, io]) -softmmu_ss.add(migration) +softmmu_ss.add(migration_files) softmmu_ss.add(files( 'block-dirty-bitmap.c',
Signature · 1 line
2.26.2
[PULL 02/39] meson.build: Sort sourcesets alphabetically
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <[email protected]>
--- meson.build | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
meson.build +9 -9
@@ -1182,19 +1182,19 @@ sphinx_extn_depends = [ meson.source_root() / 'docs/sphinx/depfile.py', # Collect sourcesets. -util_ss = ss.source_set() -stub_ss = ss.source_set() -trace_ss = ss.source_set() -block_ss = ss.source_set() blockdev_ss = ss.source_set() -qmp_ss = ss.source_set() -common_ss = ss.source_set() -softmmu_ss = ss.source_set() -user_ss = ss.source_set() +block_ss = ss.source_set() bsd_user_ss = ss.source_set() +common_ss = ss.source_set() linux_user_ss = ss.source_set() -specific_ss = ss.source_set() +qmp_ss = ss.source_set() +softmmu_ss = ss.source_set() specific_fuzz_ss = ss.source_set() +specific_ss = ss.source_set() +stub_ss = ss.source_set() +trace_ss = ss.source_set() +user_ss = ss.source_set() +util_ss = ss.source_set() modules = {} hw_arch = {}
Signature · 1 line
2.26.2
[PULL 16/39] docs/devel/qtest: Include protocol spec in document
In reply to Paolo BonziniFrom: Eduardo Habkost <[email protected]>
Include the QTest Protocol doc string in docs/devel/qtest.rst, after converting it to use Sphinx syntax.
Message-Id: <[email protected]>
--- docs/devel/qtest.rst | 12 ++++++-- softmmu/qtest.c | 71 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 73 insertions(+), 10 deletions(-)
docs/devel/qtest.rst +10 -2
@@ -4,8 +4,8 @@ QTest Device Emulation Testing Framework QTest is a device emulation testing framework. It can be very useful to test device models; it could also control certain aspects of QEMU (such as virtual -clock stepping), with a special purpose "qtest" protocol. Refer to the -documentation in ``qtest.c`` for more details of the protocol. +clock stepping), with a special purpose "qtest" protocol. Refer to +:ref:`qtest-protocol` for more details of the protocol. QTest cases can be executed with
@@ -56,3 +56,11 @@ from the output of which you can run manually. + +.. _qtest-protocol: + +QTest Protocol +-------------- + +.. kernel-doc:: softmmu/qtest.c + :doc: QTest Protocol
softmmu/qtest.c +63 -8
183 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 18/39] qtest: unify extra_qtest_srcs and extra_qtest_deps
In reply to Paolo BonziniCurrently the extra sources and extra dependencies of qtests are held in two separate dictionaries. Use the same trick as tests/meson.build to combine them into one. This will make it easier to update the documentation for unit tests and qtests.
--- tests/qtest/meson.build | 55 +++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 29 deletions(-)
tests/qtest/meson.build +26 -29
@@ -193,35 +193,25 @@ qos_test_ss.add( 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'), +tpmemu_files = ['tpm-emu.c', 'tpm-util.c', 'tpm-tests.c'] + +qtests = { + 'bios-tables-test': [io, 'boot-sector.c', 'acpi-utils.c', 'tpm-emu.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, + 'ivshmem-test': [rt, '../../contrib/ivshmem-server/ivshmem-server.c'], + 'migration-test': files('migration-helpers.c'), + 'pxe-test': files('boot-sector.c'), + 'qos-test': [chardev, io, qos_test_ss.apply(config_host, strict: false).sources()], + 'tpm-crb-swtpm-test': [io, tpmemu_files], + 'tpm-crb-test': [io, tpmemu_files], + 'tpm-tis-swtpm-test': [io, tpmemu_files, 'tpm-tis-util.c'], + 'tpm-tis-test': [io, tpmemu_files, 'tpm-tis-util.c'], + 'tpm-tis-device-swtpm-test': [io, tpmemu_files, 'tpm-tis-util.c'], + 'tpm-tis-device-test': [io, tpmemu_files, 'tpm-tis-util.c'], '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')
@@ -230,7 +220,7 @@ foreach dir : target_dirs target_base = dir.split('-')[0] qtest_emulator = emulators['qemu-system-' + target_base] - qtests = get_variable('qtests_' + target_base, []) + qtests_generic + target_qtests = get_variable('qtests_' + target_base, []) + qtests_generic test_deps = [] qtest_env = environment()
@@ -241,14 +231,21 @@ foreach dir : target_dirs 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 + foreach test : target_qtests # Executables are shared across targets, declare them only the first time we # encounter them if not qtest_executables.has_key(test) + src = [test + '.c'] + deps = [qemuutil, qos] + if test in qtests + # use a sourceset to quickly separate sources and deps + test_ss = ss.source_set() + test_ss.add(qtests[test]) + src += test_ss.all_sources() + deps += test_ss.all_dependencies() + endif qtest_executables += { - test: executable(test, - files(test + '.c') + extra_qtest_srcs.get(test, []), - dependencies: [qemuutil, qos] + extra_qtest_deps.get(test, [])) + test: executable(test, src, dependencies: deps) } endif # FIXME: missing dependency on the emulator binary and qemu-img
Signature · 1 line
2.26.2
[PULL 03/39] hw/core: Move the creation of the library to the main meson.build
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Be consistent creating all the libraries in the main meson.build file.
Message-Id: <[email protected]>
--- hw/core/meson.build | 6 ------ meson.build | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-)
hw/core/meson.build +0 -6
@@ -14,12 +14,6 @@ hwcore_files = files( 'qdev-clock.c', ) -libhwcore = static_library('hwcore', sources: hwcore_files + genh, - name_suffix: 'fa', - build_by_default: false) -hwcore = declare_dependency(link_whole: libhwcore) -common_ss.add(hwcore) - common_ss.add(files('cpu.c')) common_ss.add(when: 'CONFIG_FITLOADER', if_true: files('loader-fit.c')) common_ss.add(when: 'CONFIG_GENERIC_LOADER', if_true: files('generic-loader.c'))
meson.build +6 -0
@@ -1469,6 +1469,12 @@ libqmp = static_library('qmp', qmp_ss.sources() + genh, qmp = declare_dependency(link_whole: [libqmp]) +libhwcore = static_library('hwcore', sources: hwcore_files + genh, + name_suffix: 'fa', + build_by_default: false) +hwcore = declare_dependency(link_whole: libhwcore) +common_ss.add(hwcore) + ########### # Targets # ###########
Signature · 1 line
2.26.2
[PULL 15/39] docs: Move QTest documentation to its own document
In reply to Paolo BonziniFrom: Eduardo Habkost <[email protected]>
The qtest and libqtest doc comments will be parsed to generate API documentation, so move QTest documentation to its own document where the API and format documentation and will be included.
Message-Id: <[email protected]>
--- docs/devel/index.rst | 1 + docs/devel/qtest.rst | 58 ++++++++++++++++++++++++++++++++++++++++++ docs/devel/testing.rst | 47 ++-------------------------------- 3 files changed, 61 insertions(+), 45 deletions(-) create mode 100644 docs/devel/qtest.rst
docs/devel/index.rst +1 -0
@@ -21,6 +21,7 @@ Contents: atomics stable-process testing + qtest decodetree secure-coding-practices tcg
docs/devel/qtest.rst new file +58 -0
58 lines not on this page · raw message
docs/devel/testing.rst +2 -45
59 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 19/39] docs/devel: update instruction on how to add new unit tests
In reply to Paolo Bonzini--- docs/devel/qtest.rst | 30 +++++++++++++++++++++--------- docs/devel/testing.rst | 19 ++++++++++--------- 2 files changed, 31 insertions(+), 18 deletions(-)
docs/devel/qtest.rst +21 -9
@@ -33,15 +33,27 @@ Steps to add a new QTest case are: 2. Write the test code with the glib and libqtest/libqos API. See also existing tests and the library headers for reference. -3. Register the new test in ``tests/qtest/Makefile.include``. Add the test - executable name to an appropriate ``check-qtest-*-y`` variable. For example: - - ``check-qtest-generic-y = tests/qtest/foo-test$(EXESUF)`` - -4. Add object dependencies of the executable in the Makefile, including the - test source file(s) and other interesting objects. For example: - - ``tests/qtest/foo-test$(EXESUF): tests/qtest/foo-test.o $(libqos-obj-y)`` +3. Register the new test in ``tests/qtest/meson.build``. Add the test + executable name to an appropriate ``qtests_*`` variable. There is + one variable per architecture, plus ``qtests_generic`` for tests + that can be run for all architectures. For example:: + + qtests_generic = [ + ... + 'foo-test', + ... + ] + +4. If the test has more than one source file or needs to be linked with any + dependency other than ``qemuutil`` and ``qos``, list them in the ``qtests`` + dictionary. For example a test that needs to use the ``QIO`` library + will have an entry like:: + + { + ... + 'foo-test': [io], + ... + } Debugging a QTest failure is slightly harder than the unit test because the tests look up QEMU program names in the environment variables, such as
docs/devel/testing.rst +10 -9
@@ -41,15 +41,16 @@ add a new unit test: test. The test code should be organized with the glib testing framework. Copying and modifying an existing test is usually a good idea. -3. Add the test to ``tests/Makefile.include``. First, name the unit test - program and add it to ``$(check-unit-y)``; then add a rule to build the - executable. For example: - -.. code:: - - check-unit-y += tests/foo-test$(EXESUF) - tests/foo-test$(EXESUF): tests/foo-test.o $(test-util-obj-y) - ... +3. Add the test to ``tests/meson.build``. The unit tests are listed in a + dictionary called ``tests``. The values are any additional sources and + dependencies to be linked with the test. For a simple test whose source + is in ``tests/foo-test.c``, it is enough to add an entry like:: + + { + ... + 'foo-test': [], + ... + } Since unit tests don't require environment variables, the simplest way to debug a unit test failure is often directly invoking it or even running it under
Signature · 1 line
2.26.2
[PULL 23/39] qtest: Reintroduce qtest_qmp_receive
In reply to Paolo BonziniFrom: Maxim Levitsky <[email protected]>
The new qtest_qmp_receive buffers all the received qmp events, allowing qtest_qmp_eventwait_ref to return them.
This is intended to solve the race in regard to ordering of qmp events vs qmp responses, as soon as the callers start using the new interface.
In addition to that, define qtest_qmp_event_ref a function which only scans the buffer that qtest_qmp_receive stores the events to.
This is intended for callers that are only interested in events that were received during the last call to the qtest_qmp_receive.
Message-Id: <[email protected]>
--- tests/qtest/libqos/libqtest.h | 23 ++++++++++++++++ tests/qtest/libqtest.c | 49 ++++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 1 deletion(-)
tests/qtest/libqos/libqtest.h +23 -0
@@ -198,6 +198,16 @@ void qtest_qmp_vsend(QTestState *s, const char *fmt, va_list ap)*/ QDict *qtest_qmp_receive_dict (QTestState *s); +/** +* qtest_qmp_receive: +* @s: #QTestState instance to operate on. +* +* Reads a QMP message from QEMU and returns the response. +* Buffers all the events received meanwhile, until a +* call to qtest_qmp_eventwait +*/ +QDict *qtest_qmp_receive (QTestState *s); +/** * qtest_qmp_eventwait: * @s: #QTestState instance to operate on.
@@ -217,6 +227,19 @@ void qtest_qmp_eventwait(QTestState *s, const char *event);*/ QDict *qtest_qmp_eventwait_ref (QTestState *s,const char *event); +/** +* qtest_qmp_event_ref: +* @s: #QTestState instance to operate on. +* @s: #event event to return. +* +* Removes non-matching events from the buffer that was set by +* qtest_qmp_receive, until an event bearing the given name is found, +* and returns it. +* If no event matches, clears the buffer and returns NULL. +* +*/ +QDict *qtest_qmp_event_ref (QTestState *s,const char *event); +/** * qtest_qmp_receive_success: * @s: #QTestState instance to operate on
tests/qtest/libqtest.c +48 -1
88 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 06/39] io: Move the creation of the library to the main meson.build
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Be consistent creating all the libraries in the main meson.build file.
Message-Id: <[email protected]>
--- io/meson.build | 10 ---------- meson.build | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-)
io/meson.build +0 -10
@@ -1,4 +1,3 @@ -io_ss = ss.source_set() io_ss.add(genh) io_ss.add(files( 'channel-buffer.c',
@@ -14,12 +13,3 @@ io_ss.add(files( 'net-listener.c', 'task.c', )) - -io_ss = io_ss.apply(config_host, strict: false) -libio = static_library('io', io_ss.sources() + genh, - dependencies: [io_ss.dependencies()], - link_with: libqemuutil, - name_suffix: 'fa', - build_by_default: false) - -io = declare_dependency(link_whole: libio, dependencies: [crypto, qom])
meson.build +10 -0
@@ -1187,6 +1187,7 @@ block_ss = ss.source_set() bsd_user_ss = ss.source_set() chardev_ss = ss.source_set() common_ss = ss.source_set() +io_ss = ss.source_set() linux_user_ss = ss.source_set() qmp_ss = ss.source_set() softmmu_ss = ss.source_set()
@@ -1451,6 +1452,15 @@ qemu_syms = custom_target('qemu.syms', output: 'qemu.syms', # Library dependencies # ######################## +io_ss = io_ss.apply(config_host, strict: false) +libio = static_library('io', io_ss.sources() + genh, + dependencies: [io_ss.dependencies()], + link_with: libqemuutil, + name_suffix: 'fa', + build_by_default: false) + +io = declare_dependency(link_whole: libio, dependencies: [crypto, qom]) + libmigration = static_library('migration', sources: migration_files + genh, name_suffix: 'fa', build_by_default: false)
Signature · 1 line
2.26.2
[PULL 11/39] softmmu: move more files to softmmu/
In reply to Paolo BonziniKeep most softmmu_ss files into the system-emulation-specific directory.
--- MAINTAINERS | 9 +++++---- meson.build | 10 ---------- bootdevice.c => softmmu/bootdevice.c | 0 device_tree.c => softmmu/device_tree.c | 0 dma-helpers.c => softmmu/dma-helpers.c | 0 softmmu/meson.build | 10 ++++++++++ qdev-monitor.c => softmmu/qdev-monitor.c | 0 qemu-seccomp.c => softmmu/qemu-seccomp.c | 0 tpm.c => softmmu/tpm.c | 0 9 files changed, 15 insertions(+), 14 deletions(-) rename bootdevice.c => softmmu/bootdevice.c (100%) rename device_tree.c => softmmu/device_tree.c (100%) rename dma-helpers.c => softmmu/dma-helpers.c (100%) rename qdev-monitor.c => softmmu/qdev-monitor.c (100%) rename qemu-seccomp.c => softmmu/qemu-seccomp.c (100%) rename tpm.c => softmmu/tpm.c (100%)
MAINTAINERS +5 -4
@@ -2235,7 +2235,7 @@ Device Tree M: Alistair Francis <[email protected]> R: David Gibson <[email protected]> S: Maintained -F: device_tree.c +F: softmmu/device_tree.c F: include/sysemu/device_tree.h Dump
@@ -2281,6 +2281,7 @@ F: include/exec/memop.h F: include/exec/memory.h F: include/exec/ram_addr.h F: include/exec/ramblock.h +F: softmmu/dma-helpers.c F: softmmu/ioport.c F: softmmu/memory.c F: include/exec/memory-internal.h
@@ -2461,7 +2462,7 @@ F: include/monitor/qdev.h F: include/qom/ F: qapi/qom.json F: qapi/qdev.json -F: qdev-monitor.c +F: softmmu/qdev-monitor.c F: qom/ F: tests/check-qom-interface.c F: tests/check-qom-proplist.c
@@ -2591,7 +2592,7 @@ F: docs/interop/dbus-vmstate.rst Seccomp M: Eduardo Otubo <[email protected]> S: Supported -F: qemu-seccomp.c +F: softmmu/qemu-seccomp.c F: include/sysemu/seccomp.h Cryptography
@@ -2957,7 +2958,7 @@ T: git https://github.com/stefanha/qemu.git block Bootdevice M: Gonglei <[email protected]> S: Maintained -F: bootdevice.c +F: softmmu/bootdevice.c Quorum M: Alberto Garcia <[email protected]>
meson.build +0 -10
@@ -1365,17 +1365,7 @@ blockdev_ss.add(files( # os-win32.c does not blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c')) softmmu_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')]) - softmmu_ss.add_all(blockdev_ss) -softmmu_ss.add(files( - 'bootdevice.c', - 'dma-helpers.c', - 'qdev-monitor.c', -), sdl) - -softmmu_ss.add(when: 'CONFIG_TPM', if_true: files('tpm.c')) -softmmu_ss.add(when: 'CONFIG_SECCOMP', if_true: [files('qemu-seccomp.c'), seccomp]) -softmmu_ss.add(when: fdt, if_true: files('device_tree.c')) common_ss.add(files('cpus-common.c'))
softmmu/bootdevice.c renamed from bootdevice.c +0 -0
softmmu/device_tree.c renamed from device_tree.c +0 -0
softmmu/dma-helpers.c renamed from dma-helpers.c +0 -0
softmmu/meson.build +10 -0
@@ -14,3 +14,13 @@ specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files( specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: [files( 'icount.c' )]) + +softmmu_ss.add(files( + 'bootdevice.c', + 'dma-helpers.c', + 'qdev-monitor.c', +), sdl) + +softmmu_ss.add(when: 'CONFIG_TPM', if_true: files('tpm.c')) +softmmu_ss.add(when: 'CONFIG_SECCOMP', if_true: [files('qemu-seccomp.c'), seccomp]) +softmmu_ss.add(when: fdt, if_true: files('device_tree.c'))
softmmu/qdev-monitor.c renamed from qdev-monitor.c +0 -0
softmmu/qemu-seccomp.c renamed from qemu-seccomp.c +0 -0
softmmu/tpm.c renamed from tpm.c +0 -0
Signature · 1 line
2.26.2
[PULL 14/39] configure: fix performance regression due to PIC objects
In reply to Paolo BonziniBecause most files in QEMU are grouped into static libraries, Meson conservatively compiles them with -fPIC. This is overkill and produces slowdowns up to 20% on some TCG tests.
As a stopgap measure, use the b_staticpic option to limit the slowdown to --enable-pie. https://github.com/mesonbuild/meson/pull/7760 will allow us to use b_staticpic=false and let Meson do the right thing.
Message-Id: <[email protected]>
--- configure | 1 + 1 file changed, 1 insertion(+)
configure +1 -0
@@ -7209,6 +7209,7 @@ NINJA=${ninja:-$PWD/ninjatool} $meson setup \ -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \ -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \ -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \ + -Db_staticpic=$(if test "$pie" = yes; then echo true; else echo false; fi) \ -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \ -Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \ -Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf \
Signature · 1 line
2.26.2
[PULL 29/39] qdev: add "check if address free" callback for buses
In reply to Paolo BonziniCheck if an address is free on the bus before plugging in the device. This makes it possible to do the check without any side effects, and to detect the problem early without having to do it in the realize callback.
Message-Id: <[email protected]>
--- hw/core/qdev.c | 17 +++++++++++++++-- hw/net/virtio-net.c | 2 +- hw/sd/core.c | 3 ++- include/hw/qdev-core.h | 13 ++++++++++++- 4 files changed, 30 insertions(+), 5 deletions(-)
hw/core/qdev.c +15 -2
@@ -94,13 +94,23 @@ static void bus_add_child(BusState *bus, DeviceState *child) 0); } -void qdev_set_parent_bus (DeviceState *dev,BusState *bus) +static bool bus_check_address (BusState *bus,DeviceState *child,Error **errp) +{ +BusClass *bc =BUS_GET_CLASS (bus); +return !bc->check_address || bc->check_address (bus, child, errp); +} + +bool qdev_set_parent_bus (DeviceState *dev,BusState *bus,Error **errp) {BusState *old_parent_bus = dev->parent_bus;DeviceClass *dc =DEVICE_GET_CLASS (dev);assert (dc->bus_type &&object_dynamic_cast (OBJECT (bus), dc->bus_type)); +if (!bus_check_address (bus, dev, errp)) { +return false; + } +if (old_parent_bus) { trace_qdev_update_parent_bus(dev, object_get_typename(OBJECT(dev)), old_parent_bus, object_get_typename(OBJECT(old_parent_bus)),
@@ -126,6 +136,7 @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus)object_unref (OBJECT (old_parent_bus));object_unref (OBJECT (dev)); } +return true; }DeviceState *qdev_new (const char *name)
@@ -371,7 +382,9 @@ bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp)assert (!dev->realized && !dev->parent_bus);if (bus) { -qdev_set_parent_bus (dev, bus); +if (!qdev_set_parent_bus (dev, bus, errp)) { +return false; + } }else {assert (!DEVICE_GET_CLASS (dev)->bus_type); }
hw/net/virtio-net.c +1 -1
@@ -3138,7 +3138,7 @@ static bool failover_replug_primary(VirtIONet *n, Error **errp)error_setg (errp,"virtio_net: couldn't find primary bus" );return false; } -qdev_set_parent_bus (n->primary_dev, n->primary_bus); +qdev_set_parent_bus (n->primary_dev, n->primary_bus, &error_abort); n->primary_should_be_hidden = false;if (!qemu_opt_set_bool (n->primary_device_opts,"partially_hotplugged" , true, errp)) {
hw/sd/core.c +2 -1
@@ -23,6 +23,7 @@#include "hw/qdev-core.h" #include "hw/sd/sd.h" #include "qemu/module.h" +#include "qapi/error.h" #include "trace.h" static inline const char *sdbus_name (SDBus *sdbus)
@@ -240,7 +241,7 @@ void sdbus_reparent_card(SDBus *from, SDBus *to) readonly = sc->get_readonly (card);sdbus_set_inserted (from, false); -qdev_set_parent_bus (DEVICE (card), &to->qbus); +qdev_set_parent_bus (DEVICE (card), &to->qbus, &error_abort);sdbus_set_inserted (to, true);sdbus_set_readonly (to, readonly); }
include/hw/qdev-core.h +12 -1
@@ -210,13 +210,24 @@ struct BusClass {/* FIXME first arg should be BusState */ void (*print_dev)(Monitor *mon,DeviceState *dev,int indent);char *(*get_dev_path)(DeviceState *dev); +/* * This callback is used to create Open Firmware device path in accordance * with OF spec http://forthworks.com/standards/of1275.pdf. Individual bus * bindings can be found at http://playground.sun.com/1275/bindings/. */ char *(*get_fw_dev_path)(DeviceState *dev); +void (*reset)(BusState *bus); + +/* +* Return whether the device can be added to @bus, +* based on the address that was set (via device properties) +* before realize. If not, on return @errp contains the +* human-readable error message. +*/ +bool (*check_address)(BusState *bus,DeviceState *dev,Error **errp); +BusRealize realize;BusUnrealize unrealize;
@@ -788,7 +799,7 @@ const char *qdev_fw_name(DeviceState *dev);Object *qdev_get_machine (void );/* FIXME: make this a link<> */ -void qdev_set_parent_bus (DeviceState *dev,BusState *bus); +bool qdev_set_parent_bus (DeviceState *dev,BusState *bus,Error **errp);extern bool qdev_hotplug;extern bool qdev_hot_removed;
Signature · 1 line
2.26.2
[PULL 07/39] crypto: Move the creation of the library to the main meson.build
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Be consistent creating all the libraries in the main meson.build file.
Message-Id: <[email protected]>
--- crypto/meson.build | 10 ---------- meson.build | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-)
crypto/meson.build +0 -10
@@ -1,4 +1,3 @@ -crypto_ss = ss.source_set() crypto_ss.add(genh) crypto_ss.add(files( 'afsplit.c',
@@ -52,15 +51,6 @@ if 'CONFIG_GNUTLS' in config_host endif -crypto_ss = crypto_ss.apply(config_host, strict: false) -libcrypto = static_library('crypto', crypto_ss.sources() + genh, - dependencies: [crypto_ss.dependencies()], - name_suffix: 'fa', - build_by_default: false) - -crypto = declare_dependency(link_whole: libcrypto, - dependencies: [authz, qom]) - util_ss.add(files('aes.c')) util_ss.add(files('init.c'))
meson.build +10 -0
@@ -1187,6 +1187,7 @@ block_ss = ss.source_set() bsd_user_ss = ss.source_set() chardev_ss = ss.source_set() common_ss = ss.source_set() +crypto_ss = ss.source_set() io_ss = ss.source_set() linux_user_ss = ss.source_set() qmp_ss = ss.source_set()
@@ -1452,6 +1453,15 @@ qemu_syms = custom_target('qemu.syms', output: 'qemu.syms', # Library dependencies # ######################## +crypto_ss = crypto_ss.apply(config_host, strict: false) +libcrypto = static_library('crypto', crypto_ss.sources() + genh, + dependencies: [crypto_ss.dependencies()], + name_suffix: 'fa', + build_by_default: false) + +crypto = declare_dependency(link_whole: libcrypto, + dependencies: [authz, qom]) + io_ss = io_ss.apply(config_host, strict: false) libio = static_library('io', io_ss.sources() + genh, dependencies: [io_ss.dependencies()],
Signature · 1 line
2.26.2
[PULL 13/39] qom: fix objects with improper parent type
In reply to Paolo BonziniSome objects accidentally inherit ObjectClass instead of Object. They compile silently but may crash after downcasting.
In this patch, we introduce a coccinelle script to find broken declarations and fix them manually with proper base type.
--- MAINTAINERS | 1 + include/hw/acpi/vmgenid.h | 2 +- include/hw/misc/vmcoreinfo.h | 2 +- include/net/can_host.h | 2 +- scripts/coccinelle/qom-parent-type.cocci | 26 ++++++++++++++++++++++++ 5 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 scripts/coccinelle/qom-parent-type.cocci
MAINTAINERS +1 -0
@@ -2462,6 +2462,7 @@ F: include/monitor/qdev.h F: include/qom/ F: qapi/qom.json F: qapi/qdev.json +F: scripts/coccinelle/qom-parent-type.cocci F: softmmu/qdev-monitor.c F: qom/ F: tests/check-qom-interface.c
include/hw/acpi/vmgenid.h +1 -1
@@ -19,7 +19,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(VmGenIdState, VMGENID)struct VmGenIdState { -DeviceClass parent_obj; +DeviceState parent_obj;QemuUUID guid;/* The 128-bit GUID seen by the guest */ uint8_t vmgenid_addr_le[8 ];/* Address of the GUID (little-endian) */ };
include/hw/misc/vmcoreinfo.h +1 -1
@@ -24,7 +24,7 @@ DECLARE_INSTANCE_CHECKER(VMCoreInfoState, VMCOREINFO,typedef struct fw_cfg_vmcoreinfo FWCfgVMCoreInfo ;struct VMCoreInfoState { -DeviceClass parent_obj; +DeviceState parent_obj;bool has_vmcoreinfo;FWCfgVMCoreInfo vmcoreinfo;
include/net/can_host.h +1 -1
@@ -35,7 +35,7 @@ OBJECT_DECLARE_TYPE(CanHostState, CanHostClass, CAN_HOST)struct CanHostState { -ObjectClass oc; +Object oc;CanBusState *bus;CanBusClientState bus_client;
scripts/coccinelle/qom-parent-type.cocci new file +26 -0
@@ -0,0 +1,26 @@ +// Highlight object declarations that don't look like object class but +// accidentally inherit from it. + +@match@ +identifier obj_t, fld; +type parent_t =~ ".*Class$"; +@@ +struct obj_t { + parent_t fld; + ... +}; + +@script:python filter depends on match@ +obj_t << match.obj_t; +@@ +is_class_obj = obj_t.endswith('Class') +cocci.include_match(not is_class_obj) + +@replacement depends on filter@ +identifier match.obj_t, match.fld; +type match.parent_t; +@@ +struct obj_t { +* parent_t fld; + ... +};
Signature · 1 line
2.26.2
[PULL 20/39] build-sys: fix git version from -version
In reply to Paolo BonziniFrom: Marc-André Lureau <[email protected]>
Typo introduced with the script.
Message-Id: <[email protected]>
--- scripts/qemu-version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/qemu-version.sh +1 -1
@@ -9,7 +9,7 @@ version="$3" if [ -z "$pkgversion" ]; then cd "$dir" if [ -e .git ]; then - pkgversion=$(git describe --match 'v*' --dirty | echo "") + pkgversion=$(git describe --match 'v*' --dirty) || : fi fi
Signature · 1 line
2.26.2
[PULL 39/39] meson: identify more sections of meson.build
In reply to Paolo BonziniAdd more headers that clarify code organization.
--- meson.build | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-)
meson.build +25 -11
@@ -614,7 +614,9 @@ if not has_malloc_trim and get_option('malloc_trim').enabled() endif endif -# Create config-host.h +################# +# config-host.h # +################# config_host_data.set('CONFIG_COCOA', cocoa.found()) config_host_data.set('CONFIG_LIBUDEV', libudev.found())
@@ -660,6 +662,10 @@ foreach k, v: config_host endif endforeach +######################## +# Target configuration # +######################## + minikconf = find_program('scripts/minikconf.py') config_all = {} config_all_devices = {}
@@ -866,7 +872,9 @@ config_all += { 'CONFIG_ALL': true, } -# Submodules +############## +# Submodules # +############## capstone = not_found capstone_opt = get_option('capstone')
@@ -1105,9 +1113,11 @@ config_host_data.set('CONFIG_CAPSTONE', capstone.found()) config_host_data.set('CONFIG_FDT', fdt.found()) config_host_data.set('CONFIG_SLIRP', slirp.found()) -genh += configure_file(output: 'config-host.h', configuration: config_host_data) +##################### +# Generated sources # +##################### -# Generators +genh += configure_file(output: 'config-host.h', configuration: config_host_data) hxtool = find_program('scripts/hxtool') shaderinclude = find_program('scripts/shaderinclude.pl')
@@ -1182,7 +1192,9 @@ sphinx_extn_depends = [ meson.source_root() / 'docs/sphinx/depfile.py', meson.source_root() / 'docs/sphinx/qmp_lexer.py', qapi_gen_depends ] -# Collect sourcesets. +################### +# Collect sources # +################### authz_ss = ss.source_set() blockdev_ss = ss.source_set()
@@ -1320,8 +1332,6 @@ if enable_modules modulecommon = declare_dependency(link_whole: libmodulecommon, compile_args: '-DBUILD_DSO') endif -# Build targets from sourcesets - stub_ss = stub_ss.apply(config_all, strict: false) util_ss.add_all(trace_ss)
@@ -1409,6 +1419,10 @@ specific_ss.add_all(when: 'CONFIG_LINUX_USER', if_true: linux_user_ss) subdir('tests/qtest/libqos') subdir('tests/qtest/fuzz') +######################## +# Library dependencies # +######################## + block_mods = [] softmmu_mods = [] foreach d, list : modules
@@ -1443,10 +1457,6 @@ qemu_syms = custom_target('qemu.syms', output: 'qemu.syms', capture: true, command: [undefsym, nm, '@INPUT@']) -######################## -# Library dependencies # -######################## - qom_ss = qom_ss.apply(config_host, strict: false) libqom = static_library('qom', qom_ss.sources() + genh, dependencies: [qom_ss.dependencies()],
@@ -1797,6 +1807,10 @@ if host_machine.system() == 'windows' alias_target('installer', nsis) endif +######################### +# Configuration summary # +######################### + summary_info = {} summary_info += {'Install prefix': config_host['prefix']} summary_info += {'BIOS directory': config_host['qemu_datadir']}
Signature · 1 line
2.26.2
[PULL 10/39] hw/nvram: Always register FW_CFG_DATA_GENERATOR_INTERFACE
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
While the FW_CFG_DATA_GENERATOR_INTERFACE is only consumed by a device only available using system-mode (fw_cfg), it is implemented by a crypto component (tls-cipher-suites) which is always available when crypto is used.
Commit 69699f3055 introduced the following error in the qemu-storage-daemon binary:
$ echo -e \
'{"execute": "qmp_capabilities"}\r\n{"execute": "qom-list-types"}\r\n{"execute": "quit"}\r\n' \
| storage-daemon/qemu-storage-daemon --chardev stdio,id=qmp0 --monitor qmp0
{"QMP": {"version": {"qemu": {"micro": 50, "minor": 1, "major": 5}, "package": ""}, "capabilities": ["oob"]}}
{"return": {}}
missing interface 'fw_cfg-data-generator' for object 'tls-creds'
Aborted (core dumped)Since QOM dependencies are resolved at runtime, this issue could not be triggered at linktime, and we don't have test running the qemu-storage-daemon binary.
Fix by always registering the QOM interface.
Message-Id: <[email protected]>
--- MAINTAINERS | 2 +- hw/nvram/fw_cfg-interface.c | 23 +++++++++++++++++++++++ hw/nvram/fw_cfg.c | 7 ------- hw/nvram/meson.build | 3 +++ 4 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 hw/nvram/fw_cfg-interface.c
MAINTAINERS +1 -1
@@ -2055,7 +2055,7 @@ R: Laszlo Ersek <[email protected]> R: Gerd Hoffmann <[email protected]> S: Supported F: docs/specs/fw_cfg.txt -F: hw/nvram/fw_cfg.c +F: hw/nvram/fw_cfg*.c F: stubs/fw_cfg.c F: include/hw/nvram/fw_cfg.h F: include/standard-headers/linux/qemu_fw_cfg.h
hw/nvram/fw_cfg-interface.c new file +23 -0
@@ -0,0 +1,23 @@ +/* +* QEMU Firmware configuration device emulation (QOM interfaces) +* +* Copyright 2020 Red Hat, Inc. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "hw/nvram/fw_cfg.h" + +static const TypeInfo fw_cfg_data_generator_interface_info = { + .parent =TYPE_INTERFACE , + .name =TYPE_FW_CFG_DATA_GENERATOR_INTERFACE , + .class_size =sizeof (FWCfgDataGeneratorClass), +}; + +static void fw_cfg_register_interfaces (void ) +{ +type_register_static (&fw_cfg_data_generator_interface_info); +} + +type_init (fw_cfg_register_interfaces)
hw/nvram/fw_cfg.c +0 -7
@@ -1360,18 +1360,11 @@ static const TypeInfo fw_cfg_mem_info = { .class_init = fw_cfg_mem_class_init, }; -static const TypeInfo fw_cfg_data_generator_interface_info = { - .parent =TYPE_INTERFACE , - .name =TYPE_FW_CFG_DATA_GENERATOR_INTERFACE , - .class_size =sizeof (FWCfgDataGeneratorClass), -}; -static void fw_cfg_register_types (void ) {type_register_static (&fw_cfg_info);type_register_static (&fw_cfg_io_info);type_register_static (&fw_cfg_mem_info); -type_register_static (&fw_cfg_data_generator_interface_info); }type_init (fw_cfg_register_types)
hw/nvram/meson.build +3 -0
@@ -1,3 +1,6 @@ +# QOM interfaces must be available anytime QOM is used. +qom_ss.add(files('fw_cfg-interface.c')) + softmmu_ss.add(files('fw_cfg.c')) softmmu_ss.add(when: 'CONFIG_CHRP_NVRAM', if_true: files('chrp_nvram.c')) softmmu_ss.add(when: 'CONFIG_DS1225Y', if_true: files('ds1225y.c'))
Signature · 1 line
2.26.2
[PULL 17/39] docs/devel/qtest: Include libqtest API reference
In reply to Paolo BonziniFrom: Eduardo Habkost <[email protected]>
Message-Id: <[email protected]>
--- docs/devel/qtest.rst | 6 ++++++ tests/qtest/libqos/libqtest.h | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-)
docs/devel/qtest.rst +6 -0
@@ -64,3 +64,9 @@ QTest Protocol .. kernel-doc:: softmmu/qtest.c :doc: QTest Protocol + + +libqtest API reference +---------------------- + +.. kernel-doc:: tests/qtest/libqos/libqtest.h
tests/qtest/libqos/libqtest.h +10 -10
@@ -24,7 +24,7 @@ typedef struct QTestState QTestState;/** * qtest_initf: -* @fmt...: Format for creating other arguments to pass to QEMU, formatted +* @fmt: Format for creating other arguments to pass to QEMU, formatted * like sprintf(). * * Convenience wrapper around qtest_init().
@@ -87,7 +87,7 @@ void qtest_quit(QTestState *s);* @s: #QTestState instance to operate on. * @fds: array of file descriptors * @fds_num: number of elements in @fds -* @fmt...: QMP message to send to qemu, formatted like +* @fmt: QMP message to send to qemu, formatted like * qobject_from_jsonf_nofail(). See parse_escape() for what's * supported after '%'. *
@@ -100,7 +100,7 @@ QDict *qtest_qmp_fds(QTestState *s, int *fds, size_t fds_num,/** * qtest_qmp: * @s: #QTestState instance to operate on. -* @fmt...: QMP message to send to qemu, formatted like +* @fmt: QMP message to send to qemu, formatted like * qobject_from_jsonf_nofail(). See parse_escape() for what's * supported after '%'. *
@@ -112,7 +112,7 @@ QDict *qtest_qmp(QTestState *s, const char *fmt, ...)/** * qtest_qmp_send: * @s: #QTestState instance to operate on. -* @fmt...: QMP message to send to qemu, formatted like +* @fmt: QMP message to send to qemu, formatted like * qobject_from_jsonf_nofail(). See parse_escape() for what's * supported after '%'. *
@@ -124,7 +124,7 @@ void qtest_qmp_send(QTestState *s, const char *fmt, ...)/** * qtest_qmp_send_raw: * @s: #QTestState instance to operate on. -* @fmt...: text to send, formatted like sprintf() +* @fmt: text to send, formatted like sprintf() * * Sends text to the QMP monitor verbatim. Need not be valid JSON; * this is useful for negative tests.
@@ -201,7 +201,7 @@ QDict *qtest_qmp_receive(QTestState *s);/** * qtest_qmp_eventwait: * @s: #QTestState instance to operate on. -* @s: #event event to wait for. +* @event: event to wait for. * * Continuously polls for QMP responses until it receives the desired event. */
@@ -210,7 +210,7 @@ void qtest_qmp_eventwait(QTestState *s, const char *event);/** * qtest_qmp_eventwait_ref: * @s: #QTestState instance to operate on. -* @s: #event event to wait for. +* @event: event to wait for. * * Continuously polls for QMP responses until it receives the desired event. * Returns a copy of the event for further investigation.
@@ -237,7 +237,7 @@ QDict *qtest_qmp_receive_success(QTestState *s,/** * qtest_hmp: * @s: #QTestState instance to operate on. -* @fmt...: HMP command to send to QEMU, formats arguments like sprintf(). +* @fmt: HMP command to send to QEMU, formats arguments like sprintf(). * * Send HMP command to QEMU via QMP's human-monitor-command. * QMP events are discarded.
@@ -629,7 +629,7 @@ void qtest_add_abrt_handler(GHookFunc fn, const void *data);/** * qtest_qmp_assert_success: * @qts: QTestState instance to operate on -* @fmt...: QMP message to send to qemu, formatted like +* @fmt: QMP message to send to qemu, formatted like * qobject_from_jsonf_nofail(). See parse_escape() for what's * supported after '%'. *
@@ -676,7 +676,7 @@ void qtest_qmp_device_add_qdict(QTestState *qts, const char *drv,* @qts: QTestState instance to operate on * @driver: Name of the device that should be added * @id: Identification string -* @fmt...: QMP message to send to qemu, formatted like +* @fmt: QMP message to send to qemu, formatted like * qobject_from_jsonf_nofail(). See parse_escape() for what's * supported after '%'. *
Signature · 1 line
2.26.2
[PULL 26/39] qtest: switch users back to qtest_qmp_receive
In reply to Paolo BonziniFrom: Maxim Levitsky <[email protected]>
Let test use the new functionality for buffering events. The only remaining users of qtest_qmp_receive_dict are tests that fuzz the QMP protocol.
Tested with 'make check-qtest'.
Message-Id: <[email protected]>
--- tests/qtest/ahci-test.c | 4 ++-- tests/qtest/drive_del-test.c | 9 +++------ tests/qtest/libqtest.c | 12 +++--------- tests/qtest/pvpanic-test.c | 4 +--- tests/qtest/tpm-util.c | 8 ++++++-- 5 files changed, 15 insertions(+), 22 deletions(-)
tests/qtest/ahci-test.c +2 -2
@@ -1590,7 +1590,7 @@ static void test_atapi_tray(void)qtest_qmp_send (ahci->parent->qts,"{'execute': 'blockdev-open-tray', " "'arguments': {'id': 'cd0'}}" );atapi_wait_tray (ahci, true); - rsp =qtest_qmp_receive_dict (ahci->parent->qts); + rsp =qtest_qmp_receive (ahci->parent->qts);qobject_unref (rsp); qmp_discard_response(ahci->parent->qts,
@@ -1620,7 +1620,7 @@ static void test_atapi_tray(void)qtest_qmp_send (ahci->parent->qts,"{'execute': 'blockdev-close-tray', " "'arguments': {'id': 'cd0'}}" );atapi_wait_tray (ahci, false); - rsp =qtest_qmp_receive_dict (ahci->parent->qts); + rsp =qtest_qmp_receive (ahci->parent->qts);qobject_unref (rsp);/* Now, to convince ATAPI we understand the media has changed... */
tests/qtest/drive_del-test.c +3 -6
@@ -15,9 +15,6 @@#include "libqos/virtio.h" #include "qapi/qmp/qdict.h" -/* TODO actually test the results and get rid of this */ -#define qmp_discard_response (q, ...) qobject_unref(qtest_qmp(q, __VA_ARGS__)) -static void drive_add (QTestState *qts) {char *resp =qtest_hmp (qts,"drive_add 0 if=none,id=drive0" );
@@ -38,13 +35,13 @@ static void device_del(QTestState *qts) {QDict *response; -/* Complication: ignore DEVICE_DELETED event */ -qmp_discard_response (qts,"{'execute': 'device_del'," + response =qtest_qmp (qts,"{'execute': 'device_del'," " 'arguments': { 'id': 'dev0' } }" ); - response =qtest_qmp_receive_dict (qts);g_assert (response);g_assert (qdict_haskey (response,"return" ));qobject_unref (response); + +qtest_qmp_eventwait (qts,"DEVICE_DELETED" ); }static void test_drive_without_dev (void )
tests/qtest/libqtest.c +3 -9
@@ -324,7 +324,7 @@ QTestState *qtest_init(const char *extra_args)QDict *greeting;/* Read the QMP greeting and then do the handshake */ - greeting =qtest_qmp_receive_dict (s); + greeting =qtest_qmp_receive (s);qobject_unref (greeting);qobject_unref (qtest_qmp (s,"{ 'execute': 'qmp_capabilities' }" ));
@@ -700,7 +700,7 @@ QDict *qtest_vqmp_fds(QTestState *s, int *fds, size_t fds_num,qtest_qmp_vsend_fds (s, fds, fds_num, fmt, ap);/* Receive reply */ -return qtest_qmp_receive_dict (s); +return qtest_qmp_receive (s); }QDict *qtest_vqmp (QTestState *s,const char *fmt,va_list ap)
@@ -708,7 +708,7 @@ QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap)qtest_qmp_vsend (s, fmt, ap);/* Receive reply */ -return qtest_qmp_receive_dict (s); +return qtest_qmp_receive (s); }QDict *qmp_fd (int fd,const char *fmt, ...)
@@ -850,12 +850,6 @@ char *qtest_vhmp(QTestState *s, const char *fmt, va_list ap)" 'arguments': {'command-line': %s}}" , cmd); ret =g_strdup (qdict_get_try_str (resp,"return" )); -while (ret ==NULL &&qdict_get_try_str (resp,"event" )) { -/* Ignore asynchronous QMP events */ -qobject_unref (resp); - resp =qtest_qmp_receive_dict (s); - ret =g_strdup (qdict_get_try_str (resp,"return" )); - }g_assert (ret);qobject_unref (resp);g_free (cmd);
tests/qtest/pvpanic-test.c +1 -3
@@ -24,9 +24,7 @@ static void test_panic(void)qtest_outb (qts,0x505 ,0x1 ); - response =qtest_qmp_receive_dict (qts); -g_assert (qdict_haskey (response,"event" )); - g_assert_cmpstr(qdict_get_str(response, "event"), ==, "GUEST_PANICKED"); + response =qtest_qmp_eventwait_ref (qts,"GUEST_PANICKED" );g_assert (qdict_haskey (response,"data" )); data =qdict_get_qdict (response,"data" );g_assert (qdict_haskey (data,"action" ));
tests/qtest/tpm-util.c +6 -2
@@ -237,12 +237,16 @@ void tpm_util_migrate(QTestState *who, const char *uri)void tpm_util_wait_for_migration_complete (QTestState *who) {while (true) { +QDict *rsp;QDict *rsp_return;bool completed;const char *status; -qtest_qmp_send (who,"{ 'execute': 'query-migrate' }" ); - rsp_return =qtest_qmp_receive_success (who,NULL ,NULL ); + rsp =qtest_qmp (who,"{ 'execute': 'query-migrate' }" ); +g_assert (qdict_haskey (rsp,"return" )); + rsp_return =qdict_get_qdict (rsp,"return" ); + +g_assert (!qdict_haskey (rsp_return,"error" )); status =qdict_get_str (rsp_return,"status" ); completed =strcmp (status,"completed" ) ==0 ; g_assert_cmpstr(status, !=, "failed");
Signature · 1 line
2.26.2
[PULL 08/39] authz: Move the creation of the library to the main meson.build
In reply to Paolo BonziniFrom: Philippe Mathieu-Daudé <[email protected]>
Be consistent creating all the libraries in the main meson.build file.
Message-Id: <[email protected]>
--- authz/meson.build | 10 ---------- meson.build | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-)
authz/meson.build +0 -10
@@ -1,4 +1,3 @@ -authz_ss = ss.source_set() authz_ss.add(genh) authz_ss.add(files( 'base.c',
@@ -8,12 +7,3 @@ authz_ss.add(files( )) authz_ss.add(when: ['CONFIG_AUTH_PAM', pam], if_true: files('pamacct.c')) - -authz_ss = authz_ss.apply(config_host, strict: false) -libauthz = static_library('authz', authz_ss.sources() + genh, - dependencies: [authz_ss.dependencies()], - name_suffix: 'fa', - build_by_default: false) - -authz = declare_dependency(link_whole: libauthz, - dependencies: qom)
meson.build +10 -0
@@ -1182,6 +1182,7 @@ sphinx_extn_depends = [ meson.source_root() / 'docs/sphinx/depfile.py', # Collect sourcesets. +authz_ss = ss.source_set() blockdev_ss = ss.source_set() block_ss = ss.source_set() bsd_user_ss = ss.source_set()
@@ -1453,6 +1454,15 @@ qemu_syms = custom_target('qemu.syms', output: 'qemu.syms', # Library dependencies # ######################## +authz_ss = authz_ss.apply(config_host, strict: false) +libauthz = static_library('authz', authz_ss.sources() + genh, + dependencies: [authz_ss.dependencies()], + name_suffix: 'fa', + build_by_default: false) + +authz = declare_dependency(link_whole: libauthz, + dependencies: qom) + crypto_ss = crypto_ss.apply(config_host, strict: false) libcrypto = static_library('crypto', crypto_ss.sources() + genh, dependencies: [crypto_ss.dependencies()],
Signature · 1 line
2.26.2
[PULL 12/39] exec: split out non-softmmu-specific parts
In reply to Paolo BonziniOver the years, most parts of exec.c that were not specific to softmmu have been moved to accel/tcg; what's left is mostly the low-level part of the memory API, which includes RAMBlock and AddressSpaceDispatch. However exec.c also hosts 4-500 lines of code for the target specific parts of the CPU QOM object, plus a few functions for user-mode emulation that do not have a better place (they are not TCG-specific so accel/tcg/user-exec.c is not a good place either).
Move these parts to a new file, so that exec.c can be moved to softmmu/physmem.c.
--- MAINTAINERS | 4 +- cpu.c | 452 +++++++++++++++++++++++++++++++++++ include/exec/cpu-common.h | 3 + meson.build | 2 +- softmmu/meson.build | 3 +- exec.c => softmmu/physmem.c | 454 +----------------------------------- 6 files changed, 467 insertions(+), 451 deletions(-) create mode 100644 cpu.c rename exec.c => softmmu/physmem.c (91%)
MAINTAINERS +2 -2
@@ -117,7 +117,6 @@ R: Paolo Bonzini <[email protected]> S: Maintained F: softmmu/cpus.c F: cpus-common.c -F: exec.c F: accel/tcg/ F: accel/stubs/tcg-stub.c F: scripts/decodetree.py
@@ -1525,6 +1524,7 @@ Machine core M: Eduardo Habkost <[email protected]> M: Marcel Apfelbaum <[email protected]> S: Supported +F: cpu.c F: hw/core/cpu.c F: hw/core/machine-qmp-cmds.c F: hw/core/machine.c
@@ -2284,8 +2284,8 @@ F: include/exec/ramblock.h F: softmmu/dma-helpers.c F: softmmu/ioport.c F: softmmu/memory.c +F: softmmu/physmem.c F: include/exec/memory-internal.h -F: exec.c F: scripts/coccinelle/memory-region-housekeeping.cocci SPICE
cpu.c new file +452 -0
452 lines not on this page · raw message
include/exec/cpu-common.h +3 -0
@@ -14,6 +14,9 @@ void cpu_list_unlock(void);void tcg_flush_softmmu_tlb (CPUState *cs); +void tcg_iommu_init_notifier_list (CPUState *cpu); +void tcg_iommu_free_notifier_list (CPUState *cpu); +#if !defined(CONFIG_USER_ONLY ) enum device_endian {
meson.build +1 -1
@@ -1372,7 +1372,7 @@ common_ss.add(files('cpus-common.c')) subdir('softmmu') common_ss.add(capstone) -specific_ss.add(files('disas.c', 'exec.c', 'gdbstub.c'), capstone, libpmem, libdaxctl) +specific_ss.add(files('cpu.c', 'disas.c', 'gdbstub.c'), capstone) specific_ss.add(files('exec-vary.c')) specific_ss.add(when: 'CONFIG_TCG', if_true: files( 'fpu/softfloat.c',
softmmu/meson.build +2 -1
@@ -3,6 +3,7 @@ specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files( 'balloon.c', 'cpus.c', 'cpu-throttle.c', + 'physmem.c', 'ioport.c', 'memory.c', 'memory_mapping.c',
@@ -19,7 +20,7 @@ softmmu_ss.add(files( 'bootdevice.c', 'dma-helpers.c', 'qdev-monitor.c', -), sdl) +), sdl, libpmem, libdaxctl) softmmu_ss.add(when: 'CONFIG_TPM', if_true: files('tpm.c')) softmmu_ss.add(when: 'CONFIG_SECCOMP', if_true: [files('qemu-seccomp.c'), seccomp])
softmmu/physmem.c renamed from exec.c +7 -447
556 lines not on this page · raw message
Signature · 1 line
2.26.2
[PULL 30/39] scsi/scsi_bus: switch search direction in scsi_device_find
In reply to Paolo BonziniFrom: Maxim Levitsky <[email protected]>
This change will allow us to convert the bus children list to RCU, while not changing the logic of this function
Message-Id: <[email protected]>
--- hw/scsi/scsi-bus.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
hw/scsi/scsi-bus.c +10 -2
@@ -1572,7 +1572,7 @@ SCSIDevice *scsi_device_find(SCSIBus *bus, int channel, int id, int lun)BusChild *kid;SCSIDevice *target_dev =NULL ; - QTAILQ_FOREACH_REVERSE(kid, &bus->qbus.children, sibling) { + QTAILQ_FOREACH(kid, &bus->qbus.children, sibling) {DeviceState *qdev = kid->child;SCSIDevice *dev =SCSI_DEVICE (qdev);
@@ -1580,7 +1580,15 @@ SCSIDevice *scsi_device_find(SCSIBus *bus, int channel, int id, int lun)if (dev->lun == lun) {return dev; } - target_dev = dev; + +/* +* If we don't find exact match (channel/bus/lun), +* we will return the first device which matches channel/bus +*/ + +if (!target_dev) { + target_dev = dev; + } } }return target_dev;
Signature · 1 line
2.26.2
[PULL 22/39] qtest: rename qtest_qmp_receive to qtest_qmp_receive_dict
In reply to Paolo BonziniFrom: Maxim Levitsky <[email protected]>
In the next patch a new version of qtest_qmp_receive will be reintroduced that will buffer received qmp events for later consumption in qtest_qmp_eventwait_ref
No functional change intended.
--- tests/qtest/ahci-test.c | 4 ++-- tests/qtest/device-plug-test.c | 2 +- tests/qtest/drive_del-test.c | 2 +- tests/qtest/libqos/libqtest.h | 4 ++-- tests/qtest/libqtest.c | 16 ++++++++-------- tests/qtest/pvpanic-test.c | 2 +- tests/qtest/qmp-test.c | 18 +++++++++--------- 7 files changed, 24 insertions(+), 24 deletions(-)
tests/qtest/ahci-test.c +2 -2
@@ -1590,7 +1590,7 @@ static void test_atapi_tray(void)qtest_qmp_send (ahci->parent->qts,"{'execute': 'blockdev-open-tray', " "'arguments': {'id': 'cd0'}}" );atapi_wait_tray (ahci, true); - rsp =qtest_qmp_receive (ahci->parent->qts); + rsp =qtest_qmp_receive_dict (ahci->parent->qts);qobject_unref (rsp); qmp_discard_response(ahci->parent->qts,
@@ -1620,7 +1620,7 @@ static void test_atapi_tray(void)qtest_qmp_send (ahci->parent->qts,"{'execute': 'blockdev-close-tray', " "'arguments': {'id': 'cd0'}}" );atapi_wait_tray (ahci, false); - rsp =qtest_qmp_receive (ahci->parent->qts); + rsp =qtest_qmp_receive_dict (ahci->parent->qts);qobject_unref (rsp);/* Now, to convince ATAPI we understand the media has changed... */
tests/qtest/device-plug-test.c +1 -1
@@ -23,7 +23,7 @@ static void device_del_start(QTestState *qtest, const char *id)static void device_del_finish (QTestState *qtest) { -QDict *resp =qtest_qmp_receive (qtest); +QDict *resp =qtest_qmp_receive_dict (qtest);g_assert (qdict_haskey (resp,"return" ));qobject_unref (resp);
tests/qtest/drive_del-test.c +1 -1
@@ -41,7 +41,7 @@ static void device_del(QTestState *qts)/* Complication: ignore DEVICE_DELETED event */ qmp_discard_response (qts,"{'execute': 'device_del'," " 'arguments': { 'id': 'dev0' } }" ); - response =qtest_qmp_receive (qts); + response =qtest_qmp_receive_dict (qts);g_assert (response);g_assert (qdict_haskey (response,"return" ));qobject_unref (response);
tests/qtest/libqos/libqtest.h +2 -2
@@ -191,12 +191,12 @@ void qtest_qmp_vsend(QTestState *s, const char *fmt, va_list ap)GCC_FMT_ATTR (2 ,0 );/** -* qtest_receive: +* qtest_qmp_receive_dict: * @s: #QTestState instance to operate on. * * Reads a QMP message from QEMU and returns the response. */ -QDict *qtest_qmp_receive (QTestState *s); +QDict *qtest_qmp_receive_dict (QTestState *s);/** * qtest_qmp_eventwait:
tests/qtest/libqtest.c +8 -8
@@ -322,7 +322,7 @@ QTestState *qtest_init(const char *extra_args)QDict *greeting;/* Read the QMP greeting and then do the handshake */ - greeting =qtest_qmp_receive (s); + greeting =qtest_qmp_receive_dict (s);qobject_unref (greeting);qobject_unref (qtest_qmp (s,"{ 'execute': 'qmp_capabilities' }" ));
@@ -603,7 +603,7 @@ QDict *qmp_fd_receive(int fd)return qmp.response; } -QDict *qtest_qmp_receive (QTestState *s) +QDict *qtest_qmp_receive_dict (QTestState *s) {return qmp_fd_receive (s->qmp_fd); }
@@ -678,7 +678,7 @@ QDict *qtest_vqmp_fds(QTestState *s, int *fds, size_t fds_num,qtest_qmp_vsend_fds (s, fds, fds_num, fmt, ap);/* Receive reply */ -return qtest_qmp_receive (s); +return qtest_qmp_receive_dict (s); }QDict *qtest_vqmp (QTestState *s,const char *fmt,va_list ap)
@@ -686,7 +686,7 @@ QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap)qtest_qmp_vsend (s, fmt, ap);/* Receive reply */ -return qtest_qmp_receive (s); +return qtest_qmp_receive_dict (s); }QDict *qmp_fd (int fd,const char *fmt, ...)
@@ -776,7 +776,7 @@ QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event)QDict *response;for (;;) { - response =qtest_qmp_receive (s); + response =qtest_qmp_receive_dict (s);if ((qdict_haskey (response,"event" )) && (strcmp (qdict_get_str (response,"event" ), event) ==0 )) {return response;
@@ -807,7 +807,7 @@ char *qtest_vhmp(QTestState *s, const char *fmt, va_list ap)while (ret ==NULL &&qdict_get_try_str (resp,"event" )) {/* Ignore asynchronous QMP events */ qobject_unref (resp); - resp =qtest_qmp_receive (s); + resp =qtest_qmp_receive_dict (s); ret =g_strdup (qdict_get_try_str (resp,"return" )); }g_assert (ret);
@@ -1255,7 +1255,7 @@ QDict *qtest_qmp_receive_success(QTestState *s,const char *event;for (;;) { - response =qtest_qmp_receive (s); + response =qtest_qmp_receive_dict (s);g_assert (!qdict_haskey (response,"error" )); ret =qdict_get_qdict (response,"return" );if (ret) {
@@ -1345,7 +1345,7 @@ void qtest_qmp_device_del(QTestState *qts, const char *id) rsp =qtest_qmp_receive_success (qts, device_deleted_cb, &got_event);qobject_unref (rsp);if (!got_event) { - rsp =qtest_qmp_receive (qts); + rsp =qtest_qmp_receive_dict (qts);g_assert_cmpstr (qdict_get_try_str (rsp,"event" ), ==, "DEVICE_DELETED");qobject_unref (rsp);
tests/qtest/pvpanic-test.c +1 -1
@@ -24,7 +24,7 @@ static void test_panic(void)qtest_outb (qts,0x505 ,0x1 ); - response =qtest_qmp_receive (qts); + response =qtest_qmp_receive_dict (qts);g_assert (qdict_haskey (response,"event" )); g_assert_cmpstr(qdict_get_str(response, "event"), ==, "GUEST_PANICKED");g_assert (qdict_haskey (response,"data" ));
tests/qtest/qmp-test.c +9 -9
@@ -47,37 +47,37 @@ static void test_malformed(QTestState *qts)/* syntax error */ qtest_qmp_send_raw (qts,"{]\n" ); - resp =qtest_qmp_receive (qts); + resp =qtest_qmp_receive_dict (qts);qmp_expect_error_and_unref (resp,"GenericError" );assert_recovered (qts);/* lexical error: impossible byte outside string */ qtest_qmp_send_raw (qts,"{\xFF" ); - resp =qtest_qmp_receive (qts); + resp =qtest_qmp_receive_dict (qts);qmp_expect_error_and_unref (resp,"GenericError" );assert_recovered (qts);/* lexical error: funny control character outside string */ qtest_qmp_send_raw (qts,"{\x01" ); - resp =qtest_qmp_receive (qts); + resp =qtest_qmp_receive_dict (qts);qmp_expect_error_and_unref (resp,"GenericError" );assert_recovered (qts);/* lexical error: impossible byte in string */ qtest_qmp_send_raw (qts,"{'bad \xFF" ); - resp =qtest_qmp_receive (qts); + resp =qtest_qmp_receive_dict (qts);qmp_expect_error_and_unref (resp,"GenericError" );assert_recovered (qts);/* lexical error: control character in string */ qtest_qmp_send_raw (qts,"{'execute': 'nonexistent', 'id':'\n" ); - resp =qtest_qmp_receive (qts); + resp =qtest_qmp_receive_dict (qts);qmp_expect_error_and_unref (resp,"GenericError" );assert_recovered (qts);/* lexical error: interpolation */ qtest_qmp_send_raw (qts,"%%p" ); - resp =qtest_qmp_receive (qts); + resp =qtest_qmp_receive_dict (qts);qmp_expect_error_and_unref (resp,"GenericError" );assert_recovered (qts);
@@ -111,7 +111,7 @@ static void test_qmp_protocol(void) qts =qtest_init_without_qmp_handshake (common_args);/* Test greeting */ - resp =qtest_qmp_receive (qts); + resp =qtest_qmp_receive_dict (qts); q =qdict_get_qdict (resp,"QMP" );g_assert (q);test_version (qdict_get (q,"version" ));
@@ -205,7 +205,7 @@ static void send_oob_cmd_that_fails(QTestState *s, const char *id)static void recv_cmd_id (QTestState *s,const char *id) { -QDict *resp =qtest_qmp_receive (s); +QDict *resp =qtest_qmp_receive_dict (s); g_assert_cmpstr(qdict_get_try_str(resp, "id"), ==, id);qobject_unref (resp);
@@ -222,7 +222,7 @@ static void test_qmp_oob(void) qts =qtest_init_without_qmp_handshake (common_args);/* Check the greeting message. */ - resp =qtest_qmp_receive (qts); + resp =qtest_qmp_receive_dict (qts); q =qdict_get_qdict (resp,"QMP" );g_assert (q); capabilities =qdict_get_qlist (q,"capabilities" );
Signature · 1 line
2.26.2
[PULL 21/39] meson.build: Re-enable KVM support for MIPS
In reply to Paolo BonziniFrom: Huacai Chen <[email protected]>
After converting from configure to meson, KVM support is lost for MIPS, so re-enable it in meson.build.
Message-Id: <[email protected]>
--- meson.build | 2 ++ 1 file changed, 2 insertions(+)
meson.build +2 -0
@@ -59,6 +59,8 @@ elif cpu == 's390x' kvm_targets = ['s390x-softmmu'] elif cpu in ['ppc', 'ppc64'] kvm_targets = ['ppc-softmmu', 'ppc64-softmmu'] +elif cpu in ['mips', 'mips64'] + kvm_targets = ['mips-softmmu', 'mipsel-softmmu', 'mips64-softmmu', 'mips64el-softmmu'] else kvm_targets = [] endif
Signature · 1 line
2.26.2
[PULL 34/39] device-core: use atomic_set on .realized property
In reply to Paolo BonziniFrom: Maxim Levitsky <[email protected]>
Some code might race with placement of new devices on a bus. We currently first place a (unrealized) device on the bus and then realize it.
As a workaround, users that scan the child device list, can check the realized property to see if it is safe to access such a device. Use an atomic write here too to aid with this.
A separate discussion is what to do with devices that are unrealized:
It looks like for this case we only call the hotplug handler's unplug callback and its up to it to unrealize the device.
An atomic operation doesn't cause harm for this code path though.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
--- hw/core/qdev.c | 19 ++++++++++++++++++- include/hw/qdev-core.h | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-)
hw/core/qdev.c +18 -1
@@ -946,7 +946,25 @@ static void device_set_realized(Object *obj, bool value, Error **errp) } } +qatomic_store_release (&dev->realized, value); + }else if (!value && dev->realized) { + +/* +* Change the value so that any concurrent users are aware +* that the device is going to be unrealized +* +* TODO: change .realized property to enum that states +* each phase of the device realization/unrealization +*/ + +qatomic_set (&dev->realized, value); +/* +* Ensure that concurrent users see this update prior to +* any other changes done by unrealize. +*/ +smp_wmb (); + QLIST_FOREACH(bus, &dev->child_bus, sibling) {qbus_unrealize (bus); }
@@ -961,7 +979,6 @@ static void device_set_realized(Object *obj, bool value, Error **errp) }assert (local_err ==NULL ); - dev->realized = value;return ; child_realize_fail:
include/hw/qdev-core.h +2 -0
@@ -163,6 +163,8 @@ struct NamedClockList {/** * DeviceState: * @realized: Indicates whether the device has been fully constructed. +* When accessed outsize big qemu lock, must be accessed with +* atomic_load_acquire() * @reset: ResettableState for the device; handled by Resettable interface. * * This structure should not be accessed directly. We declare it here
Signature · 1 line
2.26.2
[PULL 28/39] qemu-iotests, qtest: rewrite test 067 as a qtest
In reply to Paolo BonziniTest 067 from qemu-iotests is executing QMP commands to hotplug and hot-unplug disks, devices and blockdevs. Because the power of the text-based test harness is limited, it is actually limiting the checks that it does, for example by skipping DEVICE_DELETED events.
tests/qtest already has a similar test, drive_del-test.c. We can merge them, and even reuse some of the existing code in drive_del-test.c. This will improve the quality of the test by covering DEVICE_DELETED events and testing multiple architectures (therefore covering multiple PCI hotplug mechanisms as well as s390x virtio-ccw).
The only difference is that the new test will always use null-co:// for the medium rather than qcow2 or raw, but this should be irrelevant for what the test is covering. For example there are no "qemu-img check" runs in 067 that would check that the file is properly closed.
The new tests requires PCI hot-plug support, so drive_del-test is moved from qemu-system-ppc to qemu-system-ppc64.
--- .gitlab-ci.yml | 2 +- tests/qemu-iotests/067 | 157 ------------- tests/qemu-iotests/067.out | 414 ----------------------------------- tests/qemu-iotests/group | 2 +- tests/qtest/drive_del-test.c | 211 ++++++++++++++++-- tests/qtest/meson.build | 4 +- 6 files changed, 191 insertions(+), 599 deletions(-) delete mode 100755 tests/qemu-iotests/067 delete mode 100644 tests/qemu-iotests/067.out
.gitlab-ci.yml +1 -1
@@ -232,7 +232,7 @@ build-tcg-disabled: - ./check -raw 001 002 003 004 005 008 009 010 011 012 021 025 032 033 048 052 063 077 086 101 104 106 113 148 150 151 152 157 159 160 163 170 171 183 184 192 194 197 208 215 221 222 226 227 236 253 277 - - ./check -qcow2 028 051 056 057 058 065 067 068 082 085 091 095 096 102 122 + - ./check -qcow2 028 051 056 057 058 065 068 082 085 091 095 096 102 122 124 132 139 142 144 145 151 152 155 157 165 194 196 197 200 202 208 209 215 216 218 222 227 234 246 247 248 250 254 255 257 258 260 261 262 263 264 270 272 273 277 279
tests/qemu-iotests/067 deleted +0 -157
157 lines not on this page · raw message
tests/qemu-iotests/067.out deleted +0 -414
414 lines not on this page · raw message
tests/qemu-iotests/group +1 -1
@@ -88,7 +88,7 @@ 064 rw quick 065 rw quick 066 rw auto quick -067 rw quick +# 067 was removed, do not reuse 068 rw quick 069 rw auto quick 070 rw quick
tests/qtest/drive_del-test.c +187 -24
277 lines not on this page · raw message
tests/qtest/meson.build +2 -2
@@ -111,7 +111,7 @@ 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'] \ + ['boot-order-test', 'prom-env-test', 'boot-serial-test'] \ qtests_ppc64 = \ (config_all_devices.has_key('CONFIG_PSERIES') ? ['device-plug-test'] : []) + \
@@ -121,7 +121,7 @@ qtests_ppc64 = \ (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_pci + ['migration-test', 'numa-test', 'cpu-plug-test', 'drive_del-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'] : [])
Signature · 1 line
2.26.2
[PULL 25/39] device-plug-test: use qtest_qmp to send the device_del command
In reply to Paolo BonziniSimplify the code now that events are buffered. There is no need anymore to separate sending the command and retrieving the response.
--- tests/qtest/device-plug-test.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-)
tests/qtest/device-plug-test.c +9 -23
@@ -15,26 +15,17 @@#include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" -static void device_del_start (QTestState *qtest,const char *id) +static void device_del (QTestState *qtest,const char *id) { -qtest_qmp_send (qtest, -"{'execute': 'device_del', 'arguments': { 'id': %s } }" , id); -} +QDict *resp; -static void device_del_finish (QTestState *qtest) -{ -QDict *resp =qtest_qmp_receive_dict (qtest); + resp =qtest_qmp (qtest, +"{'execute': 'device_del', 'arguments': { 'id': %s } }" , id);g_assert (qdict_haskey (resp,"return" ));qobject_unref (resp); } -static void device_del_request (QTestState *qtest,const char *id) -{ -device_del_start (qtest, id); -device_del_finish (qtest); -} -static void system_reset (QTestState *qtest) {QDict *resp;
@@ -79,7 +70,7 @@ static void test_pci_unplug_request(void)* be processed. However during system reset, the removal will be * handled, removing the device. */ -device_del_request (qtest,"dev0" ); +device_del (qtest,"dev0" );system_reset (qtest);wait_device_deleted_event (qtest,"dev0" );
@@ -90,13 +81,8 @@ static void test_ccw_unplug(void) {QTestState *qtest =qtest_initf ("-device virtio-balloon-ccw,id=dev0" ); -/* -* The DEVICE_DELETED events will be sent before the command -* completes. -*/ -device_del_start (qtest,"dev0" ); +device_del (qtest,"dev0" );wait_device_deleted_event (qtest,"dev0" ); -device_del_finish (qtest);qtest_quit (qtest); }
@@ -109,7 +95,7 @@ static void test_spapr_cpu_unplug_request(void) "-device power9_v2.0-spapr-cpu-core,core-id=1,id=dev0");/* similar to test_pci_unplug_request */ -device_del_request (qtest,"dev0" ); +device_del (qtest,"dev0" );system_reset (qtest);wait_device_deleted_event (qtest,"dev0" );
@@ -125,7 +111,7 @@ static void test_spapr_memory_unplug_request(void) "-device pc-dimm,id=dev0,memdev=mem0");/* similar to test_pci_unplug_request */ -device_del_request (qtest,"dev0" ); +device_del (qtest,"dev0" );system_reset (qtest);wait_device_deleted_event (qtest,"dev0" );
@@ -139,7 +125,7 @@ static void test_spapr_phb_unplug_request(void) qtest =qtest_initf ("-device spapr-pci-host-bridge,index=1,id=dev0" );/* similar to test_pci_unplug_request */ -device_del_request (qtest,"dev0" ); +device_del (qtest,"dev0" );system_reset (qtest);wait_device_deleted_event (qtest,"dev0" );
Signature · 1 line
2.26.2
[PULL 36/39] scsi/scsi_bus: Add scsi_device_get
In reply to Paolo BonziniFrom: Maxim Levitsky <[email protected]>
Add scsi_device_get which finds the scsi device
and takes a reference to it.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
--- hw/scsi/scsi-bus.c | 11 +++++++++++ include/hw/scsi/scsi.h | 1 + 2 files changed, 12 insertions(+)
hw/scsi/scsi-bus.c +11 -0
@@ -73,6 +73,17 @@ SCSIDevice *scsi_device_find(SCSIBus *bus, int channel, int id, int lun)return do_scsi_device_find (bus, channel, id, lun, false); } +SCSIDevice *scsi_device_get (SCSIBus *bus,int channel,int id,int lun) +{ +SCSIDevice *d; +RCU_READ_LOCK_GUARD (); + d =do_scsi_device_find (bus, channel, id, lun, false); +if (d) { +object_ref (d); + } +return d; +} +static void scsi_device_realize (SCSIDevice *s,Error **errp) {SCSIDeviceClass *sc =SCSI_DEVICE_GET_CLASS (s);
include/hw/scsi/scsi.h +1 -0
@@ -190,6 +190,7 @@ int scsi_device_get_sense(SCSIDevice *dev, uint8_t *buf, int len, bool fixed);int scsi_SG_IO_FROM_DEV (BlockBackend *blk,uint8_t *cmd,uint8_t cmd_size,uint8_t *buf,uint8_t buf_size);SCSIDevice *scsi_device_find (SCSIBus *bus,int channel,int target,int lun); +SCSIDevice *scsi_device_get (SCSIBus *bus,int channel,int target,int lun);/* scsi-generic.c. */ extern const SCSIReqOps scsi_generic_req_ops;
Signature · 1 line
2.26.2
[PULL 32/39] device-core: use RCU for list of children of a bus
In reply to Paolo BonziniFrom: Maxim Levitsky <[email protected]>
This fixes the race between device emulation code that tries to find a child device to dispatch the request to (e.g a scsi disk), and hotplug of a new device to that bus.
Note that this doesn't convert all the readers of the list but only these that might go over that list without BQL held.
This is a very small first step to make this code thread safe.
Message-Id: <[email protected]> [Use RCU_READ_LOCK_GUARD in more places, adjust testcase now that
the delay in DEVICE_DELETED due to RCU is more consistent. - Paolo]
Message-Id: <[email protected]>
--- hw/core/bus.c | 28 +++++++++++++++++----------- hw/core/qdev.c | 37 +++++++++++++++++++++++-------------- hw/scsi/scsi-bus.c | 12 +++++++++--- hw/scsi/virtio-scsi.c | 6 +++++- include/hw/qdev-core.h | 9 +++++++++ 5 files changed, 63 insertions(+), 29 deletions(-)
hw/core/bus.c +17 -11
@@ -49,12 +49,14 @@ int qbus_walk_children(BusState *bus, } } - QTAILQ_FOREACH(kid, &bus->children, sibling) { - err =qdev_walk_children (kid->child, - pre_devfn, pre_busfn, - post_devfn, post_busfn, opaque); -if (err <0 ) { -return err; + WITH_RCU_READ_LOCK_GUARD() { + QTAILQ_FOREACH_RCU(kid, &bus->children, sibling) { + err =qdev_walk_children (kid->child, + pre_devfn, pre_busfn, + post_devfn, post_busfn, opaque); +if (err <0 ) { +return err; + } } }
@@ -90,8 +92,10 @@ static void bus_reset_child_foreach(Object *obj, ResettableChildCallback cb,BusState *bus =BUS (obj);BusChild *kid; - QTAILQ_FOREACH(kid, &bus->children, sibling) { -cb (OBJECT (kid->child), opaque, type); + WITH_RCU_READ_LOCK_GUARD() { + QTAILQ_FOREACH_RCU(kid, &bus->children, sibling) { +cb (OBJECT (kid->child), opaque, type); + } } }
@@ -194,9 +198,11 @@ static void bus_set_realized(Object *obj, bool value, Error **errp)/* TODO: recursive realization */ }else if (!value && bus->realized) { - QTAILQ_FOREACH(kid, &bus->children, sibling) { -DeviceState *dev = kid->child; -qdev_unrealize (dev); + WITH_RCU_READ_LOCK_GUARD() { + QTAILQ_FOREACH_RCU(kid, &bus->children, sibling) { +DeviceState *dev = kid->child; +qdev_unrealize (dev); + } }if (bc->unrealize) { bc->unrealize (bus);
hw/core/qdev.c +23 -14
@@ -51,6 +51,12 @@ const VMStateDescription *qdev_get_vmsd(DeviceState *dev)return dc->vmsd; } +static void bus_free_bus_child (BusChild *kid) +{ +object_unref (OBJECT (kid->child)); +g_free (kid); +} +static void bus_remove_child (BusState *bus,DeviceState *child) {BusChild *kid;
@@ -60,15 +66,16 @@ static void bus_remove_child(BusState *bus, DeviceState *child)char name[32 ];snprintf (name,sizeof (name),"child[%d]" , kid->index); -QTAILQ_REMOVE (&bus->children, kid, sibling); +QTAILQ_REMOVE_RCU (&bus->children, kid, sibling); bus->num_children--;/* This gives back ownership of kid->child back to us. */ object_property_del (OBJECT (bus), name); -object_unref (OBJECT (kid->child)); -g_free (kid); -return ; + +/* free the bus kid, when it is safe to do so*/ +call_rcu (kid, bus_free_bus_child, rcu); +break ; } } }
@@ -83,7 +90,7 @@ static void bus_add_child(BusState *bus, DeviceState *child) kid->child = child;object_ref (OBJECT (kid->child)); -QTAILQ_INSERT_HEAD (&bus->children, kid, sibling); +QTAILQ_INSERT_HEAD_RCU (&bus->children, kid, sibling);/* This transfers ownership of kid->child to the property. */ snprintf (name,sizeof (name),"child[%d]" , kid->index);
@@ -672,17 +679,19 @@ DeviceState *qdev_find_recursive(BusState *bus, const char *id)DeviceState *ret;BusState *child; - QTAILQ_FOREACH(kid, &bus->children, sibling) { -DeviceState *dev = kid->child; + WITH_RCU_READ_LOCK_GUARD() { + QTAILQ_FOREACH_RCU(kid, &bus->children, sibling) { +DeviceState *dev = kid->child; -if (dev->id &&strcmp (dev->id, id) ==0 ) { -return dev; - } +if (dev->id &&strcmp (dev->id, id) ==0 ) { +return dev; + } - QLIST_FOREACH(child, &dev->child_bus, sibling) { - ret =qdev_find_recursive (child, id); -if (ret) { -return ret; + QLIST_FOREACH(child, &dev->child_bus, sibling) { + ret =qdev_find_recursive (child, id); +if (ret) { +return ret; + } } } }
hw/scsi/scsi-bus.c +9 -3
@@ -400,7 +400,10 @@ static bool scsi_target_emulate_report_luns(SCSITargetReq *r) id = r->req.dev->id; found_lun0 = false; n =0 ; - QTAILQ_FOREACH(kid, &r->req.bus->qbus.children, sibling) { + +RCU_READ_LOCK_GUARD (); + + QTAILQ_FOREACH_RCU(kid, &r->req.bus->qbus.children, sibling) {DeviceState *qdev = kid->child;SCSIDevice *dev =SCSI_DEVICE (qdev);
@@ -421,7 +424,7 @@ static bool scsi_target_emulate_report_luns(SCSITargetReq *r)memset (r->buf,0 , len);stl_be_p (&r->buf[0 ], n); i = found_lun0 ?8 :16 ; - QTAILQ_FOREACH(kid, &r->req.bus->qbus.children, sibling) { + QTAILQ_FOREACH_RCU(kid, &r->req.bus->qbus.children, sibling) {DeviceState *qdev = kid->child;SCSIDevice *dev =SCSI_DEVICE (qdev);
@@ -430,6 +433,7 @@ static bool scsi_target_emulate_report_luns(SCSITargetReq *r) i +=8 ; } } +assert (i == n +8 ); r->len = len;return true;
@@ -1572,7 +1576,8 @@ SCSIDevice *scsi_device_find(SCSIBus *bus, int channel, int id, int lun)BusChild *kid;SCSIDevice *target_dev =NULL ; - QTAILQ_FOREACH(kid, &bus->qbus.children, sibling) { +RCU_READ_LOCK_GUARD (); + QTAILQ_FOREACH_RCU(kid, &bus->qbus.children, sibling) {DeviceState *qdev = kid->child;SCSIDevice *dev =SCSI_DEVICE (qdev);
@@ -1591,6 +1596,7 @@ SCSIDevice *scsi_device_find(SCSIBus *bus, int channel, int id, int lun) } } } +return target_dev; }
hw/scsi/virtio-scsi.c +5 -1
@@ -367,12 +367,16 @@ static int virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req)case VIRTIO_SCSI_T_TMF_I_T_NEXUS_RESET : target = req->req.tmf.lun[1 ]; s->resetting++; - QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) { + +rcu_read_lock (); + QTAILQ_FOREACH_RCU(kid, &s->bus.qbus.children, sibling) { d =SCSI_DEVICE (kid->child);if (d->channel ==0 && d->id == target) {qdev_reset_all (&d->qdev); } } +rcu_read_unlock (); + s->resetting--;break ;
include/hw/qdev-core.h +9 -0
@@ -3,6 +3,8 @@#include "qemu/queue.h" #include "qemu/bitmap.h" +#include "qemu/rcu.h" +#include "qemu/rcu_queue.h" #include "qom/object.h" #include "hw/hotplug.h" #include "hw/resettable.h"
@@ -238,6 +240,7 @@ struct BusClass { }; typedef struct BusChild { + struct rcu_head rcu; DeviceState *child; int index; QTAILQ_ENTRY(BusChild) sibling;
@@ -258,6 +261,12 @@ struct BusState {int max_index;bool realized;int num_children; + +/* +* children is a RCU QTAILQ, thus readers must use RCU to access it, +* and writers must hold the big qemu lock +*/ + QTAILQ_HEAD(, BusChild) children;QLIST_ENTRY (BusState) sibling;ResettableState reset;
Signature · 1 line
2.26.2
[PULL 27/39] qtest: check that drives are really appearing and disappearing
In reply to Paolo BonziniDo not just trust the HMP commands to create and delete the drive, use query-block to check that this is actually the case.
--- tests/qtest/drive_del-test.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)
tests/qtest/drive_del-test.c +31 -1
@@ -14,20 +14,49 @@#include "libqos/libqtest.h" #include "libqos/virtio.h" #include "qapi/qmp/qdict.h" +#include "qapi/qmp/qlist.h" + +static bool has_drive (QTestState *qts) +{ +QDict *response; +QList *ret; +QListEntry *entry; +bool found; + + response =qtest_qmp (qts,"{'execute': 'query-block'}" ); +g_assert (response &&qdict_haskey (response,"return" )); + ret =qdict_get_qlist (response,"return" ); + + found = false; + QLIST_FOREACH_ENTRY(ret, entry) { +QDict *entry_dict =qobject_to (QDict, entry->value); +if (!strcmp (qdict_get_str (entry_dict,"device" ),"drive0" )) { + found = true; +break ; + } + } + +qobject_unref (response); +return found; +}static void drive_add (QTestState *qts) {char *resp =qtest_hmp (qts,"drive_add 0 if=none,id=drive0" ); g_assert_cmpstr(resp, ==, "OK\r\n"); +g_assert (has_drive (qts));g_free (resp); }static void drive_del (QTestState *qts) { -char *resp =qtest_hmp (qts,"drive_del drive0" ); +char *resp; +g_assert (has_drive (qts)); + resp =qtest_hmp (qts,"drive_del drive0" ); g_assert_cmpstr(resp, ==, ""); +g_assert (!has_drive (qts));g_free (resp); }
@@ -130,6 +159,7 @@ static void test_drive_del_device_del(void)*/ drive_del (qts);device_del (qts); +g_assert (!has_drive (qts));qtest_quit (qts); }
Signature · 1 line
2.26.2
[PULL 38/39] scsi/scsi_bus: fix races in REPORT LUNS
In reply to Paolo BonziniFrom: Maxim Levitsky <[email protected]>
Currently scsi_target_emulate_report_luns iterates over the child device list twice, and there is no guarantee that this list is the same in both iterations.
The reason for iterating twice is that the first iteration calculates how much memory to allocate. However if we use a dynamic array we can avoid iterating twice, and therefore we avoid this race.
Message-Id: <[email protected]>
Message-Id: <[email protected]>
--- hw/scsi/scsi-bus.c | 68 ++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 35 deletions(-)
hw/scsi/scsi-bus.c +33 -35
@@ -438,19 +438,23 @@ struct SCSITargetReq {static void store_lun (uint8_t *outbuf,int lun) {if (lun <256 ) { +/* Simple logical unit addressing method*/ + outbuf[0 ] =0 ; outbuf[1 ] = lun; -return ; + }else { +/* Flat space addressing method */ + outbuf[0 ] =0x40 | (lun >>8 ); + outbuf[1 ] = (lun &255 ); } - outbuf[1 ] = (lun &255 ); - outbuf[0 ] = (lun >>8 ) |0x40 ; }static bool scsi_target_emulate_report_luns (SCSITargetReq *r) {BusChild *kid; -int i, len, n;int channel, id; -bool found_lun0; +uint8_t tmp[8 ] = {0 }; +int len =0 ; +GByteArray *buf;if (r->req.cmd.xfer <16 ) {return false;
@@ -458,46 +462,40 @@ static bool scsi_target_emulate_report_luns(SCSITargetReq *r)if (r->req.cmd.buf[2 ] >2 ) {return false; } + +/* reserve space for 63 LUNs*/ + buf =g_byte_array_sized_new (512 ); + channel = r->req.dev->channel; id = r->req.dev->id; - found_lun0 = false; - n =0 ; -RCU_READ_LOCK_GUARD (); +/* add size (will be updated later to correct value */ +g_byte_array_append (buf, tmp,8 ); + len +=8 ; - QTAILQ_FOREACH_RCU(kid, &r->req.bus->qbus.children, sibling) { -DeviceState *qdev = kid->child; -SCSIDevice *dev =SCSI_DEVICE (qdev); +/* add LUN0 */ +g_byte_array_append (buf, tmp,8 ); + len +=8 ; -if (dev->channel == channel && dev->id == id) { -if (dev->lun ==0 ) { - found_lun0 = true; + WITH_RCU_READ_LOCK_GUARD() { + QTAILQ_FOREACH_RCU(kid, &r->req.bus->qbus.children, sibling) { +DeviceState *qdev = kid->child; +SCSIDevice *dev =SCSI_DEVICE (qdev); + +if (dev->channel == channel && dev->id == id && dev->lun !=0 ) { +store_lun (tmp, dev->lun); +g_byte_array_append (buf, tmp,8 ); + len +=8 ; } - n +=8 ; } } -if (!found_lun0) { - n +=8 ; - } - -scsi_target_alloc_buf (&r->req, n +8 ); - - len =MIN (n +8 , r->req.cmd.xfer & ~7 ); -memset (r->buf,0 , len); -stl_be_p (&r->buf[0 ], n); - i = found_lun0 ?8 :16 ; - QTAILQ_FOREACH_RCU(kid, &r->req.bus->qbus.children, sibling) { -DeviceState *qdev = kid->child; -SCSIDevice *dev =SCSI_DEVICE (qdev); -if (dev->channel == channel && dev->id == id) { -store_lun (&r->buf[i], dev->lun); - i +=8 ; - } - } + r->buf_len = len; + r->buf =g_byte_array_free (buf, FALSE); + r->len =MIN (len, r->req.cmd.xfer & ~7 ); -assert (i == n +8 ); - r->len = len; +/* store the LUN list length */ +stl_be_p (&r->buf[0 ], len -8 );return true; }
Signature · 1 line
2.26.2
[PULL 35/39] scsi/scsi-bus: scsi_device_find: don't return unrealized devices
In reply to Paolo BonziniThe device core first places a device on the bus and then realizes it. Make scsi_device_find avoid returing such devices to avoid races in drivers that use an iothread (currently virtio-scsi)
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1812399
Message-Id: <[email protected]>
Message-Id: <[email protected]>
--- hw/scsi/scsi-bus.c | 83 +++++++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 30 deletions(-)
hw/scsi/scsi-bus.c +53 -30
@@ -24,6 +24,55 @@ static void scsi_target_free_buf(SCSIRequest *req);static int next_scsi_bus; +static SCSIDevice *do_scsi_device_find (SCSIBus *bus, +int channel,int id,int lun, +bool include_unrealized) +{ +BusChild *kid; +SCSIDevice *retval =NULL ; + + QTAILQ_FOREACH_RCU(kid, &bus->qbus.children, sibling) { +DeviceState *qdev = kid->child; +SCSIDevice *dev =SCSI_DEVICE (qdev); + +if (dev->channel == channel && dev->id == id) { +if (dev->lun == lun) { + retval = dev; +break ; + } + +/* +* If we don't find exact match (channel/bus/lun), +* we will return the first device which matches channel/bus +*/ + +if (!retval) { + retval = dev; + } + } + } + +/* +* This function might run on the IO thread and we might race against +* main thread hot-plugging the device. +* We assume that as soon as .realized is set to true we can let +* the user access the device. +*/ + +if (retval && !include_unrealized && + !qatomic_load_acquire (&retval->qdev.realized)) { + retval =NULL ; + } + +return retval; +} + +SCSIDevice *scsi_device_find (SCSIBus *bus,int channel,int id,int lun) +{ +RCU_READ_LOCK_GUARD (); +return do_scsi_device_find (bus, channel, id, lun, false); +} +static void scsi_device_realize (SCSIDevice *s,Error **errp) {SCSIDeviceClass *sc =SCSI_DEVICE_GET_CLASS (s);
@@ -137,7 +186,10 @@ static bool scsi_bus_is_address_free(SCSIBus *bus, int channel, int target, int lun, SCSIDevice **p_dev) { - SCSIDevice *d = scsi_device_find(bus, channel, target, lun); + SCSIDevice *d; + +RCU_READ_LOCK_GUARD (); + d =do_scsi_device_find (bus, channel, target, lun, true);if (d && d->lun == lun) {if (p_dev) { *p_dev = d;
@@ -1570,35 +1622,6 @@ static char *scsibus_get_fw_dev_path(DeviceState *dev) qdev_fw_name(dev), d->id, d->lun); } -SCSIDevice *scsi_device_find (SCSIBus *bus,int channel,int id,int lun) -{ -BusChild *kid; -SCSIDevice *target_dev =NULL ; - -RCU_READ_LOCK_GUARD (); - QTAILQ_FOREACH_RCU(kid, &bus->qbus.children, sibling) { -DeviceState *qdev = kid->child; -SCSIDevice *dev =SCSI_DEVICE (qdev); - -if (dev->channel == channel && dev->id == id) { -if (dev->lun == lun) { -return dev; - } - -/* -* If we don't find exact match (channel/bus/lun), -* we will return the first device which matches channel/bus -*/ - -if (!target_dev) { - target_dev = dev; - } - } - } - -return target_dev; -} -/* SCSI request list. For simplicity, pv points to the whole device */ static int put_scsi_requests(QEMUFile *f, void *pv, size_t size,
Signature · 1 line
2.26.2
[PULL 24/39] qtest: remove qtest_qmp_receive_success
In reply to Paolo BonziniFrom: Maxim Levitsky <[email protected]>
The purpose of qtest_qmp_receive_success was mostly to process events that arrived between the issueing of a command and the "return" line from QMP. This is now handled by the buffering of events that libqtest performs automatically.
--- tests/qtest/libqos/libqtest.h | 17 ----------- tests/qtest/libqtest.c | 53 ++++----------------------------- tests/qtest/migration-helpers.c | 25 ++++++++++++---- 3 files changed, 25 insertions(+), 70 deletions(-)
tests/qtest/libqos/libqtest.h +0 -17
@@ -240,23 +240,6 @@ QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event);*/ QDict *qtest_qmp_event_ref (QTestState *s,const char *event); -/** -* qtest_qmp_receive_success: -* @s: #QTestState instance to operate on -* @event_cb: Event callback -* @opaque: Argument for @event_cb -* -* Poll QMP messages until a command success response is received. -* If @event_cb, call it for each event received, passing @opaque, -* the event's name and data. -* Return the success response's "return" member. -*/ -QDict *qtest_qmp_receive_success (QTestState *s, -void (*event_cb)(void *opaque, -const char *name, -QDict *data), -void *opaque); -/** * qtest_hmp: * @s: #QTestState instance to operate on.
tests/qtest/libqtest.c +5 -48
77 lines not on this page · raw message
tests/qtest/migration-helpers.c +20 -5
@@ -17,10 +17,12 @@bool got_stop; -static void stop_cb (void *opaque,const char *name,QDict *data) +static void check_stop_event (QTestState *who) { -if (!strcmp (name,"STOP" )) { +QDict *event =qtest_qmp_event_ref (who,"STOP" ); +if (event) { got_stop = true; +qobject_unref (event); } }
@@ -30,12 +32,19 @@ static void stop_cb(void *opaque, const char *name, QDict *data)QDict *wait_command_fd (QTestState *who,int fd,const char *command, ...) {va_list ap; +QDict *resp;va_start (ap, command);qtest_qmp_vsend_fds (who, &fd,1 , command, ap);va_end (ap); -return qtest_qmp_receive_success (who, stop_cb,NULL ); + resp =qtest_qmp_receive (who); +check_stop_event (who); + +g_assert (!qdict_haskey (resp,"error" )); +g_assert (qdict_haskey (resp,"return" )); + +return qdict_get_qdict (resp,"return" ); }/*
@@ -44,12 +53,18 @@ QDict *wait_command_fd(QTestState *who, int fd, const char *command, ...)QDict *wait_command (QTestState *who,const char *command, ...) {va_list ap; +QDict *resp;va_start (ap, command); -qtest_qmp_vsend (who, command, ap); + resp =qtest_vqmp (who, command, ap);va_end (ap); -return qtest_qmp_receive_success (who, stop_cb,NULL ); +check_stop_event (who); + +g_assert (!qdict_haskey (resp,"error" )); +g_assert (qdict_haskey (resp,"return" )); + +return qdict_get_qdict (resp,"return" ); }/*
Signature · 1 line
2.26.2
[PULL 33/39] scsi: switch to bus->check_address
In reply to Paolo BonziniMessage-Id: <[email protected]>
--- hw/scsi/scsi-bus.c | 122 ++++++++++++++++++++++++++++----------------- 1 file changed, 75 insertions(+), 47 deletions(-)
hw/scsi/scsi-bus.c +75 -47
@@ -22,33 +22,6 @@ static void scsi_req_dequeue(SCSIRequest *req);static uint8_t *scsi_target_alloc_buf (SCSIRequest *req,size_t len);static void scsi_target_free_buf (SCSIRequest *req); -static Property scsi_props[] = { -DEFINE_PROP_UINT32 ("channel" , SCSIDevice, channel,0 ), -DEFINE_PROP_UINT32 ("scsi-id" , SCSIDevice, id,-1 ), -DEFINE_PROP_UINT32 ("lun" , SCSIDevice, lun,-1 ), -DEFINE_PROP_END_OF_LIST (), -}; - -static void scsi_bus_class_init (ObjectClass *klass,void *data) -{ -BusClass *k =BUS_CLASS (klass); -HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (klass); - - k->get_dev_path = scsibus_get_dev_path; - k->get_fw_dev_path = scsibus_get_fw_dev_path; - hc->unplug = qdev_simple_device_unplug_cb; -} - -static const TypeInfo scsi_bus_info = { - .name =TYPE_SCSI_BUS , - .parent =TYPE_BUS , - .instance_size =sizeof (SCSIBus), - .class_init = scsi_bus_class_init, - .interfaces = (InterfaceInfo []) { - {TYPE_HOTPLUG_HANDLER }, - { } - } -};static int next_scsi_bus;static void scsi_device_realize (SCSIDevice *s,Error **errp)
@@ -160,35 +133,68 @@ static void scsi_dma_restart_cb(void *opaque, int running, RunState state) } } -static void scsi_qdev_realize (DeviceState *qdev,Error **errp) +static bool scsi_bus_is_address_free (SCSIBus *bus, +int channel,int target,int lun, +SCSIDevice **p_dev) +{ +SCSIDevice *d =scsi_device_find (bus, channel, target, lun); +if (d && d->lun == lun) { +if (p_dev) { + *p_dev = d; + } +return false; + } +if (p_dev) { + *p_dev =NULL ; + } +return true; +} + +static bool scsi_bus_check_address (BusState *qbus,DeviceState *qdev,Error **errp) {SCSIDevice *dev =SCSI_DEVICE (qdev); -SCSIBus *bus =DO_UPCAST (SCSIBus, qbus, dev->qdev.parent_bus); -SCSIDevice *d; -Error *local_err =NULL ; +SCSIBus *bus =SCSI_BUS (qbus);if (dev->channel > bus->info->max_channel) {error_setg (errp,"bad scsi channel id: %d" , dev->channel); -return ; +return false; }if (dev->id !=-1 && dev->id > bus->info->max_target) {error_setg (errp,"bad scsi device id: %d" , dev->id); -return ; +return false; }if (dev->lun !=-1 && dev->lun > bus->info->max_lun) {error_setg (errp,"bad scsi device lun: %d" , dev->lun); -return ; +return false; + } + +if (dev->id !=-1 && dev->lun !=-1 ) { +SCSIDevice *d; +if (!scsi_bus_is_address_free (bus, dev->channel, dev->id, dev->lun, &d)) { +error_setg (errp,"lun already used by '%s'" , d->qdev.id); +return false; + } } +return true; +} + +static void scsi_qdev_realize (DeviceState *qdev,Error **errp) +{ +SCSIDevice *dev =SCSI_DEVICE (qdev); +SCSIBus *bus =DO_UPCAST (SCSIBus, qbus, dev->qdev.parent_bus); +bool is_free; +Error *local_err =NULL ; +if (dev->id ==-1 ) {int id =-1 ;if (dev->lun ==-1 ) { dev->lun =0 ; }do { - d =scsi_device_find (bus, dev->channel, ++id, dev->lun); - }while (d && d->lun == dev->lun && id < bus->info->max_target); -if (d && d->lun == dev->lun) { + is_free =scsi_bus_is_address_free (bus, dev->channel, ++id, dev->lun,NULL ); + }while (!is_free && id < bus->info->max_target); +if (!is_free) {error_setg (errp,"no free target" );return ; }
@@ -196,20 +202,13 @@ static void scsi_qdev_realize(DeviceState *qdev, Error **errp) }else if (dev->lun ==-1 ) {int lun =-1 ;do { - d =scsi_device_find (bus, dev->channel, dev->id, ++lun); - }while (d && d->lun == lun && lun < bus->info->max_lun); -if (d && d->lun == lun) { + is_free =scsi_bus_is_address_free (bus, dev->channel, dev->id, ++lun,NULL ); + }while (!is_free && lun < bus->info->max_lun); +if (!is_free) {error_setg (errp,"no free lun" );return ; } dev->lun = lun; - }else { - d =scsi_device_find (bus, dev->channel, dev->id, dev->lun); -assert (d); -if (d->lun == dev->lun && dev != d) { -error_setg (errp,"lun already used by '%s'" , d->qdev.id); -return ; - } }QTAILQ_INIT (&dev->requests);
@@ -1723,6 +1722,13 @@ const VMStateDescription vmstate_scsi_device = { } }; +static Property scsi_props[] = { +DEFINE_PROP_UINT32 ("channel" , SCSIDevice, channel,0 ), +DEFINE_PROP_UINT32 ("scsi-id" , SCSIDevice, id,-1 ), +DEFINE_PROP_UINT32 ("lun" , SCSIDevice, lun,-1 ), +DEFINE_PROP_END_OF_LIST (), +}; +static void scsi_device_class_init (ObjectClass *klass,void *data) {DeviceClass *k =DEVICE_CLASS (klass);
@@ -1753,6 +1759,28 @@ static const TypeInfo scsi_device_type_info = { .instance_init = scsi_dev_instance_init, }; +static void scsi_bus_class_init (ObjectClass *klass,void *data) +{ +BusClass *k =BUS_CLASS (klass); +HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (klass); + + k->get_dev_path = scsibus_get_dev_path; + k->get_fw_dev_path = scsibus_get_fw_dev_path; + k->check_address = scsi_bus_check_address; + hc->unplug = qdev_simple_device_unplug_cb; +} + +static const TypeInfo scsi_bus_info = { + .name =TYPE_SCSI_BUS , + .parent =TYPE_BUS , + .instance_size =sizeof (SCSIBus), + .class_init = scsi_bus_class_init, + .interfaces = (InterfaceInfo []) { + {TYPE_HOTPLUG_HANDLER }, + { } + } +}; +static void scsi_register_types (void ) {type_register_static (&scsi_bus_info);
Signature · 1 line
2.26.2
[PULL 31/39] device_core: use drain_call_rcu in in qmp_device_add
In reply to Paolo BonziniFrom: Maxim Levitsky <[email protected]>
Soon, a device removal might only happen on RCU callback execution. This is okay for device-del which provides a DEVICE_DELETED event, but not for the failure case of device-add. To avoid changing monitor semantics, just drain all pending RCU callbacks on error.
Message-Id: <[email protected]>
--- softmmu/qdev-monitor.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
softmmu/qdev-monitor.c +12 -0
@@ -803,6 +803,18 @@ void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp)return ; } dev =qdev_device_add (opts, errp); + +/* +* Drain all pending RCU callbacks. This is done because +* some bus related operations can delay a device removal +* (in this case this can happen if device is added and then +* removed due to a configuration error) +* to a RCU callback, but user might expect that this interface +* will finish its job completely once qmp command returns result +* to the user +*/ +drain_call_rcu (); +if (!dev) {qemu_opts_del (opts);return ;
Signature · 1 line
2.26.2
[PULL 37/39] virtio-scsi: use scsi_device_get
In reply to Paolo BonziniFrom: Maxim Levitsky <[email protected]>
This will help us to avoid the scsi device disappearing after we took a reference to it.
It doesn't by itself forbid case when we try to access an unrealized device
Message-Id: <[email protected]>
Message-Id: <[email protected]>
--- hw/scsi/virtio-scsi.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
hw/scsi/virtio-scsi.c +13 -8
@@ -33,7 +33,7 @@ static inline int virtio_scsi_get_lun(uint8_t *lun)return ((lun[2 ] <<8 ) | lun[3 ]) &0x3FFF ; } -static inline SCSIDevice *virtio_scsi_device_find (VirtIOSCSI *s,uint8_t *lun) +static inline SCSIDevice *virtio_scsi_device_get (VirtIOSCSI *s,uint8_t *lun) {if (lun[0 ] !=1 ) {return NULL ;
@@ -41,7 +41,7 @@ static inline SCSIDevice *virtio_scsi_device_find(VirtIOSCSI *s, uint8_t *lun)if (lun[2 ] !=0 && !(lun[2 ] >=0x40 && lun[2 ] <0x80 )) {return NULL ; } -return scsi_device_find (&s->bus,0 , lun[1 ],virtio_scsi_get_lun (lun)); +return scsi_device_get (&s->bus,0 , lun[1 ],virtio_scsi_get_lun (lun)); }void virtio_scsi_init_req (VirtIOSCSI *s,VirtQueue *vq,VirtIOSCSIReq *req)
@@ -256,7 +256,7 @@ static inline void virtio_scsi_ctx_check(VirtIOSCSI *s, SCSIDevice *d)* case of async cancellation. */ static int virtio_scsi_do_tmf (VirtIOSCSI *s,VirtIOSCSIReq *req) { -SCSIDevice *d =virtio_scsi_device_find (s, req->req.tmf.lun); +SCSIDevice *d =virtio_scsi_device_get (s, req->req.tmf.lun);SCSIRequest *r, *next;BusChild *kid;int target;
@@ -370,10 +370,10 @@ static int virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req)rcu_read_lock (); QTAILQ_FOREACH_RCU(kid, &s->bus.qbus.children, sibling) { - d =SCSI_DEVICE (kid->child); -if (d->channel ==0 && d->id == target) { -qdev_reset_all (&d->qdev); - } +SCSIDevice *d1 =SCSI_DEVICE (kid->child); +if (d1->channel ==0 && d1->id == target) { +qdev_reset_all (&d1->qdev); + } }rcu_read_unlock ();
@@ -386,14 +386,17 @@ static int virtio_scsi_do_tmf(VirtIOSCSI *s, VirtIOSCSIReq *req)break ; } +object_unref (OBJECT (d));return ret; incorrect_lun: req->resp.tmf.response =VIRTIO_SCSI_S_INCORRECT_LUN ; +object_unref (OBJECT (d));return ret; fail: req->resp.tmf.response =VIRTIO_SCSI_S_BAD_TARGET ; +object_unref (OBJECT (d));return ret; }
@@ -564,7 +567,7 @@ static int virtio_scsi_handle_cmd_req_prepare(VirtIOSCSI *s, VirtIOSCSIReq *req) } } - d =virtio_scsi_device_find (s, req->req.cmd.lun); + d =virtio_scsi_device_get (s, req->req.cmd.lun);if (!d) { req->resp.cmd.response =VIRTIO_SCSI_S_BAD_TARGET ;virtio_scsi_complete_cmd_req (req);
@@ -580,10 +583,12 @@ static int virtio_scsi_handle_cmd_req_prepare(VirtIOSCSI *s, VirtIOSCSIReq *req) req->sreq->cmd.xfer > req->qsgl.size)) { req->resp.cmd.response =VIRTIO_SCSI_S_OVERRUN ;virtio_scsi_complete_cmd_req (req); +object_unref (OBJECT (d));return -ENOBUFS ; }scsi_req_ref (req->sreq);blk_io_plug (d->conf.blk); +object_unref (OBJECT (d));return 0 ; }
Signature · 1 line
2.26.2
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [PULL 00/39] SCSI, qdev, qtest, meson patches for 2020-10-10
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
- [tag update] patchew/[email protected] -> patchew/[email protected] * [new tag] patchew/[email protected] -> patchew/[email protected] * [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
55f98d2 meson: identify more sections of meson.build
3f959b1 scsi/scsi_bus: fix races in REPORT LUNS
41c759b virtio-scsi: use scsi_device_get
17f4dca scsi/scsi_bus: Add scsi_device_get
eafe5c7 scsi/scsi-bus: scsi_device_find: don't return unrealized devices c8ddbc5 device-core: use atomic_set on .realized property 07df212 scsi: switch to bus->check_address
a7baa24 device-core: use RCU for list of children of a bus bbd9350 device_core: use drain_call_rcu in in qmp_device_add 7cafd84 scsi/scsi_bus: switch search direction in scsi_device_find 9ef1542 qdev: add "check if address free" callback for buses 1d6727d qemu-iotests, qtest: rewrite test 067 as a qtest 96b23e6 qtest: check that drives are really appearing and disappearing a6d906c qtest: switch users back to qtest_qmp_receive
fcf3581 device-plug-test: use qtest_qmp to send the device_del command 3722046 qtest: remove qtest_qmp_receive_success
17077b6 qtest: Reintroduce qtest_qmp_receive
5b850fc qtest: rename qtest_qmp_receive to qtest_qmp_receive_dict 940c32f meson.build: Re-enable KVM support for MIPS
b4cd071 build-sys: fix git version from -version
e81db1e docs/devel: update instruction on how to add new unit tests f187a57 qtest: unify extra_qtest_srcs and extra_qtest_deps 80c356b docs/devel/qtest: Include libqtest API reference ef6b5cb docs/devel/qtest: Include protocol spec in document 7f82ce7 docs: Move QTest documentation to its own document d5fddc0 configure: fix performance regression due to PIC objects 70cd0b9 qom: fix objects with improper parent type
a63dc48 exec: split out non-softmmu-specific parts
6a633f6 softmmu: move more files to softmmu/
32c750b hw/nvram: Always register FW_CFG_DATA_GENERATOR_INTERFACE 85a528c qom: Move the creation of the library to the main meson.build 6d611b1 authz: Move the creation of the library to the main meson.build d597f26 crypto: Move the creation of the library to the main meson.build d44bc2e io: Move the creation of the library to the main meson.build 6f014b0 migration: Move the creation of the library to the main meson.build 9d197f1 chardev: Move the creation of the library to the main meson.build 8b9a449 hw/core: Move the creation of the library to the main meson.build 245f27b meson.build: Sort sourcesets alphabetically
cbc9573 meson.build: Add comments to clarify code organization
=== OUTPUT BEGIN ===
1/39 Checking commit cbc957397c02 (meson.build: Add comments to clarify code organization) 2/39 Checking commit 245f27b24fa7 (meson.build: Sort sourcesets alphabetically)
3/39 Checking commit 8b9a44915aa8 (hw/core: Move the creation of the library to the main meson.build) 4/39 Checking commit 9d197f154484 (chardev: Move the creation of the library to the main meson.build) 5/39 Checking commit 6f014b047dde (migration: Move the creation of the library to the main meson.build) 6/39 Checking commit d44bc2e97f1c (io: Move the creation of the library to the main meson.build) 7/39 Checking commit d597f26a6c94 (crypto: Move the creation of the library to the main meson.build) 8/39 Checking commit 6d611b137d38 (authz: Move the creation of the library to the main meson.build) 9/39 Checking commit 85a528c294eb (qom: Move the creation of the library to the main meson.build) 10/39 Checking commit 32c750b90a9c (hw/nvram: Always register FW_CFG_DATA_GENERATOR_INTERFACE)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#52:
new file mode 100644
total: 0 errors, 1 warnings, 55 lines checked
Patch 10/39 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
11/39 Checking commit 6a633f68ddd7 (softmmu: move more files to softmmu/)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #85:
rename from bootdevice.c
total: 0 errors, 1 warnings, 69 lines checked
Patch 11/39 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
12/39 Checking commit a63dc48247ea (exec: split out non-softmmu-specific parts)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #52:
new file mode 100644
WARNING: Block comments use a leading /* on a separate line #104: FILE: cpu.c:48:
+ /* 0x01 was CPU_INTERRUPT_EXIT. This line can be removed when the
WARNING: Block comments use * on subsequent lines
#105: FILE: cpu.c:49:
+ /* 0x01 was CPU_INTERRUPT_EXIT. This line can be removed when the
+ version_id is increased. */
WARNING: Block comments use a trailing */ on a separate line #105: FILE: cpu.c:49:
+ version_id is increased. */
WARNING: Block comments use a leading /* on a separate line #109: FILE: cpu.c:53:
+ /* loadvm has just updated the content of RAM, bypassing the
ERROR: spaces required around that '*' (ctx:VxV)
#175: FILE: cpu.c:119:
+ .subsections = (const VMStateDescription*[]) {
^WARNING: Block comments use a leading /* on a separate line #205: FILE: cpu.c:149:
+ /* Create a memory property for softmmu CPU object,
WARNING: Block comments use a leading /* on a separate line #393: FILE: cpu.c:337:
+/* enable or disable single step mode. EXCP_DEBUG is returned by the
WARNING: Block comments use * on subsequent lines
#394: FILE: cpu.c:338:
+/* enable or disable single step mode. EXCP_DEBUG is returned by the
+ CPU loop after each instruction */
WARNING: Block comments use a trailing */ on a separate line #394: FILE: cpu.c:338:
+ CPU loop after each instruction */
ERROR: "foo * bar" should be "foo *bar"
#452: FILE: cpu.c:396:
+ void * p;
ERROR: braces {} are necessary for all arms of this statement #458: FILE: cpu.c:402:
+ if (l > len)
[...]
ERROR: braces {} are necessary for all arms of this statement #461: FILE: cpu.c:405:
+ if (!(flags & PAGE_VALID))
[...]
ERROR: braces {} are necessary for all arms of this statement #464: FILE: cpu.c:408:
+ if (!(flags & PAGE_WRITE))
[...]
ERROR: do not use assignment in if condition
#467: FILE: cpu.c:411:
+ if (!(p = lock_user(VERIFY_WRITE, addr, l, 0)))
ERROR: braces {} are necessary for all arms of this statement #467: FILE: cpu.c:411:
+ if (!(p = lock_user(VERIFY_WRITE, addr, l, 0)))
[...]
ERROR: braces {} are necessary for all arms of this statement #472: FILE: cpu.c:416:
+ if (!(flags & PAGE_READ))
[...]
ERROR: do not use assignment in if condition
#475: FILE: cpu.c:419:
+ if (!(p = lock_user(VERIFY_READ, addr, l, 1)))
ERROR: braces {} are necessary for all arms of this statement #475: FILE: cpu.c:419:
+ if (!(p = lock_user(VERIFY_READ, addr, l, 1)))
[...]
WARNING: Block comments use a leading /* on a separate line #499: FILE: cpu.c:443:
+ /* NOTE: we can always suppose that qemu_host_page_size >=
WARNING: Block comments use * on subsequent lines
#500: FILE: cpu.c:444:
+ /* NOTE: we can always suppose that qemu_host_page_size >=
+ TARGET_PAGE_SIZE */
WARNING: Block comments use a trailing */ on a separate line #500: FILE: cpu.c:444:
+ TARGET_PAGE_SIZE */
total: 10 errors, 12 warnings, 1061 lines checked
Patch 12/39 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
13/39 Checking commit 70cd0b9ec467 (qom: fix objects with improper parent type)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #69:
new file mode 100644
total: 0 errors, 1 warnings, 57 lines checked
Patch 13/39 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
14/39 Checking commit d5fddc0cba63 (configure: fix performance regression due to PIC objects) 15/39 Checking commit 7f82ce732ca7 (docs: Move QTest documentation to its own document)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#31:
new file mode 100644
total: 0 errors, 1 warnings, 124 lines checked
Patch 15/39 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
16/39 Checking commit ef6b5cbd233f (docs/devel/qtest: Include protocol spec in document) 17/39 Checking commit 80c356b3fbc1 (docs/devel/qtest: Include libqtest API reference) 18/39 Checking commit f187a576c59c (qtest: unify extra_qtest_srcs and extra_qtest_deps) 19/39 Checking commit e81db1ec6da4 (docs/devel: update instruction on how to add new unit tests) 20/39 Checking commit b4cd071db805 (build-sys: fix git version from -version)
21/39 Checking commit 940c32fa7664 (meson.build: Re-enable KVM support for MIPS) 22/39 Checking commit 5b850fc17469 (qtest: rename qtest_qmp_receive to qtest_qmp_receive_dict) 23/39 Checking commit 17077b686545 (qtest: Reintroduce qtest_qmp_receive)
24/39 Checking commit 372204626c2a (qtest: remove qtest_qmp_receive_success)
25/39 Checking commit fcf3581e19b2 (device-plug-test: use qtest_qmp to send the device_del command)
WARNING: line over 80 characters
#33: FILE: tests/qtest/device-plug-test.c:23:
+ "{'execute': 'device_del', 'arguments': { 'id': %s } }", id);
total: 0 errors, 1 warnings, 76 lines checked
Patch 25/39 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
26/39 Checking commit a6d906ce8819 (qtest: switch users back to qtest_qmp_receive) 27/39 Checking commit 96b23e6b9397 (qtest: check that drives are really appearing and disappearing) 28/39 Checking commit 1d6727dc791e (qemu-iotests, qtest: rewrite test 067 as a qtest)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#46:
deleted file mode 100755
WARNING: line over 80 characters
#650: FILE: tests/qtest/drive_del-test.c:19:
+static bool look_for_drive0(QTestState *qts, const char *command, const char *key)
total: 0 errors, 2 warnings, 309 lines checked
Patch 28/39 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
29/39 Checking commit 9ef154286ce3 (qdev: add "check if address free" callback for buses) 30/39 Checking commit 7cafd8471e6a (scsi/scsi_bus: switch search direction in scsi_device_find) 31/39 Checking commit bbd93507e2d4 (device_core: use drain_call_rcu in in qmp_device_add) 32/39 Checking commit a7baa24616a2 (device-core: use RCU for list of children of a bus) 33/39 Checking commit 07df2121d569 (scsi: switch to bus->check_address)
ERROR: code indent should never use tabs
#55: FILE: hw/scsi/scsi-bus.c:137:
+^I^I^I^I int channel, int target, int lun,$
ERROR: code indent should never use tabs
#56: FILE: hw/scsi/scsi-bus.c:138:
+^I^I^I^I SCSIDevice **p_dev)$
WARNING: line over 80 characters
#71: FILE: hw/scsi/scsi-bus.c:153:
+static bool scsi_bus_check_address(BusState *qbus, DeviceState *qdev, Error **errp)
WARNING: line over 80 characters
#91: FILE: hw/scsi/scsi-bus.c:173:
+ if (!scsi_bus_is_address_free(bus, dev->channel, dev->id, dev->lun, &d)) {
WARNING: line over 80 characters
#130: FILE: hw/scsi/scsi-bus.c:195:
+ is_free = scsi_bus_is_address_free(bus, dev->channel, ++id, dev->lun, NULL);
WARNING: line over 80 characters
#143: FILE: hw/scsi/scsi-bus.c:205:
+ is_free = scsi_bus_is_address_free(bus, dev->channel, dev->id, ++lun, NULL);
total: 2 errors, 4 warnings, 182 lines checked
Patch 33/39 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
34/39 Checking commit c8ddbc5cad10 (device-core: use atomic_set on .realized property) 35/39 Checking commit eafe5c7675d0 (scsi/scsi-bus: scsi_device_find: don't return unrealized devices) 36/39 Checking commit 17f4dca5c0be (scsi/scsi_bus: Add scsi_device_get)
37/39 Checking commit 41c759b9e570 (virtio-scsi: use scsi_device_get)
38/39 Checking commit 3f959b1165c9 (scsi/scsi_bus: fix races in REPORT LUNS)
39/39 Checking commit 55f98d22596c (meson: identify more sections of meson.build)
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Quoted 11 lines · Paolo Bonzini
The following changes since commit
4a7c0bd9dcb08798c6f82e55b5a3423f7ee669f1:Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-5.2-20201009' into staging (2020-10-09 15:48:04 +0100)
are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to
1340ff2adb2624e61c5fcb0eb1889b932b76f669:
Quoted 9 lines
meson: identify more sections of meson.build (2020-10-09 13:19:50 -0400)
----------------------------------------------------------------
* qtest documentation improvements (Eduardo, myself)
* libqtest event buffering (Maxim)
* use RCU for list of children of a bus (Maxim)
* move more files to softmmu/ (myself)
* meson.build cleanups, qemu-storage-daemon fix (Philippe)
This produces a new warning, I think from Sphinx:
Running Sphinx v1.6.7
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date building [html]: targets for 2 source files that are out of date updating environment: 1 added, 2 changed, 0 removed reading sources... [ 33%] index
reading sources... [ 66%] qtest
reading sources... [100%] testing
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [ 33%] index
writing output... [ 66%] qtest
writing output... [100%] testing
generating indices... genindex
writing additional pages... search
copying static files... done
copying extra files... done
dumping search index in English (code: en) ... done
dumping object inventory... done
build succeeded. /home/petmay01/linaro/qemu-for-merges/docs/../tests/qtest/libqos/libqtest.h:241:
warning: Function parameter or member 'event' not described in 'qtest_qmp_event_ref'
make: Leaving directory '/home/petmay01/linaro/qemu-for-merges/build/all'
make: Entering directory '/home/petmay01/linaro/qemu-for-merges/build/all' [build continues and succeeds]
Not sure why it isn't fatal.
thanks
-- PMM
Quoted 7 lines · Peter Maydell
warning: Function parameter or member 'event' not described in '
qtest_qmp_event_ref'
make: Leaving directory '/home/petmay01/linaro/qemu-for-merges/build/all'
make: Entering directory '/home/petmay01/linaro/qemu-for-merges/build/all' [build continues and succeeds]Not sure why it isn't fatal.
I'll fix and resend anyway.
Paolo