qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] qdev: modify func qdev_build_hotpluggable_device_list
@ 2014-11-04  6:55 Jun Li
  2014-11-04 18:39 ` Andreas Färber
  0 siblings, 1 reply; 5+ messages in thread
From: Jun Li @ 2014-11-04  6:55 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>
---
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 | 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] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2] qdev: modify func qdev_build_hotpluggable_device_list
  2014-11-04  6:55 [Qemu-devel] [PATCH v2] qdev: modify func qdev_build_hotpluggable_device_list Jun Li
@ 2014-11-04 18:39 ` Andreas Färber
  2014-11-05  0:53   ` jun muzi
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Färber @ 2014-11-04 18:39 UTC (permalink / raw)
  To: Jun Li, qemu-devel; +Cc: peter.crosthwaite, famz, mst, juli, imammedo, pbonzini

Hi,

Am 04.11.2014 um 07:55 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>
> ---
> 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 | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)

Thanks, I've queued this patch, but we should give it a more meaningful
subject - maybe "qdev: Avoid type assertion in qdev_build_...()"?

Also, we could avoid reindentation by returning early:
if (dev == NULL) {
    return 0;
}

What do you think?

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	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2] qdev: modify func qdev_build_hotpluggable_device_list
  2014-11-04 18:39 ` Andreas Färber
@ 2014-11-05  0:53   ` jun muzi
  2014-11-05  1:59     ` Fam Zheng
  0 siblings, 1 reply; 5+ messages in thread
From: jun muzi @ 2014-11-05  0:53 UTC (permalink / raw)
  To: Andreas Färber
  Cc: peter.crosthwaite, famz, mst, qemu-devel, imammedo, pbonzini

[-- Attachment #1: Type: text/plain, Size: 2106 bytes --]

Yes, in my original thought i just want to do as you said. But it will have
two "return 0" in one function. So i think it's not so smart. If you still
think two "return 0" is better, i will submit a new version. Thanks.

BTW, for subject, i agree with you.

Jun Li
2014-11-5 上午2:39于 "Andreas Färber" <afaerber@suse.de>写道:

> Hi,
>
> Am 04.11.2014 um 07:55 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>
> > ---
> > 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 | 13 +++++++++----
> >  1 file changed, 9 insertions(+), 4 deletions(-)
>
> Thanks, I've queued this patch, but we should give it a more meaningful
> subject - maybe "qdev: Avoid type assertion in qdev_build_...()"?
>
> Also, we could avoid reindentation by returning early:
> if (dev == NULL) {
>     return 0;
> }
>
> What do you think?
>
> Regards,
> Andreas
>
> --
> SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 21284 AG Nürnberg
>

[-- Attachment #2: Type: text/html, Size: 2722 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2] qdev: modify func qdev_build_hotpluggable_device_list
  2014-11-05  0:53   ` jun muzi
@ 2014-11-05  1:59     ` Fam Zheng
  2014-11-05  6:48       ` Jun Li
  0 siblings, 1 reply; 5+ messages in thread
From: Fam Zheng @ 2014-11-05  1:59 UTC (permalink / raw)
  To: jun muzi
  Cc: peter.crosthwaite, mst, qemu-devel, imammedo, pbonzini,
	Andreas Färber

On Wed, 11/05 08:53, jun muzi wrote:
> Yes, in my original thought i just want to do as you said. But it will have
> two "return 0" in one function. So i think it's not so smart. If you still
> think two "return 0" is better, i will submit a new version. Thanks.
> 
> BTW, for subject, i agree with you.

Please use inline reply for mailing list discussions.

Fam

> 
> Jun Li
> 2014-11-5 上午2:39于 "Andreas Färber" <afaerber@suse.de>写道:
> 
> > Hi,
> >
> > Am 04.11.2014 um 07:55 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>
> > > ---
> > > 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 | 13 +++++++++----
> > >  1 file changed, 9 insertions(+), 4 deletions(-)
> >
> > Thanks, I've queued this patch, but we should give it a more meaningful
> > subject - maybe "qdev: Avoid type assertion in qdev_build_...()"?
> >
> > Also, we could avoid reindentation by returning early:
> > if (dev == NULL) {
> >     return 0;
> > }
> >
> > What do you think?
> >
> > 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	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH v2] qdev: modify func qdev_build_hotpluggable_device_list
  2014-11-05  1:59     ` Fam Zheng
@ 2014-11-05  6:48       ` Jun Li
  0 siblings, 0 replies; 5+ messages in thread
From: Jun Li @ 2014-11-05  6:48 UTC (permalink / raw)
  To: Fam Zheng
  Cc: peter.crosthwaite, mst, qemu-devel, imammedo, pbonzini,
	Andreas Färber

On Wed, 11/05 09:59, Fam Zheng wrote:
> On Wed, 11/05 08:53, jun muzi wrote:
> > Yes, in my original thought i just want to do as you said. But it will have
> > two "return 0" in one function. So i think it's not so smart. If you still
> > think two "return 0" is better, i will submit a new version. Thanks.
> > 
> > BTW, for subject, i agree with you.
> 
> Please use inline reply for mailing list discussions.

Ok, got it. Thx.

> 
> Fam
> 
> > 
> > Jun Li
> > 2014-11-5 上午2:39于 "Andreas Färber" <afaerber@suse.de>写道:
> > 
> > > Hi,
> > >
> > > Am 04.11.2014 um 07:55 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>
> > > > ---
> > > > 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 | 13 +++++++++----
> > > >  1 file changed, 9 insertions(+), 4 deletions(-)
> > >
> > > Thanks, I've queued this patch, but we should give it a more meaningful
> > > subject - maybe "qdev: Avoid type assertion in qdev_build_...()"?
> > >
> > > Also, we could avoid reindentation by returning early:
> > > if (dev == NULL) {
> > >     return 0;
> > > }
> > >
> > > What do you think?
> > >
> > > 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	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-05  6:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-04  6:55 [Qemu-devel] [PATCH v2] qdev: modify func qdev_build_hotpluggable_device_list Jun Li
2014-11-04 18:39 ` Andreas Färber
2014-11-05  0:53   ` jun muzi
2014-11-05  1:59     ` Fam Zheng
2014-11-05  6:48       ` Jun Li

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).