]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qdev-monitor: Avoid device_add crashing on non-device driver name
authorMarkus Armbruster <armbru@redhat.com>
Thu, 28 Nov 2013 16:02:24 +0000 (17:02 +0100)
committerAndreas Färber <afaerber@suse.de>
Tue, 24 Dec 2013 16:26:58 +0000 (17:26 +0100)
Watch this:

    $ upstream-qemu -nodefaults -S -display none -monitor stdio
    QEMU 1.7.50 monitor - type 'help' for more information
    (qemu) device_add rng-egd
    /work/armbru/qemu/qdev-monitor.c:491:qdev_device_add: Object 0x2089b00 is not an instance of type device
    Aborted (core dumped)

Crashes because "rng-egd" exists, but isn't a subtype of TYPE_DEVICE.
Broken in commit 18b6dad.

Cc: qemu-stable@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
qdev-monitor.c

index 7877d018781fd07209a5c24939c71f8d5c1b489c..177b849abbf05de1e62e6a1cf65b089cd6ba69d8 100644 (file)
@@ -478,7 +478,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
         }
     }
 
-    if (!oc) {
+    if (!object_class_dynamic_cast(oc, TYPE_DEVICE)) {
         qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver", "device type");
         return NULL;
     }