qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PULL 01/10] qdev: Avoid type assertion in qdev_build_hotpl


From: Andreas Färber
Subject: [Qemu-devel] [PULL 01/10] qdev: Avoid type assertion in qdev_build_hotpluggable_device_list()
Date: Tue, 24 Feb 2015 14:58:21 +0100

From: Jun Li <address@hidden>

Currently when *obj is not a TYPE_DEVICE, QEMU will abort. This patch
fixes it. When *obj is not a TYPE_DEVICE, just do not add it to hotpluggable
device list.

This patch also fixes the following issue:
1. boot QEMU using cli:
$ /opt/qemu-git-arm/bin/qemu-system-x86_64 -monitor stdio -enable-kvm \
-device virtio-scsi-pci,id=scsi0

2. device_del scsi0 via hmp using tab key(first input device_del, then press
"Tab" key).
(qemu) device_del

After step 2, QEMU will abort.
(qemu) device_del hw/core/qdev.c:930:qdev_build_hotpluggable_device_list:
Object 0x5555563a2460 is not an instance of type device

Signed-off-by: Jun Li <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
Cc: address@hidden
Signed-off-by: Andreas Färber <address@hidden>
---
 hw/core/qdev.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 2eacac0..ff81f67 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -988,7 +988,12 @@ void qdev_alias_all_properties(DeviceState *target, Object 
*source)
 static int qdev_add_hotpluggable_device(Object *obj, void *opaque)
 {
     GSList **list = opaque;
-    DeviceState *dev = DEVICE(obj);
+    DeviceState *dev = (DeviceState *)object_dynamic_cast(OBJECT(obj),
+                                                          TYPE_DEVICE);
+
+    if (dev == NULL) {
+        return 0;
+    }
 
     if (dev->realized && object_property_get_bool(obj, "hotpluggable", NULL)) {
         *list = g_slist_append(*list, dev);
-- 
2.1.4




reply via email to

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