qemu-patch-raspberry4/hw
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
..
9pfs virtio: express virtio dependencies with Kconfig 2019-03-07 21:45:53 +01:00
acpi i386-softmmu.mak: remove all CONFIG_* except boards definitions 2019-03-07 21:45:53 +01:00
adc kconfig: introduce kconfig files 2019-03-07 21:45:53 +01:00
alpha - qtest fixes 2019-03-08 16:31:34 +00:00
arm pflash: Clean up after commit 368a354f02, part 2 2019-03-11 22:53:44 +01:00
audio i2c: express dependencies with Kconfig 2019-03-07 21:45:53 +01:00
block pflash_cfi01: Add pflash_cfi01_get_blk() helper 2019-03-11 22:53:44 +01:00
bt kconfig: introduce kconfig files 2019-03-07 21:45:53 +01:00
char virtio: express virtio dependencies with Kconfig 2019-03-07 21:45:53 +01:00
core sysbus: Fix latent bug with onboard devices 2019-03-11 22:53:44 +01:00
cpu kconfig: introduce kconfig files 2019-03-07 21:45:53 +01:00
cris cris-softmmu.mak: express dependencies with Kconfig 2019-03-07 21:46:19 +01:00
display hw/display: Add basic ATI VGA emulation 2019-03-11 08:04:55 +01:00
dma isa: express dependencies with kconfig 2019-03-07 21:45:53 +01:00
gpio i2c: express dependencies with Kconfig 2019-03-07 21:45:53 +01:00
hppa - qtest fixes 2019-03-08 16:31:34 +00:00
hyperv hyperv: express dependencies with kconfig 2019-03-07 21:45:53 +01:00
i2c display: express dependencies with kconfig 2019-03-07 21:45:53 +01:00
i386 pc: Support firmware configuration with -blockdev 2019-03-11 22:54:26 +01:00
ide isa: express dependencies with kconfig 2019-03-07 21:45:53 +01:00
input virtio: express virtio dependencies with Kconfig 2019-03-07 21:45:53 +01:00
intc - qtest fixes 2019-03-08 16:31:34 +00:00
ipack build: convert pci.mak to Kconfig 2019-03-07 21:45:53 +01:00
ipmi ipmi: express dependencies with kconfig 2019-03-07 21:45:53 +01:00
isa isa: express SuperIO dependencies with Kconfig 2019-03-07 21:45:53 +01:00
lm32 pflash: Clean up after commit 368a354f02, part 2 2019-03-11 22:53:44 +01:00
m68k m68k-softmmu.mak: express dependencies with Kconfig 2019-03-07 21:46:19 +01:00
mem ppc64: Express dependencies of 'pseries' and 'powernv' machines with kconfig 2019-03-07 21:45:53 +01:00
microblaze pflash: Clean up after commit 368a354f02, part 2 2019-03-11 22:53:44 +01:00
mips pflash: Clean up after commit 368a354f02, part 2 2019-03-11 22:53:44 +01:00
misc sparc-softmmu.mak: express dependencies with Kconfig 2019-03-07 21:46:19 +01:00
moxie moxie-softmmu.mak: express dependencies with Kconfig 2019-03-07 21:46:19 +01:00
net - qtest fixes 2019-03-08 16:31:34 +00:00
nios2 nios2-softmmu.mak: express dependencies with Kconfig 2019-03-07 21:46:19 +01:00
nvram i2c: express dependencies with Kconfig 2019-03-07 21:45:53 +01:00
openrisc or1k-softmmu.mak: express dependencies with Kconfig 2019-03-07 21:46:19 +01:00
pci build: convert pci.mak to Kconfig 2019-03-07 21:45:53 +01:00
pci-bridge i386-softmmu.mak: remove all CONFIG_* except boards definitions 2019-03-07 21:45:53 +01:00
pci-host ppc: Express dependencies of the Mac machines with kconfig 2019-03-07 21:46:19 +01:00
pcmcia kconfig: introduce kconfig files 2019-03-07 21:45:53 +01:00
ppc pflash: Clean up after commit 368a354f02, part 2 2019-03-11 22:53:44 +01:00
rdma hw/rdma: modify struct initialization 2019-01-19 11:01:33 +02:00
riscv riscv/Kconfig: enable PCI_DEVICES 2019-03-11 16:33:49 +01:00
s390x s390x: express dependencies with Kconfig 2019-03-07 21:46:19 +01:00
scsi lsi: 810/895A are always little endian 2019-03-11 16:33:49 +01:00
sd sd: express dependencies with kconfig 2019-03-07 21:45:53 +01:00
sh4 pflash: Clean up after commit 368a354f02, part 2 2019-03-11 22:53:44 +01:00
smbios kconfig: introduce kconfig files 2019-03-07 21:45:53 +01:00
sparc sparc-softmmu.mak: express dependencies with Kconfig 2019-03-07 21:46:19 +01:00
sparc64 sparc64-softmmu.mak: express dependencies with Kconfig 2019-03-07 21:46:19 +01:00
ssi ssi: express dependencies with kconfig 2019-03-07 21:45:53 +01:00
timer i386-softmmu.mak: remove all CONFIG_* except boards definitions 2019-03-07 21:45:53 +01:00
tpm tpm: express dependencies with Kconfig 2019-03-07 21:45:53 +01:00
tricore - qtest fixes 2019-03-08 16:31:34 +00:00
unicore32 unicore32-softmmu.mak: express dependencies with Kconfig 2019-03-07 21:46:19 +01:00
usb - qtest fixes 2019-03-08 16:31:34 +00:00
vfio vfio-pci: enable by default 2019-03-11 14:45:10 +01:00
virtio virtio: add class_size to VirtioPCIDeviceTypeInfo 2019-03-11 08:04:12 +01:00
watchdog ptimer: express dependencies with Kconfig 2019-03-07 21:45:53 +01:00
xen xen: fix xen-bus state model to allow frontend re-connection 2019-02-04 11:04:49 +00:00
xenpv xen: Replace few mentions of xend by libxl 2019-01-14 13:45:40 +00:00
xtensa hw: Use PFLASH_CFI0{1,2} and TYPE_PFLASH_CFI0{1,2} 2019-03-11 22:53:44 +01:00
Kconfig ptimer: express dependencies with Kconfig 2019-03-07 21:45:53 +01:00
Makefile.objs i2c: express dependencies with Kconfig 2019-03-07 21:45:53 +01:00