On 2025/09/11 6:10, Peter Xu wrote:
On Sat, Sep 06, 2025 at 04:11:19AM +0200, Akihiko Odaki wrote:
A common pattern is that to delete memory subregions during realization
error handling and unrealization. pci automatically automatically
deletes the IO subregions, but the pattern is manually implemented
in other places, which is tedious and error-prone.
I don't think they're the same? What is the ultimate goal of this change?
Covering all devices in the common code is less tedious and error-prone
because the same logic will not be duplicated by the subclasses.
PCI core only detachs all the BARs from the address space registered from
pci_register_bar() explicitly. It's not an object_dynamic_cast() detaching
every MR not matter what it is..
All devices share one semantics: they are exposed to the guest only when
they are realized. Therefore, every MRs should be detached after
unrealization, no matter what it is.
The other thing it does is detaching the DMA root memory region.
I'm not fluent with pci, but IMHO it's good to keep those explicit.
Explicit detaching is "tedious and error-prone"; more concretely, there
are the following two error situations:
1. Forget the detachment and cause a memory leak.
2. Perform the detachment after finalization, which could have happened
with a manual detachment in "[PATCH 11/22] vfio-user: Do not delete the
subregion".
Regards,
Akihiko Odaki