QOM: Enforce container_get() to operate on containers only
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest5 patches 13 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/5 | qom: Add TYPE_CONTAINER macrohw/ include/ qom/ +1 more | +7 | 2 replies | |
| 2/5 | ppc/e500: Avoid abuse of container_get()hw/ | +2 | 0 replies | |
| 3/5 | qdev: Make device_set_realized() always safe in testshw/ | +10 | 2 replies | |
| 4/5 | qdev: Make qdev_get_machine() not use container_get()hw/ | +7 | 0 replies | |
| 5/5 | qom: Make container_get() strict to always walk or return containerqom/ | +21 | 9 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/5] QOM: Enforce container_get() to operate on containers only
[This is not for 9.2 release, but for 10.0]
QEMU defines a frequently used helper container_get(), which (from its name implies) should return a container object of a specific path, normally starting from object_get_root() (aka, the root of QOM tree, "/"), or some sub-directory of root.
We mostly use it correctly across the tree, except two use cases that may abuse the helper to be similar to object_resolve_path_component():
- qdev_get_machine()
- e500_pcihost_bridge_realize()
In the two cases, container_get() might accidentally create a container even if the goal of the caller is trying to fetch some non-container object.
This series cleans this up by firstly remove these two abuses, replacing the container_get() usages with object_resolve_path_component(). Meanwhile, the last patch adds not only rich comment explaining container_get() usages, but also added a lightweight assertion to make sure container_get() will always walk on container objects, and always return container objects.
There's another implicit side effect that container_get() may silently create missing container objects while walking the path. We could switch to an explicit way of using containers in the future, but now leaving that behavior as-is.
Note, patch 3,4 were picked up from the previous singleton series [1], even if the vIOMMU patch wasn't present. It's because they're still required in this cleanup series to either clean up container_get() user, or to avoid breaking test_static_prop_subprocess() similarly there. Looks like that test is so far the only test that can try to realize() a qdev without a machine object.
[1] https://lore.kernel.org/r/[email protected]
Thanks,
Peter Xu (5):
qom: Add TYPE_CONTAINER macro
ppc/e500: Avoid abuse of container_get()
qdev: Make device_set_realized() always safe in tests
qdev: Make qdev_get_machine() not use container_get()
qom: Make container_get() strict to always walk or return container
include/qom/object.h | 3 ++- hw/arm/stellaris.c | 2 +- hw/core/qdev.c | 20 +++++++++++++++++--- hw/pci-host/ppce500.c | 4 ++-- qom/container.c | 25 +++++++++++++++++++++++-- qom/object.c | 4 ++-- 6 files changed, 47 insertions(+), 11 deletions(-)
Signature · 1 line
2.45.0