qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Jun Li" <junmuzi@gmail.com>,
	qemu-stable@nongnu.org, "Andreas Färber" <afaerber@suse.de>
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	[thread overview]
Message-ID: <1424786311-22387-2-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1424786311-22387-1-git-send-email-afaerber@suse.de>

From: Jun Li <junmuzi@gmail.com>

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 <junmuzi@gmail.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 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	other threads:[~2015-02-24 14:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-24 13:58 [Qemu-devel] [PULL 00/10] QOM devices patch queue 2015-02-24 Andreas Färber
2015-02-24 13:58 ` Andreas Färber [this message]
2015-02-24 13:58 ` [Qemu-devel] [PULL 02/10] qom: Fix typo, 'my_class_init' -> 'derived_class_init' Andreas Färber
2015-02-24 13:58 ` [Qemu-devel] [PULL 03/10] qdev: Improve qdev_init_nofail()'s error reporting Andreas Färber
2015-02-24 13:58 ` [Qemu-devel] [PULL 04/10] ide/isa: Replace unchecked qdev_init() by qdev_init_nofail() Andreas Färber
2015-02-24 13:58 ` [Qemu-devel] [PULL 05/10] leon3: " Andreas Färber
2015-02-24 13:58 ` [Qemu-devel] [PULL 06/10] etsec: Replace " Andreas Färber
2015-02-24 13:58 ` [Qemu-devel] [PULL 07/10] serial: Factor out common serial_hds_isa_init() Andreas Färber
2015-02-24 13:58 ` [Qemu-devel] [PULL 08/10] serial: serial_hds_isa_init() shouldn't fail Andreas Färber
2015-02-24 13:58 ` [Qemu-devel] [PULL 09/10] parallel: Factor out common parallel_hds_isa_init() Andreas Färber
2015-02-24 13:58 ` [Qemu-devel] [PULL 10/10] parallel: parallel_hds_isa_init() shouldn't fail Andreas Färber
2015-02-24 19:17 ` [Qemu-devel] [PULL 00/10] QOM devices patch queue 2015-02-24 Mark Cave-Ayland
2015-03-02 14:21 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1424786311-22387-2-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=junmuzi@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).