From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xkyqn-00017N-9b for qemu-devel@nongnu.org; Sun, 02 Nov 2014 12:22:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xkyqe-0000hi-7g for qemu-devel@nongnu.org; Sun, 02 Nov 2014 12:22:01 -0500 Received: from mail-pd0-x22a.google.com ([2607:f8b0:400e:c02::22a]:40794) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xkyqe-0000f8-0z for qemu-devel@nongnu.org; Sun, 02 Nov 2014 12:21:52 -0500 Received: by mail-pd0-f170.google.com with SMTP id z10so10157882pdj.15 for ; Sun, 02 Nov 2014 09:21:50 -0800 (PST) From: Jun Li Date: Mon, 3 Nov 2014 01:21:12 +0800 Message-Id: <1414948872-25736-1-git-send-email-junmuzi@gmail.com> Subject: [Qemu-devel] [PATCH] qdev: modify func qdev_build_hotpluggable_device_list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.crosthwaite@xilinx.com, famz@redhat.com, mst@redhat.com, juli@redhat.com, imammedo@redhat.com, pbonzini@redhat.com, Jun Li , afaerber@suse.de Currently when *obj is not a TYPE_DEVICE, qemu will abort. This patch just fixed it. When *obj is not a TYPE_DEVICE, just do not add it to hotpluggable device list. This patch also fixed the following issue: 1, boot qemu using cli: virtio-scsi-pci,id=scsi0 -enable-kvm 2, device_del scsi0 via hmp using tab key(first input device_del, then press "Tab" key). (qemu) device_del After step2, 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 --- hw/core/qdev.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index b3d5196..2282e95 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -927,13 +927,18 @@ void qdev_alias_all_properties(DeviceState *target, Object *source) int qdev_build_hotpluggable_device_list(Object *obj, void *opaque) { GSList **list = opaque; - DeviceState *dev = DEVICE(obj); + DeviceState *dev = (DeviceState *)object_dynamic_cast(OBJECT(obj), + "device"); + + if (dev) { + if (dev->realized && + object_property_get_bool(obj, "hotpluggable", NULL)) { + *list = g_slist_append(*list, dev); + } - if (dev->realized && object_property_get_bool(obj, "hotpluggable", NULL)) { - *list = g_slist_append(*list, dev); + object_child_foreach(obj, qdev_build_hotpluggable_device_list, opaque); } - object_child_foreach(obj, qdev_build_hotpluggable_device_list, opaque); return 0; } -- 1.9.3