qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH RESEND 0/9] virtio: fix virtio child recount in


From: Gonglei (Arei)
Subject: Re: [Qemu-devel] [PATCH RESEND 0/9] virtio: fix virtio child recount in transports
Date: Mon, 29 Sep 2014 12:09:06 +0000

> From: Cornelia Huck [mailto:address@hidden
> Sent: Monday, September 29, 2014 6:53 PM
> Subject: Re: [PATCH RESEND 0/9] virtio: fix virtio child recount in transports
> 
> On Sat, 27 Sep 2014 10:37:23 +0000
> "Gonglei (Arei)" <address@hidden> wrote:
> 
> > > > One thing I noticed is that the various devices end up with similar
> > > > code in the end:
> > > >
> > > >      object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_WHATEVER);
> > > >      object_property_add_child(obj, "virtio-backend",
> > > OBJECT(&dev->vdev),
> > > > NULL);
> > > >      object_unref(OBJECT(&dev->vdev));
> > > >      qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
> > > >
> > > > Would it make sense to add a helper function for that?
> > >
> >
> > Sorry, I'm afraid this is not helpful. Because dev and dev->vdev is 
> > different
> > for different virtio devices, like VirtIOBlkPCI(and its vdev is 
> > VirtIOBlock),
> > VirtIONetPCI(and its vdev is VirtIONet). They have no the same parameters
> > for above code segment. :)
> 
> Hm...
> 
> void virtio_instance_init_common(Object *proxydev,
>                                  DeviceState *vdev,
>                                  size_t vdevsize,
>                                  const char *vdevname)
> {
>     object_initialize(vdev, vdevsize, vdevname);
>     object_property_add_child(proxydev, "virtio-backend", OBJECT(vdev),
> NULL);
>     object_unref(OBJECT(vdev));
>     qdev_alias_all_properties(vdev, proxydev);
> }
> 
> and have the initializers call
> 
> virtio_instance_init_common(obj, DEVICE(&dev->vdev), sizeof(dev->vdev),
> TYPE_WHATEVER);
> 
> ?

OK, it looks good that pass all parameters to one wrapper function. 
Will do this in next version.

Thanks, Cornelia. :)

Best regards,
-Gonglei



reply via email to

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