* [PATCH] qdev-properties: alias all object class properties
@ 2023-08-03 19:51 Stefan Hajnoczi
2023-09-14 12:44 ` Stefan Hajnoczi
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Hajnoczi @ 2023-08-03 19:51 UTC (permalink / raw)
To: qemu-devel
Cc: Daniel P. Berrangé, Paolo Bonzini, Eduardo Habkost,
Stefan Hajnoczi
qdev_alias_all_properties() aliases a DeviceState's qdev properties onto
an Object. This is used for VirtioPCIProxy types so that --device
virtio-blk-pci has properties of its embedded --device virtio-blk-device
object.
Currently this function is implemented using qdev properties. Change the
function to use QOM object class properties instead. This works because
qdev properties create QOM object class properties, but it also catches
any QOM object class-only properties that have no qdev properties.
This change ensures that properties of devices are shown with --device
foo,\? even if they are QOM object class properties.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
hw/core/qdev-properties.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 357b8761b5..fbf3969d3c 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -959,16 +959,18 @@ void device_class_set_props(DeviceClass *dc, Property *props)
void qdev_alias_all_properties(DeviceState *target, Object *source)
{
ObjectClass *class;
- Property *prop;
+ ObjectPropertyIterator iter;
+ ObjectProperty *prop;
class = object_get_class(OBJECT(target));
- do {
- DeviceClass *dc = DEVICE_CLASS(class);
- for (prop = dc->props_; prop && prop->name; prop++) {
- object_property_add_alias(source, prop->name,
- OBJECT(target), prop->name);
+ object_class_property_iter_init(&iter, class);
+ while ((prop = object_property_iter_next(&iter))) {
+ if (object_property_find(source, prop->name)) {
+ continue; /* skip duplicate properties */
}
- class = object_class_get_parent(class);
- } while (class != object_class_by_name(TYPE_DEVICE));
+
+ object_property_add_alias(source, prop->name,
+ OBJECT(target), prop->name);
+ }
}
--
2.41.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] qdev-properties: alias all object class properties
2023-08-03 19:51 [PATCH] qdev-properties: alias all object class properties Stefan Hajnoczi
@ 2023-09-14 12:44 ` Stefan Hajnoczi
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2023-09-14 12:44 UTC (permalink / raw)
To: Paolo Bonzini
Cc: qemu-devel, Daniel P. Berrangé, Eduardo Habkost,
Stefan Hajnoczi
Paolo: ping?
On Thu, 3 Aug 2023 at 15:51, Stefan Hajnoczi <stefanha@redhat.com> wrote:
>
> qdev_alias_all_properties() aliases a DeviceState's qdev properties onto
> an Object. This is used for VirtioPCIProxy types so that --device
> virtio-blk-pci has properties of its embedded --device virtio-blk-device
> object.
>
> Currently this function is implemented using qdev properties. Change the
> function to use QOM object class properties instead. This works because
> qdev properties create QOM object class properties, but it also catches
> any QOM object class-only properties that have no qdev properties.
>
> This change ensures that properties of devices are shown with --device
> foo,\? even if they are QOM object class properties.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> hw/core/qdev-properties.c | 18 ++++++++++--------
> 1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index 357b8761b5..fbf3969d3c 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -959,16 +959,18 @@ void device_class_set_props(DeviceClass *dc, Property *props)
> void qdev_alias_all_properties(DeviceState *target, Object *source)
> {
> ObjectClass *class;
> - Property *prop;
> + ObjectPropertyIterator iter;
> + ObjectProperty *prop;
>
> class = object_get_class(OBJECT(target));
> - do {
> - DeviceClass *dc = DEVICE_CLASS(class);
>
> - for (prop = dc->props_; prop && prop->name; prop++) {
> - object_property_add_alias(source, prop->name,
> - OBJECT(target), prop->name);
> + object_class_property_iter_init(&iter, class);
> + while ((prop = object_property_iter_next(&iter))) {
> + if (object_property_find(source, prop->name)) {
> + continue; /* skip duplicate properties */
> }
> - class = object_class_get_parent(class);
> - } while (class != object_class_by_name(TYPE_DEVICE));
> +
> + object_property_add_alias(source, prop->name,
> + OBJECT(target), prop->name);
> + }
> }
> --
> 2.41.0
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-14 12:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-03 19:51 [PATCH] qdev-properties: alias all object class properties Stefan Hajnoczi
2023-09-14 12:44 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).