qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] qdev: relax bus type check in qdev_device_add()


From: Konrad Frederic
Subject: Re: [Qemu-devel] [PATCH] qdev: relax bus type check in qdev_device_add() (v2)
Date: Thu, 29 Nov 2012 16:20:32 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.5) Gecko/20120623 Thunderbird/10.0.5

On 29/11/2012 16:12, Anthony Liguori wrote:
We are currently checking for an exact type match.  Use QOM dynamic_cast to
check for a compatible type instead.

Cc: Konrad Frederic<address@hidden>
Cc: Peter Maydell<address@hidden>
Signed-off-by: Anthony Liguori<address@hidden>
---
v1 ->  v2:
  - also add cast to qbus_find_recursive (Peter)
  - simplify by doing object_dynamic_cast instead of messing with classes
---
  hw/qdev-monitor.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
index 479eecd..a1b4d6a 100644
--- a/hw/qdev-monitor.c
+++ b/hw/qdev-monitor.c
@@ -289,8 +289,7 @@ static BusState *qbus_find_recursive(BusState *bus, const 
char *name,
      if (name&&  (strcmp(bus->name, name) != 0)) {
          match = 0;
      }
-    if (bus_typename&&
-        (strcmp(object_get_typename(OBJECT(bus)), bus_typename) != 0)) {
+    if (bus_typename&&  !object_dynamic_cast(OBJECT(bus), bus_typename)) {
          match = 0;
      }
      if (match) {
@@ -435,7 +434,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
          if (!bus) {
              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,
                            driver, object_get_typename(OBJECT(bus)));
              return NULL;
That seems to work.

Thanks,

Fred.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]