* [Qemu-devel] [PATCH] qdev: modify func qdev_build_hotpluggable_device_list
@ 2014-11-02 17:21 Jun Li
2014-11-03 16:07 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Jun Li @ 2014-11-02 17:21 UTC (permalink / raw)
To: qemu-devel
Cc: peter.crosthwaite, famz, mst, juli, imammedo, pbonzini, Jun Li,
afaerber
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] qdev: modify func qdev_build_hotpluggable_device_list
2014-11-02 17:21 [Qemu-devel] [PATCH] qdev: modify func qdev_build_hotpluggable_device_list Jun Li
@ 2014-11-03 16:07 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2014-11-03 16:07 UTC (permalink / raw)
To: Jun Li, qemu-devel; +Cc: peter.crosthwaite, famz, mst, juli, imammedo, afaerber
On 02/11/2014 18:21, Jun Li wrote:
> 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);
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-03 16:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-02 17:21 [Qemu-devel] [PATCH] qdev: modify func qdev_build_hotpluggable_device_list Jun Li
2014-11-03 16:07 ` Paolo Bonzini
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).