Skip to content

refactor PC machine, i440fx and piix3 to take advantage of QOM

Wanpeng Li qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 35 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6eliminate piix_pci.c and module i440fx and piix3Makefile.target hw/i440fx.c hw/i440fx.h +3 more+863 -6010 replies
2/6convert MemoryRegion to QOMmemory.c memory.h+78 -240 replies
3/6convert pci-host to QOMhw/pci_host.c hw/pci_host.h+31 -03 replies
4/6prepare to create HPET, RTC and i8254 through compositionhw/hpet.c hw/hpet_emul.h hw/i8254_internal.h +2 more+73 -640 replies
5/6merge pc_piix.c to pc.cMakefile.target hw/pc.c hw/pc.h +1 more+739 -8603 replies
6/6make some functions statichw/pc.c hw/pc.h+11 -370 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [Qemu-devel] [PATCH 0/6] refactor PC machine, i440fx and piix3 to take advantage of QOM

From: Anthony Liguori <[email protected]>

This series aggressively refactors the PC machine initialization to be more modelled and less ad-hoc. The highlights of this series are:

1) Things like -m and -bios-name are now device model properties

2) The i440fx and piix3 are now modelled in a thorough fashion

3) Most of the chipset features of the piix3 are modelled through composition

4) i440fx_init is trivialized to creating devices and setting properties

5) convert MemoryRegion to QOM

6) convert PCI host bridge to QOM

The point (4) is the most important one. As we refactor in this fashion, we should quickly get to the point where machine->init disappears completely in favor of just creating a handful of devices.

The two stage initialization of QOM is important here. instance_init() is when composed devices are created which means that after you've created a device, all of its children are visible in the device model. This lets you set properties of the parent and its children.

realize() (which is still called DeviceState::init today) will be called right before the guest starts up for the first time.

---
 Makefile.target     |    3 +-
 hw/hpet.c           |   39 +---
 hw/hpet_emul.h      |   41 +++
 hw/i440fx.c         |  431 ++++++++++++++++++++++++++
 hw/i440fx.h         |   78 +++++
 hw/i8254_internal.h |    2 +-
 hw/mc146818rtc.c    |   26 --
 hw/mc146818rtc.h    |   29 ++
 hw/pc.c             |  838 +++++++++++++++++++++++++++++++++++++++++++++------
 hw/pc.h             |   46 +---
 hw/pc_piix.c        |  762 ----------------------------------------------
 hw/pci_host.c       |   26 ++
 hw/pci_host.h       |    5 +
 hw/piix3.c          |  274 +++++++++++++++++
 hw/piix3.h          |   79 +++++
 hw/piix_pci.c       |  600 ------------------------------------
 memory.c            |   94 +++++--
 memory.h            |    8 +
 18 files changed, 1795 insertions(+), 1586 deletions(-)
 create mode 100644 hw/i440fx.c
 create mode 100644 hw/i440fx.h
 delete mode 100644 hw/pc_piix.c
 create mode 100644 hw/piix3.c
 create mode 100644 hw/piix3.h
 delete mode 100644 hw/piix_pci.c

--