All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jun Li <junmuzi@gmail.com>
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 <junmuzi@gmail.com>,
	afaerber@suse.de
Subject: [Qemu-devel] [PATCH] qdev: modify func qdev_build_hotpluggable_device_list
Date: Mon,  3 Nov 2014 01:21:12 +0800	[thread overview]
Message-ID: <1414948872-25736-1-git-send-email-junmuzi@gmail.com> (raw)

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 <junmuzi@gmail.com>
---
 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

             reply	other threads:[~2014-11-02 17:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-02 17:21 Jun Li [this message]
2014-11-03 16:07 ` [Qemu-devel] [PATCH] qdev: modify func qdev_build_hotpluggable_device_list Paolo Bonzini

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=1414948872-25736-1-git-send-email-junmuzi@gmail.com \
    --to=junmuzi@gmail.com \
    --cc=afaerber@suse.de \
    --cc=famz@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=juli@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=qemu-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.