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: Philippe Mathieu-Daudé
Subject: Re: qdev instance_init vs realize split
Date: Tue, 15 Feb 2022 12:15:19 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.1

On 15/2/22 11:19, Damien Hedde wrote:
Hi,

I'm wondering if there are rules or convention about what we put in the instance_init() vs realize() for simple devices ? (For complex ones we generally have no choice to put everything in realize())

See Peter's recommendations here:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg723958.html

For example we can declare irqs and mmios in instance_init() or realize() if they do not depend on some property.

This is not a big deal, but given how works the help message generation in the monitor, there are difference if the device is user-creatable.

If we leave irqs and mmios declaration in the instance_init(). They appear in the help message.
 > (qemu) device_add ibex-timer,help
 > ibex-timer options:
 >   ibex-timer[0]=<child<memory-region>>
 >   sysbus-irq[0]=<link<irq>>
 >   timebase-freq=<uint32> -  (default: 10000)

If we delay the declaration in realize(), we only have the declared qdev-properties (which is maybe more what we expect at this point):

 > (qemu) device_add ibex-timer,help
 > ibex-timer options:
 >   timebase-freq=<uint32> -  (default: 10000)

Any comments ?

Thanks,
Damien




reply via email to

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