qemu-e2k/hw/i386
Markus Armbruster ebc29e1bea pc: Support firmware configuration with -blockdev
The PC machines put firmware in ROM by default.  To get it put into
flash memory (required by OVMF), you have to use -drive
if=pflash,unit=0,... and optionally -drive if=pflash,unit=1,...

Why two -drive?  This permits setting up one part of the flash memory
read-only, and the other part read/write.  It also makes upgrading
firmware on the host easier.  Below the hood, it creates two separate
flash devices, because we were too lazy to improve our flash device
models to support sector protection.

The problem at hand is to do the same with -blockdev somehow, as one
more step towards deprecating -drive.

Mapping -drive if=none,... to -blockdev is a solved problem.  With
if=T other than if=none, -drive additionally configures a block device
frontend.  For non-onboard devices, that part maps to -device.  Also a
solved problem.  For onboard devices such as PC flash memory, we have
an unsolved problem.

This is actually an instance of a wider problem: our general device
configuration interface doesn't cover onboard devices.  Instead, we have
a zoo of ad hoc interfaces that are much more limited.  One of them is
-drive, which we'd rather deprecate, but can't until we have suitable
replacements for all its uses.

Sadly, I can't attack the wider problem today.  So back to the narrow
problem.

My first idea was to reduce it to its solved buddy by using pluggable
instead of onboard devices for the flash memory.  Workable, but it
requires some extra smarts in firmware descriptors and libvirt.  Paolo
had an idea that is simpler for libvirt: keep the devices onboard, and
add machine properties for their block backends.

The implementation is less than straightforward, I'm afraid.

First, block backend properties are *qdev* properties.  Machines can't
have those, as they're not devices.  I could duplicate these qdev
properties as QOM properties, but I hate that.

More seriously, the properties do not belong to the machine, they
belong to the onboard flash devices.  Adding them to the machine would
then require bad magic to somehow transfer them to the flash devices.
Fortunately, QOM provides the means to handle exactly this case: add
alias properties to the machine that forward to the onboard devices'
properties.

Properties need to be created in .instance_init() methods.  For PC
machines, that's pc_machine_initfn().  To make alias properties work,
we need to create the onboard flash devices there, too.  Requires
several bug fixes, in the previous commits.  We also have to realize
the devices.  More on that below.

If the user sets pflash0, firmware resides in flash memory.
pc_system_firmware_init() maps and realizes the flash devices.

Else, firmware resides in ROM.  The onboard flash devices aren't used
then.  pc_system_firmware_init() destroys them unrealized, along with
the alias properties.

The existing code to pick up drives defined with -drive if=pflash is
replaced by code to desugar into the machine properties.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <87ftrtux81.fsf@dusky.pond.sub.org>
2019-03-11 22:54:26 +01:00
..
kvm ioapic: use TYPE_FOO MACRO than constant string 2019-01-09 11:33:47 +01:00
xen xen: introduce new 'XenBus' and 'XenDevice' object hierarchy 2019-01-14 13:45:40 +00:00
Kconfig i386-softmmu.mak: remove all CONFIG_* except boards definitions 2019-03-07 21:45:53 +01:00
Makefile.objs i386: express dependencies with Kconfig 2019-03-07 21:45:53 +01:00
acpi-build.c i386, acpi: cleanup build_facs by removing second unused argument 2019-02-05 10:58:33 -05:00
acpi-build.h Use scripts/clean-includes to drop redundant qemu/typedefs.h 2016-03-22 22:20:16 +01:00
amd_iommu.c update copyright notice 2019-03-11 16:33:49 +01:00
amd_iommu.h update copyright notice 2019-03-11 16:33:49 +01:00
intel_iommu.c intel_iommu: reset intr_enabled when system reset 2019-02-05 10:58:33 -05:00
intel_iommu_internal.h intel_iommu: dma read/write draining support 2018-12-19 16:48:16 -05:00
kvmvapic.c target: Do not include "exec/exec-all.h" if it is not necessary 2018-06-01 14:15:10 +02:00
multiboot.c elf: Add optional function ptr to load_elf() to parse ELF notes 2019-02-05 16:50:16 +01:00
multiboot.h refer to FWCfgState explicitly 2013-06-02 18:14:02 +03:00
pc.c pc: Support firmware configuration with -blockdev 2019-03-11 22:54:26 +01:00
pc_piix.c boards.h: Ignore migration for SMBus devices on older machines 2019-02-27 21:06:08 -06:00
pc_q35.c boards.h: Ignore migration for SMBus devices on older machines 2019-02-27 21:06:08 -06:00
pc_sysfw.c pc: Support firmware configuration with -blockdev 2019-03-11 22:54:26 +01:00
trace-events intel_iommu: convert invalid traces into error reports 2018-12-19 16:48:16 -05:00
vmmouse.c hw/input/i8042: Extract declarations from i386/pc.h into input/i8042.h 2018-03-12 16:12:48 +01:00
vmport.c hw/input/i8042: Extract declarations from i386/pc.h into input/i8042.h 2018-03-12 16:12:48 +01:00
x86-iommu.c x86-iommu: turn on IR by default if proper 2018-12-20 13:25:11 -05:00