Blame SOURCES/kvm-qdev-monitor-Avoid-device_add-crashing-on-non-device.patch

0a122b
From d2b004602412ce65613b30f28d07ef8607e0d505 Mon Sep 17 00:00:00 2001
0a122b
From: Markus Armbruster <armbru@redhat.com>
0a122b
Date: Fri, 17 Jan 2014 17:07:58 +0100
0a122b
Subject: [PATCH 08/11] qdev-monitor: Avoid device_add crashing on non-device driver name
0a122b
MIME-Version: 1.0
0a122b
Content-Type: text/plain; charset=UTF-8
0a122b
Content-Transfer-Encoding: 8bit
0a122b
0a122b
RH-Author: Markus Armbruster <armbru@redhat.com>
0a122b
Message-id: <1389978479-30595-9-git-send-email-armbru@redhat.com>
0a122b
Patchwork-id: 56795
0a122b
O-Subject: [PATCH 7.0 qemu-kvm 8/9] qdev-monitor: Avoid device_add crashing on non-device driver name
0a122b
Bugzilla: 669524
0a122b
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
0a122b
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
0a122b
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
0a122b
0a122b
Watch this:
0a122b
0a122b
    $ upstream-qemu -nodefaults -S -display none -monitor stdio
0a122b
    QEMU 1.7.50 monitor - type 'help' for more information
0a122b
    (qemu) device_add rng-egd
0a122b
    /work/armbru/qemu/qdev-monitor.c:491:qdev_device_add: Object 0x2089b00 is not an instance of type device
0a122b
    Aborted (core dumped)
0a122b
0a122b
Crashes because "rng-egd" exists, but isn't a subtype of TYPE_DEVICE.
0a122b
Broken in commit 18b6dad.
0a122b
0a122b
Cc: qemu-stable@nongnu.org
0a122b
Signed-off-by: Markus Armbruster <armbru@redhat.com>
0a122b
Signed-off-by: Andreas Färber <afaerber@suse.de>
0a122b
(cherry picked from commit 061e84f7a469ad1f94f3b5f6a5361b346ab990e8)
0a122b
---
0a122b
 qdev-monitor.c | 2 +-
0a122b
 1 file changed, 1 insertion(+), 1 deletion(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 qdev-monitor.c |    2 +-
0a122b
 1 files changed, 1 insertions(+), 1 deletions(-)
0a122b
0a122b
diff --git a/qdev-monitor.c b/qdev-monitor.c
0a122b
index da7fe0d..55a476b 100644
0a122b
--- a/qdev-monitor.c
0a122b
+++ b/qdev-monitor.c
0a122b
@@ -478,7 +478,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
0a122b
         }
0a122b
     }
0a122b
 
0a122b
-    if (!oc) {
0a122b
+    if (!object_class_dynamic_cast(oc, TYPE_DEVICE)) {
0a122b
         qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver", "device type");
0a122b
         return NULL;
0a122b
     }
0a122b
-- 
0a122b
1.7.1
0a122b