mirror of https://github.com/xemu-project/xemu.git
qdev: relax bus type check in qdev_device_add() (v2)
We are currently checking for an exact type match. Use QOM dynamic_cast to check for a compatible type instead. Cc: Konrad Frederic <fred.konrad@greensocs.com> Cc: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> --- v1 -> v2: - also add cast to qbus_find_recursive (Peter) - simplify by doing object_dynamic_cast instead of messing with classes
This commit is contained in:
parent
e9bff10f8d
commit
e912c96f7d
|
@ -289,8 +289,7 @@ static BusState *qbus_find_recursive(BusState *bus, const char *name,
|
||||||
if (name && (strcmp(bus->name, name) != 0)) {
|
if (name && (strcmp(bus->name, name) != 0)) {
|
||||||
match = 0;
|
match = 0;
|
||||||
}
|
}
|
||||||
if (bus_typename &&
|
if (bus_typename && !object_dynamic_cast(OBJECT(bus), bus_typename)) {
|
||||||
(strcmp(object_get_typename(OBJECT(bus)), bus_typename) != 0)) {
|
|
||||||
match = 0;
|
match = 0;
|
||||||
}
|
}
|
||||||
if (match) {
|
if (match) {
|
||||||
|
@ -435,7 +434,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
|
||||||
if (!bus) {
|
if (!bus) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (strcmp(object_get_typename(OBJECT(bus)), k->bus_type) != 0) {
|
if (!object_dynamic_cast(OBJECT(bus), k->bus_type)) {
|
||||||
qerror_report(QERR_BAD_BUS_FOR_DEVICE,
|
qerror_report(QERR_BAD_BUS_FOR_DEVICE,
|
||||||
driver, object_get_typename(OBJECT(bus)));
|
driver, object_get_typename(OBJECT(bus)));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue