* [Qemu-devel] [PATCH v3] qdev: Avoid type assertion in qdev_build_hotpluggable_device_list()
@ 2014-11-05 7:03 Jun Li
2014-12-08 14:07 ` Jun Li
2014-12-09 15:29 ` Andreas Färber
0 siblings, 2 replies; 4+ messages in thread
From: Jun Li @ 2014-11-05 7:03 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:
$ /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 <junmuzi@gmail.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
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 Andreas's suggestion. Thanks.
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 | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index b3d5196..7db3e13 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -927,7 +927,12 @@ 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 == NULL) {
+ return 0;
+ }
if (dev->realized && object_property_get_bool(obj, "hotpluggable", NULL)) {
*list = g_slist_append(*list, dev);
--
1.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v3] qdev: Avoid type assertion in qdev_build_hotpluggable_device_list()
2014-11-05 7:03 [Qemu-devel] [PATCH v3] qdev: Avoid type assertion in qdev_build_hotpluggable_device_list() Jun Li
@ 2014-12-08 14:07 ` Jun Li
2014-12-09 15:08 ` Andreas Färber
2014-12-09 15:29 ` Andreas Färber
1 sibling, 1 reply; 4+ messages in thread
From: Jun Li @ 2014-12-08 14:07 UTC (permalink / raw)
To: qemu-devel
Cc: peter.crosthwaite, famz, mst, juli, imammedo, pbonzini, afaerber
Ping, why does this patch has not been merged until now? Could anyone give
some explanations? Thx.
Regards,
Jun Li
On Wed, 11/05 15:03, 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:
> $ /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 <junmuzi@gmail.com>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> 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 Andreas's suggestion. Thanks.
>
> 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 | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index b3d5196..7db3e13 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -927,7 +927,12 @@ 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 == NULL) {
> + return 0;
> + }
>
> if (dev->realized && object_property_get_bool(obj, "hotpluggable", NULL)) {
> *list = g_slist_append(*list, dev);
> --
> 1.9.3
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v3] qdev: Avoid type assertion in qdev_build_hotpluggable_device_list()
2014-12-08 14:07 ` Jun Li
@ 2014-12-09 15:08 ` Andreas Färber
0 siblings, 0 replies; 4+ messages in thread
From: Andreas Färber @ 2014-12-09 15:08 UTC (permalink / raw)
To: Jun Li, qemu-devel; +Cc: peter.crosthwaite, famz, mst, juli, imammedo, pbonzini
Am 08.12.2014 um 15:07 schrieb Jun Li:
> Ping, why does this patch has not been merged until now? Could anyone give
> some explanations? Thx.
I had already applied the previous version of the patch to qom-next.
I'll drop it and replace it with this version then.
Regards,
Andreas
> On Wed, 11/05 15:03, 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:
>> $ /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 <junmuzi@gmail.com>
>> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>> 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 Andreas's suggestion. Thanks.
>>
>> 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 | 7 ++++++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
>> index b3d5196..7db3e13 100644
>> --- a/hw/core/qdev.c
>> +++ b/hw/core/qdev.c
>> @@ -927,7 +927,12 @@ 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 == NULL) {
>> + return 0;
>> + }
>>
>> if (dev->realized && object_property_get_bool(obj, "hotpluggable", NULL)) {
>> *list = g_slist_append(*list, dev);
>> --
>> 1.9.3
>>
>
--
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 21284 AG Nürnberg
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v3] qdev: Avoid type assertion in qdev_build_hotpluggable_device_list()
2014-11-05 7:03 [Qemu-devel] [PATCH v3] qdev: Avoid type assertion in qdev_build_hotpluggable_device_list() Jun Li
2014-12-08 14:07 ` Jun Li
@ 2014-12-09 15:29 ` Andreas Färber
1 sibling, 0 replies; 4+ messages in thread
From: Andreas Färber @ 2014-12-09 15:29 UTC (permalink / raw)
To: Jun Li, qemu-devel; +Cc: peter.crosthwaite, famz, mst, juli, imammedo, pbonzini
Am 05.11.2014 um 08:03 schrieb Jun Li:
> 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 <junmuzi@gmail.com>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> 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 Andreas'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 = opaque;
DeviceState *dev = (DeviceState *)object_dynamic_cast(OBJECT(obj),
- "device");
+ TYPE_DEVICE);
if (dev == NULL) {
return 0;
Regards,
Andreas
--
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 21284 AG Nürnberg
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-12-09 15:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-05 7:03 [Qemu-devel] [PATCH v3] qdev: Avoid type assertion in qdev_build_hotpluggable_device_list() Jun Li
2014-12-08 14:07 ` Jun Li
2014-12-09 15:08 ` Andreas Färber
2014-12-09 15:29 ` Andreas Färber
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).