qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3] qdev: Avoid type assertion in qdev_build_hot


From: Andreas Färber
Subject: Re: [Qemu-devel] [PATCH v3] qdev: Avoid type assertion in qdev_build_hotpluggable_device_list()
Date: Tue, 09 Dec 2014 16:29:02 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

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 <address@hidden>
> Reviewed-by: Paolo Bonzini <address@hidden>
> ---
> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]