From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XYa61-0005Nv-Ur for qemu-devel@nongnu.org; Mon, 29 Sep 2014 08:30:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XYa5x-0002zW-1m for qemu-devel@nongnu.org; Mon, 29 Sep 2014 08:30:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38478) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XYa5w-0002yt-Pk for qemu-devel@nongnu.org; Mon, 29 Sep 2014 08:30:24 -0400 Date: Mon, 29 Sep 2014 15:33:32 +0300 From: "Michael S. Tsirkin" Message-ID: <20140929123332.GA1429@redhat.com> References: <1411721147-11712-1-git-send-email-arei.gonglei@huawei.com> <20140926162125.71ea6598.cornelia.huck@de.ibm.com> <33183CC9F5247A488A2544077AF1902086DDC6DD@SZXEMA503-MBS.china.huawei.com> <20140929125309.3b3483d0.cornelia.huck@de.ibm.com> <33183CC9F5247A488A2544077AF1902086DDCCC8@SZXEMA503-MBS.china.huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <33183CC9F5247A488A2544077AF1902086DDCCC8@SZXEMA503-MBS.china.huawei.com> Subject: Re: [Qemu-devel] [PATCH RESEND 0/9] virtio: fix virtio child recount in transports List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Gonglei (Arei)" Cc: "Huangweidong (C)" , "armbru@redhat.com" , Luonengjun , "qemu-devel@nongnu.org" , "agraf@suse.de" , "borntraeger@de.ibm.com" , "stefanha@redhat.com" , Cornelia Huck , "pbonzini@redhat.com" , "Huangpeng (Peter)" , "rth@twiddle.net" On Mon, Sep 29, 2014 at 12:09:06PM +0000, Gonglei (Arei) wrote: > > From: Cornelia Huck [mailto:cornelia.huck@de.ibm.com] > > 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)" 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 I'm fine with doing the cleanup as a patch on top. Cornelia, fine with you?