From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQG3B-0003RS-HJ for qemu-devel@nongnu.org; Tue, 24 Feb 2015 09:01:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQG31-0007Yh-2h for qemu-devel@nongnu.org; Tue, 24 Feb 2015 09:01:25 -0500 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 24 Feb 2015 14:58:21 +0100 Message-Id: <1424786311-22387-2-git-send-email-afaerber@suse.de> In-Reply-To: <1424786311-22387-1-git-send-email-afaerber@suse.de> References: <1424786311-22387-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 01/10] qdev: Avoid type assertion in qdev_build_hotpluggable_device_list() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jun Li , qemu-stable@nongnu.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= From: Jun Li 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 hotplugga= ble 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=3Dscsi0 2. device_del scsi0 via hmp using tab key(first input device_del, then pr= ess "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 Reviewed-by: Paolo Bonzini Cc: qemu-stable@nongnu.org Signed-off-by: Andreas F=C3=A4rber --- 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 =3D opaque; - DeviceState *dev =3D DEVICE(obj); + DeviceState *dev =3D (DeviceState *)object_dynamic_cast(OBJECT(obj), + TYPE_DEVICE); + + if (dev =3D=3D NULL) { + return 0; + } =20 if (dev->realized && object_property_get_bool(obj, "hotpluggable", N= ULL)) { *list =3D g_slist_append(*list, dev); --=20 2.1.4