qemu/hw/core
Peter Maydell bb09b7bfd3 hw/core/machine.c: Make -machine dumpdtb=file.dtb with no DTB an error
Currently if the user requests via -machine dumpdtb=file.dtb that we
dump the DTB, but the machine doesn't have a DTB, we silently ignore
the option.  This is confusing to users, and is a legacy of the old
board-specific implementation of the option, where if the execution
codepath didn't go via a call to qemu_fdt_dumpdtb() we would never
handle the option.

Now we handle the option in one place in machine.c, we can provide
the user with a useful message if they asked us to dump a DTB when
none exists.  qmp_dumpdtb() already produces this error; remove the
logic in handle_machine_dumpdtb() that was there specifically to
avoid hitting it.

While we're here, beef up the error message a bit with a hint, and
make it consistent about "an FDT" rather than "a FDT".  (In the
qmp_dumpdtb() case this needs an ERRP_GUARD to make
error_append_hint() work when the caller passes error_fatal.)

Note that the three places where we might report "doesn't have an
FDT" are hit in different situations:

(1) in handle_machine_dumpdtb(), if CONFIG_FDT is not set: this is
because the QEMU binary was built without libfdt at all. The
build system will not let you build with a machine type that
needs an FDT but no libfdt, so here we know both that the machine
doesn't use FDT and that QEMU doesn't have the support:

(2) in the device_tree-stub.c qmp_dumpdtb(): this is used when
we had libfdt at build time but the target architecture didn't
enable any machines which did "select DEVICE_TREE", so here we
know that the machine doesn't use FDT.

(3) in qmp_dumpdtb(), if current_machine->fdt is NULL all we know
is that this machine never set it. That might be because it doesn't
use FDT, or it might be because the user didn't pass an FDT
on the command line and the machine doesn't autogenerate an FDT.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2733
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20250206151214.2947842-7-peter.maydell@linaro.org
2025-02-25 15:32:57 +00:00
..
bus.c hw/core: Remove transitional infrastructure from BusClass 2024-02-02 13:51:57 +00:00
clock-vmstate.c hw/core: Constify VMState 2023-12-29 11:17:30 +11:00
clock.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
cpu-common.c cpu: Remove nr_cores from struct CPUState 2025-01-10 23:34:45 +01:00
cpu-system.c physmem: teach cpu_memory_rw_debug() to write to more memory regions 2025-02-12 11:33:13 -05:00
eif.c hw/core/eif: Use stateful qcrypto apis 2024-12-13 15:26:58 +01:00
eif.h hw/core: Add Enclave Image Format (EIF) related helpers 2024-10-31 18:28:32 +01:00
fw-path-provider.c Include qemu/module.h where needed, drop it from qemu-common.h 2019-06-12 13:18:33 +02:00
generic-loader.c hw/loader: Pass ELFDATA endian order argument to load_elf_as() 2025-01-31 19:36:44 +01:00
gpio.c qdev: Use machine_get_container() 2025-01-09 18:16:24 +01:00
guest-loader.c Accel & Exec patch queue 2024-12-21 11:07:00 -05:00
guest-loader.h hw/core: implement a guest-loader to support static hypervisor guests 2021-03-10 15:34:11 +00:00
hotplug.c call HotplugHandler->plug() as the last step in device realization 2018-10-19 13:44:12 +02:00
irq.c hw/irq: Introduce qemu_init_irqs() helper 2025-01-31 19:36:44 +01:00
Kconfig hw/core: Add Enclave Image Format (EIF) related helpers 2024-10-31 18:28:32 +01:00
loader-fit.c hw/mips/boston: Support dumpdtb monitor commands 2025-02-24 15:03:42 +00:00
loader.c memory: pass MemTxAttrs to memory_access_is_direct() 2025-02-12 11:33:05 -05:00
machine-hmp-cmds.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
machine-qmp-cmds.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
machine-smp.c hw/core/machine: Reject thread level cache 2025-02-16 14:25:07 +01:00
machine.c hw/core/machine.c: Make -machine dumpdtb=file.dtb with no DTB an error 2025-02-25 15:32:57 +00:00
meson.build qdev: Implement qdev_create_fake_machine() for user emulation 2025-01-09 18:16:24 +01:00
nmi.c hw/core: Improve error message when machine doesn't provide NMIs 2023-02-23 14:10:17 +01:00
null-machine.c hw/boards: Rename no_sdcard -> auto_create_sdcard 2025-02-16 14:25:08 +01:00
numa.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
or-irq.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
platform-bus.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
ptimer.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
qdev-clock.c clock: inline most of qdev_init_clocklist 2024-12-10 18:49:24 +01:00
qdev-fw.c Include hw/qdev-properties.h less 2019-08-16 13:31:53 +02:00
qdev-hotplug.c hw/qdev: Check machine_hotplug_handler in hotplug_unplug_allowed_common 2025-01-13 17:16:03 +01:00
qdev-prop-internal.h qdev: Make qdev_propinfo_get_uint16() static 2020-12-15 10:02:07 -05:00
qdev-properties-system.c hw/qdev-properties-system: Introduce EndianMode QAPI enum 2025-02-16 14:33:39 +01:00
qdev-properties.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
qdev-user.c qdev: Implement qdev_create_fake_machine() for user emulation 2025-01-09 18:16:24 +01:00
qdev.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
register.c hw/core/register: Add more 64-bit utilities 2021-09-01 11:59:12 +10:00
reset.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
resetcontainer.c hw/core: Add ResetContainer which holds objects implementing Resettable 2024-02-27 13:01:42 +00:00
resettable.c hw/core/resettable: Remove transitional_function machinery 2024-09-13 15:31:46 +01:00
split-irq.c include/hw/qdev-properties: Remove DEFINE_PROP_END_OF_LIST 2024-12-19 19:36:37 +01:00
stream.c hw/core/stream: Rename StreamSlave as StreamSink 2020-12-10 12:15:04 -05:00
sysbus-fdt.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
sysbus.c hw/sysbus: Introduce TYPE_DYNAMIC_SYS_BUS_DEVICE 2025-02-16 14:25:07 +01:00
trace-events trace-events: remove the remaining vcpu trace events 2023-06-01 11:05:05 -04:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
uboot_image.h license: Update deprecated SPDX tag GPL-2.0+ to GPL-2.0-or-later 2024-09-20 10:11:59 +03:00
vm-change-state-handler.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
vmstate-if.c vmstate: add qom interface to get id 2020-01-06 18:41:32 +04:00