From patchwork Tue Nov 4 06:55:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: lijun X-Patchwork-Id: 406449 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id CA81714009E for ; Tue, 4 Nov 2014 17:56:35 +1100 (AEDT) Received: from localhost ([::1]:38894 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlY2a-0003Pe-LG for incoming@patchwork.ozlabs.org; Tue, 04 Nov 2014 01:56:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlY2C-00034j-50 for qemu-devel@nongnu.org; Tue, 04 Nov 2014 01:56:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XlY23-0000c1-0a for qemu-devel@nongnu.org; Tue, 04 Nov 2014 01:56:08 -0500 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]:44795) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlY22-0000bu-PI for qemu-devel@nongnu.org; Tue, 04 Nov 2014 01:55:58 -0500 Received: by mail-pa0-f41.google.com with SMTP id rd3so13887732pab.28 for ; Mon, 03 Nov 2014 22:55:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=sHSIc3C3LBDH0n4areuROyUuOtEEI/sSjjbM3+phPDo=; b=duuqDtC2dYOS9TCQNPToWK4vFgzTkmXO8WbVtalDsdaVodilFa8679ylF7MAx0phc3 kw6bDUdnq6bzKZgY5A1HA00t//3y8Y0X+kZsh3+vxImsK9A5PcPIxu7robOMMMl+VbAt BwyaowOr2DgubjemVtgYhwL3KGgUVWcEFKAa2GrGKOmwcR12xXwD7lSZQQF91QBspMOT IPdRBCf7PrZ/bZyAzcL+nD5W6PdIIyp3RhZO+62awJetd4WhHTLa/Y11QJSU2xbgR4dK mJow7dzHbfMx80cfeefKt+sDGYerhHaq3F5rbLFnl80OEJTsmRNL7W8TnheONKCeJYkf qLtA== X-Received: by 10.68.111.161 with SMTP id ij1mr48352994pbb.10.1415084157158; Mon, 03 Nov 2014 22:55:57 -0800 (PST) Received: from localhost ([203.114.244.88]) by mx.google.com with ESMTPSA id gz1sm18927400pbb.8.2014.11.03.22.55.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Nov 2014 22:55:56 -0800 (PST) From: Jun Li To: qemu-devel@nongnu.org Date: Tue, 4 Nov 2014 14:55:47 +0800 Message-Id: <1415084147-11895-1-git-send-email-junmuzi@gmail.com> X-Mailer: git-send-email 1.9.3 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::229 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 Subject: [Qemu-devel] [PATCH v2] qdev: modify func qdev_build_hotpluggable_device_list X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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: $ /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 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 Reviewed-by: Paolo Bonzini --- v2: This version just do a little changes for the commit message. As following show: In v1, 1, boot qemu using cli: virtio-scsi-pci,id=scsi0 -enable-kvm In v2, 1, boot qemu using cli: $ /opt/qemu-git-arm/bin/qemu-system-x86_64 -monitor stdio -enable-kvm \ -device virtio-scsi-pci,id=scsi0 --- 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; }