Skip to content

qom: resolve type name conflicts, avoid target_info() in class_init or type_init

Yonggang Luo qemu-arm qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest12 patches 15 repliesIn review
  2. v112 patches 15 repliesSuperseded

Changes in v2 from the cover letter

- Drop target_not_s390x() from target-info. v1 exported it for scsi-disk, virtio-blk-pci, and virtio-net-pci. Each file keeps a static copy
- Drop target_not_base_i386() from target-info. Keep target_base_i386(), and a static target_not_base_i386() in virtio-mem
- Split hw/xtensa/virt: select virt machine types with is_available out of the DEFINE_MACHINE expansion, so later only that small patch needs a revert

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12target-info: add target_loongarch()include/qemu/target-info.h target-info.c+12 -00 replies
2/12hw/loongarch/virt: select virt machine types with is_availablehw/loongarch/virt.c+3 -00 replies
3/12target-info: add target_xtensa()include/qemu/target-info.h target-info.c+18 -00 replies
4/12hw/xtensa: expand DEFINE_MACHINE in virt.chw/xtensa/virt.c+16 -21 reply
5/12hw/xtensa/virt: select virt machine types with is_availablehw/xtensa/virt.c+2 -00 replies
6/12target/arm: register separate max-v8 CPU types for arm and aarch64target/arm/cpu.c target/arm/cpu.h target/arm/tcg/cpu-max-v8.c+14 -49 replies
7/12hw/scsi/scsi-disk: register s390x scsi-hd and scsi-cd variantshw/scsi/scsi-disk.c+38 -101 reply
8/12hw/virtio/virtio-pci: pass is_available through VirtioPCIDeviceTypeInfohw/virtio/virtio-pci.c include/hw/virtio/virtio-pci.h+5 -00 replies
9/12hw/virtio: register s390x virtio-blk-pci and virtio-net-pci variantshw/pci/pci.c hw/virtio/virtio-blk-pci.c hw/virtio/virtio-net-pci.c+57 -103 replies
10/12target-info: add target_base_i386()include/qemu/target-info.h target-info.c+18 -00 replies
11/12hw/virtio/virtio-mem: register legacy-guest variant with is_availablehw/virtio/virtio-mem.c include/hw/virtio/virtio-mem.h+34 -201 reply
12/12hw/microblaze: defer PetaLogix endianness default until inithw/microblaze/petalogix_s3adsp1800_mmu.c+8 -30 replies

Reviews trailers per patch

6 of 12 patches have a Reviewed-by or Acked-by.

PatchPierrick Bouvier
1/12R-b
2/12R-b
3/12R-b
4/12
5/12R-b
6/12R-b
7/12
8/12
9/12
10/12
11/12
12/12R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 00/12] qom: resolve type name conflicts, avoid target_info() in class_init or type_init

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.

v1: https://lore.kernel.org/qemu-devel/[email protected]/

Changes v1 -> v2:

- Drop target_not_s390x() from target-info. v1 exported it for scsi-disk, virtio-blk-pci, and virtio-net-pci. Each file keeps a static copy
- Drop target_not_base_i386() from target-info. Keep target_base_i386(), and a static target_not_base_i386() in virtio-mem
- Split hw/xtensa/virt: select virt machine types with is_available out of the DEFINE_MACHINE expansion, so later only that small patch needs a revert

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: expand DEFINE_MACHINE in virt.c
hw/xtensa/virt: select virt machine types with is_available target/arm: register separate max-v8 CPU types for arm and aarch64 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()
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                      | 48 +++++++++++++++++-----
 hw/virtio/virtio-blk-pci.c               | 27 +++++++++++-
 hw/virtio/virtio-mem.c                   | 52 +++++++++++++++---------
 hw/virtio/virtio-net-pci.c               | 27 +++++++++++-
 hw/virtio/virtio-pci.c                   |  4 ++
 hw/xtensa/virt.c                         | 20 ++++++++-
 include/hw/virtio/virtio-mem.h           |  2 +
 include/hw/virtio/virtio-pci.h           |  1 +
 include/qemu/target-info.h               | 21 ++++++++++
 target-info.c                            | 27 ++++++++++++
 target/arm/cpu.c                         |  1 +
 target/arm/cpu.h                         |  1 +
 target/arm/tcg/cpu-max-v8.c              | 16 ++++++--
 16 files changed, 225 insertions(+), 49 deletions(-)
Signature · 1 line
2.55.0.windows.3