]> xenbits.xensource.com Git - qemu-upstream-4.6-testing.git/commitdiff
qdev: Fix crash when using non-device class name on -global
authorEduardo Habkost <ehabkost@redhat.com>
Thu, 3 Jul 2014 19:45:35 +0000 (16:45 -0300)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 6 Jul 2014 06:13:54 +0000 (09:13 +0300)
This fixes the following crash:

    $ qemu-system-x86_64 -global container.xxx=y
    hw/core/qdev-properties-system.c:399:qdev_add_one_global: Object 0x7f7eff234100 is not an instance of type device
    Aborted (core dumped)

New behavior will be to just warn, just like when non-existing clas
names are used:

    $ qemu-system-x86_64 -global container.xxx=y
    qemu-system-x86_64: Warning: "-global container.xxx=y" not used

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Tested-by: Don Slutz <dslutz@verizon.com>
hw/core/qdev-properties-system.c

index 8e140af46f82594af3d6d0ce93f4e0a35fe53ce5..ae0900f651b6aaa33735d98a6af5e3e7e8731e43 100644 (file)
@@ -394,7 +394,8 @@ static int qdev_add_one_global(QemuOpts *opts, void *opaque)
     g->driver   = qemu_opt_get(opts, "driver");
     g->property = qemu_opt_get(opts, "property");
     g->value    = qemu_opt_get(opts, "value");
-    oc = object_class_by_name(g->driver);
+    oc = object_class_dynamic_cast(object_class_by_name(g->driver),
+                                   TYPE_DEVICE);
     if (oc) {
         DeviceClass *dc = DEVICE_CLASS(oc);