@samitouri / QOSamiQemu / commits / a16d4c2f16

ppc/pnv: fix dumpdtb option

The '-machine dumpdtb' command line option stopped working on PowerPC/pnv systems after recent design change [1]. Fixing this by generating fdt blob in `pnv_init`. [1] https://lore.kernel.org/qemu-devel/20250206151214.2947842-1-peter.maydell@linaro.org/ Cc: Aditya Gupta <adityag@linux.ibm.com> Cc: Harsh Prateek Bora <harshpb@linux.ibm.com> Cc: Peter Maydell <peter.maydell@linaro.org> Cc: BALATON Zoltan <balaton@eik.bme.hu> Cc: qemu-stable@nongnu.org Fixes: 8fd2518ef2f8d34 ("hw: Centralize handling of -machine dumpdtb option") Signed-off-by: Shivang Upadhyay <shivangu@linux.ibm.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Aditya Gupta <adityag@linux.ibm.com> Link: https://lore.kernel.org/qemu-devel/20260311143549.118720-1-shivangu@linux.ibm.com Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>

Shivang Upadhyay committed Mar 11, 2026 at 20:05 UTC a16d4c2f162a86db1f84ef0836d42eabaf57fe69
1 file changed +6 -19
hw/ppc/pnv.c
+6 -19
@@ -773,26 +773,8 @@ static void pnv_reset(MachineState *machine, ResetType type)
773 }
774 }
775
776 - if (machine->fdt) {
777 - fdt = machine->fdt;
778 - } else {
779 - fdt = pnv_dt_create(machine);
780 - /* Pack resulting tree */
781 - _FDT((fdt_pack(fdt)));
782 - }
783 -
776 + fdt = machine->fdt;
777 cpu_physical_memory_write(PNV_FDT_ADDR, fdt, fdt_totalsize(fdt));
785 -
786 - /* Update machine->fdt with latest fdt */
787 - if (machine->fdt != fdt) {
788 - /*
789 - * Set machine->fdt for 'dumpdtb' QMP/HMP command. Free
790 - * the existing machine->fdt to avoid leaking it during
791 - * a reset.
792 - */
793 - g_free(machine->fdt);
794 - machine->fdt = fdt;
795 - }
778 }
779
780 static ISABus *pnv_chip_power8_isa_create(PnvChip *chip, Error **errp)
@@ -1261,6 +1243,11 @@ static void pnv_init(MachineState *machine)
1243 if (pmc->i2c_init) {
1244 pmc->i2c_init(pnv);
1245 }
1246 +
1247 + if (!machine->fdt) {
1248 + machine->fdt = pnv_dt_create(machine);
1249 + _FDT((fdt_pack(machine->fdt)));
1250 + }
1251 }
1252
1253 /*