On Thu, 30 Oct 2025, Paolo Bonzini wrote:
On 10/30/25 11:38, BALATON Zoltan wrote:
I've tried to explain why I dislike that way in previous replies in this
thread but here's a short summary:
- Not piling memory regions not otherwise needed in device struct makes it
easier to understand. (Could you spot errors within the lot of boiler plate
code before clean up? Having less code makes it more comprehensible.)
Not sure what's different between
MemoryRegion foo_mr;
in the struct, versus
mr = g_new(MemoryRegion, 1);
in the realize function. It's one line either way.
Please read back in thread. An example here:
https://lists.nongnu.org/archive/html/qemu-ppc/2025-10/msg00785.html
from this series
https://patchew.org/QEMU/[email protected]/
- Documentation says it should work this way QOM managing memory regions so
it was meant to be that way. I'd rather fix code than documentation as I
think if it just works that's easier than loosing that convenience.No,
that's *your* reading of the documentation, and it's based on the
incorrect assumption that destruction implies freeing the memory. Akihiko
explained that
(https://lore.kernel.org/qemu-devel/[email protected]/).
The memory region documentation does not exist in a void, the difference
between QOM object_initialize() and object_new() exists independent of that
documentation. It may be worth improving the QOM documentation on the object
lifecycle; that could be.
I'll try to also clarify documentation but IMO the fix is not dropping
this intended feature but fixing and using it where helps.
Regards,
BALATON Zoltan