mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
qdev: Move bus properties to abstract superclasses
In qdev, each bus in practice identified an abstract superclass, but this was mostly hidden. In QOM, instead, these abstract classes are explicit so we can move bus properties there. All bus property walks are removed, and all device property walks are changed to look along the class hierarchy instead. We would have duplicates if class A defines some properties and its subclass B does not define any, because class_b->props will be left equal to class_a->props. The solution here is to reintroduce the class_base_init TypeInfo callback, that was present in one of the early QOM versions but removed (on my request...) before committing. This breaks global bus properties, an obscure feature when used with the command-line which is actually useful and used when used by backwards-compatible machine types. So this patch also adjusts the global bus properties in hw/pc_piix.c to refer to the abstract class. Globals and other properties must be modified in the same patch to avoid complications related to initialization ordering. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
3cb75a7cba
commit
bce544740a
14 changed files with 73 additions and 83 deletions
|
@ -915,17 +915,18 @@ static Property *qdev_prop_walk(Property *props, const char *name)
|
|||
|
||||
static Property *qdev_prop_find(DeviceState *dev, const char *name)
|
||||
{
|
||||
ObjectClass *class;
|
||||
Property *prop;
|
||||
|
||||
/* device properties */
|
||||
prop = qdev_prop_walk(qdev_get_props(dev), name);
|
||||
if (prop)
|
||||
return prop;
|
||||
|
||||
/* bus properties */
|
||||
prop = qdev_prop_walk(dev->parent_bus->info->props, name);
|
||||
if (prop)
|
||||
return prop;
|
||||
class = object_get_class(OBJECT(dev));
|
||||
do {
|
||||
prop = qdev_prop_walk(DEVICE_CLASS(class)->props, name);
|
||||
if (prop) {
|
||||
return prop;
|
||||
}
|
||||
class = object_class_get_parent(class);
|
||||
} while (class != object_class_by_name(TYPE_DEVICE));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1145,17 +1146,20 @@ void qdev_prop_register_global_list(GlobalProperty *props)
|
|||
|
||||
void qdev_prop_set_globals(DeviceState *dev)
|
||||
{
|
||||
GlobalProperty *prop;
|
||||
ObjectClass *class = object_get_class(OBJECT(dev));
|
||||
|
||||
QTAILQ_FOREACH(prop, &global_props, next) {
|
||||
if (strcmp(object_get_typename(OBJECT(dev)), prop->driver) != 0 &&
|
||||
strcmp(qdev_get_bus_info(dev)->name, prop->driver) != 0) {
|
||||
continue;
|
||||
do {
|
||||
GlobalProperty *prop;
|
||||
QTAILQ_FOREACH(prop, &global_props, next) {
|
||||
if (strcmp(object_class_get_name(class), prop->driver) != 0) {
|
||||
continue;
|
||||
}
|
||||
if (qdev_prop_parse(dev, prop->property, prop->value) != 0) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if (qdev_prop_parse(dev, prop->property, prop->value) != 0) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
class = object_class_get_parent(class);
|
||||
} while (class);
|
||||
}
|
||||
|
||||
static int qdev_add_one_global(QemuOpts *opts, void *opaque)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue