qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

xen: cleanup unrealized flash devices

The generic pc_machine_initfn() calls pc_system_flash_create() which creates
'system.flash0' and 'system.flash1' devices. These devices are then realized
by pc_system_flash_map() which is called from pc_system_firmware_init() which
itself is called via pc_memory_init(). The latter however is not called when
xen_enable() is true and hence the following assertion fails:

qemu-system-i386: hw/core/qdev.c:439: qdev_assert_realized_properly:
Assertion `dev->realized' failed

These flash devices are unneeded when using Xen so this patch avoids the
assertion by simply removing them using pc_system_flash_cleanup_unused().

Reported-by: Jason Andryuk <jandryuk@gmail.com>
Fixes: ebc29e1beab0 ("pc: Support firmware configuration with -blockdev")
Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Tested-by: Jason Andryuk <jandryuk@gmail.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200624121841.17971-3-paul@xen.org>
Fixes: dfe8c79c4468 ("qdev: Assert onboard devices all get realized properly")
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>

authored by

Paul Durrant and committed by
Anthony PERARD
dd29b5c3 104a7f4e

+8 -4
+6 -3
hw/i386/pc_piix.c
··· 186 186 if (!xen_enabled()) { 187 187 pc_memory_init(pcms, system_memory, 188 188 rom_memory, &ram_memory); 189 - } else if (machine->kernel_filename != NULL) { 190 - /* For xen HVM direct kernel boot, load linux here */ 191 - xen_load_linux(pcms); 189 + } else { 190 + pc_system_flash_cleanup_unused(pcms); 191 + if (machine->kernel_filename != NULL) { 192 + /* For xen HVM direct kernel boot, load linux here */ 193 + xen_load_linux(pcms); 194 + } 192 195 } 193 196 194 197 gsi_state = pc_gsi_create(&x86ms->gsi, pcmc->pci_enabled);
+1 -1
hw/i386/pc_sysfw.c
··· 108 108 } 109 109 } 110 110 111 - static void pc_system_flash_cleanup_unused(PCMachineState *pcms) 111 + void pc_system_flash_cleanup_unused(PCMachineState *pcms) 112 112 { 113 113 char *prop_name; 114 114 int i;
+1
include/hw/i386/pc.h
··· 186 186 187 187 /* pc_sysfw.c */ 188 188 void pc_system_flash_create(PCMachineState *pcms); 189 + void pc_system_flash_cleanup_unused(PCMachineState *pcms); 189 190 void pc_system_firmware_init(PCMachineState *pcms, MemoryRegion *rom_memory); 190 191 191 192 /* acpi-build.c */