Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
qdev-properties: alias all object class properties
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>
Message-ID: <20231220134755.814917-2-stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
Stefan Hajnoczi authored and Kevin Wolf committed Dec 21, 2023
1 parent ce95340 commit 0c11a39
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 10 additions & 8 deletions hw/core/qdev-properties.c
Expand Up @@ -1076,16 +1076,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);
}
}
4 changes: 2 additions & 2 deletions include/hw/qdev-properties.h
Expand Up @@ -230,8 +230,8 @@ void qdev_property_add_static(DeviceState *dev, Property *prop);
* @target: Device which has properties to be aliased
* @source: Object to add alias properties to
*
* Add alias properties to the @source object for all qdev properties on
* the @target DeviceState.
* Add alias properties to the @source object for all properties on the @target
* DeviceState.
*
* This is useful when @target is an internal implementation object
* owned by @source, and you want to expose all the properties of that
Expand Down

0 comments on commit 0c11a39

Please sign in to comment.