qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: qdev instance_init vs realize split


From: Damien Hedde
Subject: Re: qdev instance_init vs realize split
Date: Tue, 15 Feb 2022 17:42:19 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.0


On 2/15/22 14:35, Peter Maydell wrote:
On Tue, 15 Feb 2022 at 13:21, Damien Hedde <damien.hedde@greensocs.com> wrote:
Are you saying that: if an operation like a mmio/irq definition is done
in realize(), in theory, we should have the unrealize() counterpart ?

I'm saying that at the moment we have two categories of device:
  * ones which are intended to be pluggable and so might be
    destroyed at runtime: these have to support the full
    instance_init->realize->unrealize->finalize cycle
  * ones which are only created in machine models and then exist
    for the lifetime of the QEMU process: these have to support
    instance_init->finalize (for the benefit of monitor introspection
    which can create and delete devices in that way) but otherwise
    only need to support the instance_init->realize and don't
    need to handle the unrealize->finalize part

and maybe we should consider whether it would be better to write
all our devices in the same way to handle the full set of
state transitions.

But if we do decide that then we'd need to have a testing framework
that actually exercised the whole lifecycle for all devices, and
it would probably be a lot of work, so maybe it's not worthwhile.

We'd also want where we can to have APIs that arrange to do
the handling of destruction for you. I think the GPIO line
APIs are like this, for instance. That's much less prone to
"forgot to clean it up" bugs.

-- PMM

Thanks for the clarification,
--
Damien



reply via email to

[Prev in Thread] Current Thread [Next in Thread]