Re: [PATCH v2 09/10] qom: Allow default values for instance properties

Daniel P. BerrangĂ© <[email protected]> Wed, 10 Jun 2026 17:19:38 +0100
Newsgroups org.nongnu.qemu-rust,org.nongnu.qemu-arm,org.nongnu.qemu-devel
Message-ID <[email protected]>
On Tue, Jun 09, 2026 at 01:25:13PM -0400, Peter Xu wrote:
> ObjectProperty allows default value settings via proper setup of
> prop->init() and prop->defval.  It currently is only supported in class
> properties, not instance properties.
> 
> However, since QOM allows class and instance properties, it should also
> allow instance to add properties during instance_init() and allow the
> default values to be applied properly for this instance only.
> 
> Add the logic.  It will be useful for all kinds of pointer based properties
> because pointers are normally not accessble in a class but only when an
> instance is available.  This will be able to achieve similar function as
> what qdev properties have (which works by remembering offsets within a
> structure instead).

Again, I don't think we should be adding more features to the
instance properties concept, as new code should use class
level properties.

> 
> Signed-off-by: Peter Xu <[email protected]>
> ---
>  qom/object.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|