qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] hw: Centralize handling, improve error messages for -machine dumpdtb
@ 2025-02-06 15:12 Peter Maydell
  2025-02-06 15:12 ` [PATCH 1/6] monitor/hmp-cmds.c: Clean up hmp_dumpdtb printf Peter Maydell
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: Peter Maydell @ 2025-02-06 15:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paul Burton, Aleksandar Rikalo, Eduardo Habkost, Marcel Apfelbaum,
	Philippe Mathieu-Daudé, Yanan Wang, Zhao Liu, Jia Liu

We originally implemented '-machine dumpdtb' in a fairly ad-hoc way:
every machine using FDT is supposed to call qemu_fdt_dumpdtb() once
it has finished creating and modifying the DTB; if the user passed in
the machine option then qemu_fdt_dumpdtb() will write the FDT to a
file and then exit QEMU.

Somewhat later we implemented the QMP and HMP dumpdtb commands; for
these to work we had to make all the FDT-using machines set
MachineState::fdt to point to the FDT blob.

This means we can clean up the handling of the -machine option, so we
can implement it in one place in machine.c.  The benefit of this is:
 * boards only need to do one thing, not two
 * we can have better error messages for the "user asked us to
   dump the DTB but this board doesn't have one" case

(In particular the bug report
https://gitlab.com/qemu-project/qemu/-/issues/2733
is essentially because we silently ignore the option if there
is no DTB to dump.)

The openrisc machines and the MIPS boston machine both were not
setting MachineState::fdt, so the HMP/QMP dumpdtb don't work for
those machines; the series starts by fixing those bugs.  Then we can
implement the centralized handling of the machine option.  Finally we
get to fix the "no error message" problem:

 $ qemu-system-aarch64 -M raspi4b,dumpdtb=/tmp/d.dtb
 qemu-system-aarch64: This machine doesn't have an FDT
 (Perhaps it doesn't support FDT at all, or perhaps you need to
 provide an FDT with the -fdt option?)

The fact that there are three places that report "this machine
doesn't have an FDT" is a bit of a wart, stemming largely from the
fact that the QMP dumpdtb command is only conditionally present if
CONFIG_FDT.  In theory we could make it unconditional, but I opted to
leave that can of worms for another day...

thanks
-- PMM

Peter Maydell (6):
  monitor/hmp-cmds.c: Clean up hmp_dumpdtb printf
  hw/openrisc: Support monitor dumpdtb command
  hw/mips/boston: Check for error return from boston_fdt_filter()
  hw/mips/boston: Support dumpdtb monitor commands
  hw: Centralize handling of -machine dumpdtb option
  hw/core/machine.c: Make -machine dumpdtb=file.dtb with no DTB an error

 include/hw/loader-fit.h      | 21 +++++++++++++++++---
 include/hw/openrisc/boot.h   |  3 ++-
 include/system/device_tree.h |  2 --
 hw/arm/boot.c                |  2 --
 hw/core/loader-fit.c         | 38 ++++++++++++++++++++----------------
 hw/core/machine.c            | 23 ++++++++++++++++++++++
 hw/loongarch/virt.c          |  1 -
 hw/mips/boston.c             | 16 ++++++++++-----
 hw/openrisc/boot.c           |  8 +++++---
 hw/openrisc/openrisc_sim.c   |  2 +-
 hw/openrisc/virt.c           |  2 +-
 hw/ppc/e500.c                |  1 -
 hw/ppc/pegasos2.c            |  1 -
 hw/ppc/pnv.c                 |  1 -
 hw/ppc/spapr.c               |  1 -
 hw/riscv/boot.c              |  2 --
 monitor/hmp-cmds.c           |  2 +-
 system/device_tree-stub.c    |  5 ++++-
 system/device_tree.c         | 22 ++++++---------------
 19 files changed, 93 insertions(+), 60 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2025-02-24 14:51 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-06 15:12 [PATCH 0/6] hw: Centralize handling, improve error messages for -machine dumpdtb Peter Maydell
2025-02-06 15:12 ` [PATCH 1/6] monitor/hmp-cmds.c: Clean up hmp_dumpdtb printf Peter Maydell
2025-02-06 20:46   ` Richard Henderson
2025-02-10 10:57   ` Philippe Mathieu-Daudé
2025-02-06 15:12 ` [PATCH 2/6] hw/openrisc: Support monitor dumpdtb command Peter Maydell
2025-02-06 20:48   ` Richard Henderson
2025-02-10 10:57   ` Philippe Mathieu-Daudé
2025-02-06 15:12 ` [PATCH 3/6] hw/mips/boston: Check for error return from boston_fdt_filter() Peter Maydell
2025-02-10 10:48   ` Philippe Mathieu-Daudé
2025-02-06 15:12 ` [PATCH 4/6] hw/mips/boston: Support dumpdtb monitor commands Peter Maydell
2025-02-10 10:56   ` Philippe Mathieu-Daudé
2025-02-10 11:09     ` Peter Maydell
2025-02-10 11:37       ` Philippe Mathieu-Daudé
2025-02-06 15:12 ` [PATCH 5/6] hw: Centralize handling of -machine dumpdtb option Peter Maydell
2025-02-06 20:51   ` Richard Henderson
2025-02-06 15:12 ` [PATCH 6/6] hw/core/machine.c: Make -machine dumpdtb=file.dtb with no DTB an error Peter Maydell
2025-02-06 20:52   ` Richard Henderson
2025-02-24 14:50 ` [PATCH 0/6] hw: Centralize handling, improve error messages for -machine dumpdtb Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).