mbox series

[00/12] QOM: container_get() removal

Message ID 20241120215703.3918445-1-peterx@redhat.com (mailing list archive)
Headers show
Series QOM: container_get() removal | expand

Message

Peter Xu Nov. 20, 2024, 9:56 p.m. UTC
This series is not for 9.2, but for 10.0.  It is intended to replace this
previous patchset:

  [PATCH 0/5] QOM: Enforce container_get() to operate on containers only
  https://lore.kernel.org/r/20241118221330.3480246-1-peterx@redhat.com

Since it's a different patchset, the versioning starts from v1.

The series is about container_get() and its removal.  Meanwhile after the
whole series applied, all the containers will be created explicitly.  No
lookup code will implicitly create container anymore.

In general, container_get() is a flaky interface in a few things.  Firstly,
some of the users use it without getting a container object.  Secondly, it
can implicitly create containers on the fly.

As Dan (mostly) pointed out, we don't have a super complicated container
layout.  It looks like this:

  /objects
  /chardevs
  /backend         (conditional, ui/ only)
  /dr-connector    (conditional, ppc/ only)
  /machine
    /peripheral
    /peripheral-anon
    /unattached

This series create these containers explicitly.

There's a side benefit of dropping container_get(), which is to avoid
complicated string operations, as container_get() is never used in more
than one depth.  It means switching to object_resolve_path_component()
should make existing code even tiny little faster.

To achieve this, some test needs to be fixed first.  For that, "tests: Fix
test-qdev-global-props on anonymous qdev realize()".

Comments welcomed, thanks.

Peter Xu (12):
  qom: Add TYPE_CONTAINER macro
  qom: New container_create()
  tests: Fix test-qdev-global-props on anonymous qdev realize()
  tests: Explicitly create containers in test_qom_partial_path()
  ui/console: Explicitly create "/backend" container
  hw/ppc: Explicitly create the drc container
  ppc/e500: Avoid abuse of container_get()
  qdev: Make qdev_get_machine() not use container_get()
  qdev: Add machine_get_container()
  qom: Create system containers explicitly
  qom: Add object_get_container()
  qom: Drop container_get()

 include/hw/qdev-core.h              | 10 ++++++++
 include/qom/object.h                | 25 +++++++++++++-----
 backends/cryptodev.c                |  4 +--
 chardev/char.c                      |  2 +-
 hw/arm/stellaris.c                  |  2 +-
 hw/core/gpio.c                      |  3 +--
 hw/core/machine.c                   | 19 +++++++++++---
 hw/core/qdev.c                      | 28 +++++++++++++++++---
 hw/core/sysbus.c                    |  4 +--
 hw/i386/pc.c                        |  4 +--
 hw/pci-host/ppce500.c               |  4 +--
 hw/ppc/spapr_drc.c                  | 40 +++++++++++++++++++++--------
 qom/container.c                     | 31 ++++++++--------------
 qom/object.c                        | 30 +++++++++++++++++++---
 scsi/pr-manager.c                   |  4 +--
 system/ioport.c                     |  2 +-
 system/memory.c                     |  2 +-
 system/qdev-monitor.c               |  6 ++---
 system/vl.c                         |  3 +--
 tests/unit/check-qom-proplist.c     |  2 +-
 tests/unit/test-qdev-global-props.c | 21 +++++++++++++++
 ui/console.c                        |  4 +--
 ui/dbus-chardev.c                   |  2 +-
 23 files changed, 180 insertions(+), 72 deletions(-)

Comments

Philippe Mathieu-Daudé Nov. 21, 2024, 9:18 a.m. UTC | #1
On 20/11/24 22:56, Peter Xu wrote:

> Peter Xu (12):
>    qom: Add TYPE_CONTAINER macro
>    qom: New container_create()
>    tests: Fix test-qdev-global-props on anonymous qdev realize()
>    tests: Explicitly create containers in test_qom_partial_path()
>    ui/console: Explicitly create "/backend" container
>    hw/ppc: Explicitly create the drc container
>    ppc/e500: Avoid abuse of container_get()
>    qdev: Make qdev_get_machine() not use container_get()
>    qdev: Add machine_get_container()
>    qom: Create system containers explicitly
>    qom: Add object_get_container()
>    qom: Drop container_get()

Maybe split the last patch in 3, reordering as:

- qom: Create system containers explicitly
- qdev: Make qdev_get_machine() not use container_get()
- qdev: Add machine_get_container()
- qdev: Use machine_get_container()
   (part 1 of 'qom: Drop container_get()')
- qom: Add object_get_container()
- qom: Use object_get_container()
   (part 2 of 'qom: Drop container_get()')
- qom: Drop container_get()
   (part 3 of 'qom: Drop container_get()')