The goal is a single binary that links several targets, where every QOM type is
registered once for all of them. Types that share a name go into one bucket per
name, each variant tagged with the targets it serves, and the selected target
picks the variant at lookup time. For that to work, registering a type and
building its class must not depend on which target is selected.
Today some class_init and type_init functions call target_info(), directly or
through helpers such as target_s390x(). The result is fixed for the one target
selected when the class is built, so the other targets never get their own form
of that type.
max-v8 called target_aarch64() from its type_init to pick an instance
initializer. scsi-hd, scsi-cd, virtio-blk-pci, virtio-net-pci and virtio-mem
called target_s390x() or target_arch() from class_init to add properties. The
PetaLogix machine called target_big_endian() from class_init to set the default
endianness.
Instead, each target-specific form becomes its own TypeInfo under the same name.
Its is_available callback says which target it belongs to. Today QOM registers
only the one that matches; a bucket can later keep all of them. LoongArch and
Xtensa virt machines are handled the same way, since both share the virt-machine
name. PetaLogix keeps one type: its endianness default is "unspecified" until
the machine starts. A few target_*() helpers are added for the new callbacks.
Yonggang Luo (12):
target-info: add target_loongarch()
hw/loongarch/virt: select virt machine types with is_available
target-info: add target_xtensa()
hw/xtensa/virt: select virt machine types with is_available
target/arm: register separate max-v8 CPU types for arm and aarch64
target-info: add target_not_s390x()
hw/scsi/scsi-disk: register s390x scsi-hd and scsi-cd variants
hw/virtio/virtio-pci: pass is_available through
VirtioPCIDeviceTypeInfo
hw/virtio: register s390x virtio-blk-pci and virtio-net-pci variants
target-info: add target_base_i386() and target_not_base_i386()
hw/virtio/virtio-mem: register legacy-guest variant with is_available
hw/microblaze: defer PetaLogix endianness default until init
hw/loongarch/virt.c | 3 ++
hw/microblaze/petalogix_s3adsp1800_mmu.c | 11 ++++--
hw/pci/pci.c | 13 +++----
hw/scsi/scsi-disk.c | 43 +++++++++++++++++-----
hw/virtio/virtio-blk-pci.c | 22 ++++++++++-
hw/virtio/virtio-mem.c | 47 ++++++++++++++----------
hw/virtio/virtio-net-pci.c | 22 ++++++++++-
hw/virtio/virtio-pci.c | 4 ++
hw/xtensa/virt.c | 21 ++++++++++-
include/hw/virtio/virtio-mem.h | 2 +
include/hw/virtio/virtio-pci.h | 1 +
include/qemu/target-info.h | 35 ++++++++++++++++++
target-info.c | 37 +++++++++++++++++++
target/arm/cpu.c | 1 +
target/arm/cpu.h | 1 +
target/arm/tcg/cpu-max-v8.c | 16 ++++++--
16 files changed, 231 insertions(+), 48 deletions(-)
--
2.55.0.windows.3