From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38801) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyMit-0002C9-Lx for qemu-devel@nongnu.org; Tue, 09 Dec 2014 10:29:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XyMim-0000Pb-H4 for qemu-devel@nongnu.org; Tue, 09 Dec 2014 10:29:11 -0500 Received: from cantor2.suse.de ([195.135.220.15]:45728 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XyMim-0000PI-BO for qemu-devel@nongnu.org; Tue, 09 Dec 2014 10:29:04 -0500 Message-ID: <5487153E.70002@suse.de> Date: Tue, 09 Dec 2014 16:29:02 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1415170983-12981-1-git-send-email-junmuzi@gmail.com> In-Reply-To: <1415170983-12981-1-git-send-email-junmuzi@gmail.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3] qdev: Avoid type assertion in qdev_build_hotpluggable_device_list() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jun Li , qemu-devel@nongnu.org Cc: peter.crosthwaite@xilinx.com, famz@redhat.com, mst@redhat.com, juli@redhat.com, imammedo@redhat.com, pbonzini@redhat.com Am 05.11.2014 um 08:03 schrieb Jun Li: > Currently when *obj is not a TYPE_DEVICE, qemu will abort. This patch j= ust > fixed it. When *obj is not a TYPE_DEVICE, just do not add it to hotplug= gable > device list. >=20 > This patch also fixed 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 >=20 > 2, device_del scsi0 via hmp using tab key(first input device_del, then = press > "Tab" key). > (qemu) device_del >=20 > After step2, qemu will abort. > (qemu) device_del hw/core/qdev.c:930:qdev_build_hotpluggable_device_lis= t: > Object 0x5555563a2460 is not an instance of type device >=20 > Signed-off-by: Jun Li > Reviewed-by: Paolo Bonzini > --- > v3: > According to Andreas's suggestion, do some changes. As followings: > 1, change the Subject to more meaningful. > 2, use two "return 0" to return early avoid reindentation. And I have= found in qcow2_grow_l1_table has also used two "return 0". So accept And= reas's suggestion. Thanks. Thanks, replaced the queued version on qom-next with a few edits and the following change: https://github.com/afaerber/qemu-cpu/commits/qom-next diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 51ab59e..ef06aa4 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -939,7 +939,7 @@ static int qdev_add_hotpluggable_device(Object *obj, void *opaque) { GSList **list =3D opaque; DeviceState *dev =3D (DeviceState *)object_dynamic_cast(OBJECT(obj), - "device"); + TYPE_DEVICE); if (dev =3D=3D NULL) { return 0; Regards, Andreas --=20 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 21284 AG N=FCrnbe= rg