On 05/01/2012 03:37 PM, Paolo Bonzini wrote:
Il 01/05/2012 20:18, Anthony Liguori ha scritto:
This is technically a compatibility breaker.  However:

1) libvirt does not rely on this (it always uses the driver name)

2) This behavior isn't actually documented anywhere (the docs just say driver).

3) I suspect there are less than three people on earth that even know this is
    possible (minus the people reading this message).

So I think we can safely break it :-)

Does this work with compat properties set on a bus?

No :-(

This is pretty easy to fix though. The attached should do the trick, I'll update and send out.

  Even if it does,
perhaps it's better to avoid the cleverness and wait for my series that
moves bus properties to the appropriate abstract superclass.

This series does that FWIW (patch 6/14).

Regards,

Anthony Liguori


Paolo


diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 6a75718..be809db 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -378,7 +378,7 @@ static QEMUMachine pc_machine_v1_1 = {
             .property = "vapic",\
             .value    = "off",\
         },{\
-            .driver   = "USB",\
+            .driver   = TYPE_USB_DEVICE,\
             .property = "full-path",\
             .value    = "no",\
         }
@@ -451,7 +451,7 @@ static QEMUMachine pc_machine_v0_14 = {
 #define PC_COMPAT_0_13 \
         PC_COMPAT_0_14,\
         {\
-            .driver   = "PCI",\
+            .driver   = TYPE_PCI_DEVICE,\
             .property = "command_serr_enable",\
             .value    = "off",\
         },{\
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 0c6dade..ddd7b25 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -1158,10 +1158,14 @@ void qdev_prop_set_globals(DeviceState *dev)
     GlobalProperty *prop;
 
     QTAILQ_FOREACH(prop, &global_props, next) {
-        if (strcmp(object_get_typename(OBJECT(dev)), prop->driver) != 0) {
+        Object *obj;
+
+        obj = object_dynamic_cast(OBJECT(dev), prop->driver);
+        if (obj == NULL) {
             continue;
         }
-        if (qdev_prop_parse(dev, prop->property, prop->value) != 0) {
+
+        if (qdev_prop_parse(DEVICE(obj), prop->property, prop->value) != 0) {
             exit(1);
         }
     }

Reply via email to