Re: [PATCH v2 09/10] qom: Allow default values for instance properties
Daniel P. Berrangé <[email protected]> Thu, 11 Jun 2026 15:17:06 +0100
| Newsgroups | org.nongnu.qemu-rust,org.nongnu.qemu-arm,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Jun 11, 2026 at 03:08:41PM +0100, Mark Cave-Ayland wrote: > On 09/06/2026 18:25, 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. > > Thinking back to the earlier patches, a question that has come up before is > whether we should require all properties to be class properties? Ideally yes, but we have the classic QEMU problem of a big pile of technical debt that would need converting and always more interesting things to work on. Most is a boring mechanical task, but there are some awkward edge cases around dynamically added properties. > IIRC one of > the motivations for this move was to allow schema introspection, but I don't > immediately have a reference to the original discussion. Better supporting introspection was the original key goal, but also reducing memory footprint for classes which have 100s or 1000s of instances registering the same props over & over. Introspection against the class means we trivially avoid risk of side-effects from instantiating objects and not completing their realization. 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 :|