From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XYYlr-0000EK-EK for qemu-devel@nongnu.org; Mon, 29 Sep 2014 07:05:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XYYlj-00067T-Qd for qemu-devel@nongnu.org; Mon, 29 Sep 2014 07:05:35 -0400 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:60113) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XYYlj-00065v-In for qemu-devel@nongnu.org; Mon, 29 Sep 2014 07:05:27 -0400 Received: from /spool/local by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 29 Sep 2014 11:55:08 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 0884C2190148 for ; Mon, 29 Sep 2014 11:54:32 +0100 (BST) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s8TArEi55570630 for ; Mon, 29 Sep 2014 10:53:14 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s8T5pKgd024410 for ; Mon, 29 Sep 2014 01:51:21 -0400 Date: Mon, 29 Sep 2014 12:53:09 +0200 From: Cornelia Huck Message-ID: <20140929125309.3b3483d0.cornelia.huck@de.ibm.com> In-Reply-To: <33183CC9F5247A488A2544077AF1902086DDC6DD@SZXEMA503-MBS.china.huawei.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> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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)" , "mst@redhat.com" , "armbru@redhat.com" , Luonengjun , "agraf@suse.de" , "qemu-devel@nongnu.org" , "borntraeger@de.ibm.com" , "stefanha@redhat.com" , "pbonzini@redhat.com" , "Huangpeng (Peter)" , "rth@twiddle.net" 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); ?