* [Qemu-devel] [PATCH] qdev: relax bus type check in qdev_device_add()
@ 2012-11-29 13:49 Anthony Liguori
2012-11-29 13:56 ` Peter Maydell
0 siblings, 1 reply; 3+ messages in thread
From: Anthony Liguori @ 2012-11-29 13:49 UTC (permalink / raw)
To: qemu-devel; +Cc: Anthony Liguori, Konrad Frederic
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>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/qdev-monitor.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
index 479eecd..69f5ff2 100644
--- a/hw/qdev-monitor.c
+++ b/hw/qdev-monitor.c
@@ -431,11 +431,16 @@ DeviceState *qdev_device_add(QemuOpts *opts)
/* find bus */
path = qemu_opt_get(opts, "bus");
if (path != NULL) {
+ ObjectClass *bus_class;
+
bus = qbus_find(path);
if (!bus) {
return NULL;
}
- if (strcmp(object_get_typename(OBJECT(bus)), k->bus_type) != 0) {
+
+ bus_class = OBJECT_CLASS(BUS_GET_CLASS(bus));
+
+ if (!object_class_dynamic_cast(bus_class, k->bus_type)) {
qerror_report(QERR_BAD_BUS_FOR_DEVICE,
driver, object_get_typename(OBJECT(bus)));
return NULL;
--
1.8.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] qdev: relax bus type check in qdev_device_add()
2012-11-29 13:49 [Qemu-devel] [PATCH] qdev: relax bus type check in qdev_device_add() Anthony Liguori
@ 2012-11-29 13:56 ` Peter Maydell
2012-11-29 14:07 ` Konrad Frederic
0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2012-11-29 13:56 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel, Konrad Frederic
On 29 November 2012 13:49, Anthony Liguori <aliguori@us.ibm.com> wrote:
> We are currently checking for an exact type match. Use QOM dynamic_cast to
> check for a compatible type instead.
I think this only catches the case where a bus was explicitly
specified via bus=. For the default case you also need to change
the similar code for checking the bus type in qbus_find_recursive(),
right?
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] qdev: relax bus type check in qdev_device_add()
2012-11-29 13:56 ` Peter Maydell
@ 2012-11-29 14:07 ` Konrad Frederic
0 siblings, 0 replies; 3+ messages in thread
From: Konrad Frederic @ 2012-11-29 14:07 UTC (permalink / raw)
To: Peter Maydell; +Cc: Anthony Liguori, qemu-devel
On 29/11/2012 14:56, Peter Maydell wrote:
> On 29 November 2012 13:49, Anthony Liguori<aliguori@us.ibm.com> wrote:
>> We are currently checking for an exact type match. Use QOM dynamic_cast to
>> check for a compatible type instead.
> I think this only catches the case where a bus was explicitly
> specified via bus=. For the default case you also need to change
> the similar code for checking the bus type in qbus_find_recursive(),
> right?
>
> -- PMM
Right, it's working only with the "bus=" command line.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-11-29 14:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-29 13:49 [Qemu-devel] [PATCH] qdev: relax bus type check in qdev_device_add() Anthony Liguori
2012-11-29 13:56 ` Peter Maydell
2012-11-29 14:07 ` Konrad Frederic
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).