Received: from eggs.gnu.org ([2001:4830:134:3::10]:48345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPyQK-0005Ni-40 for qemu-devel@nongnu.org; Fri, 05 Sep 2014 14:39:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XPyQF-0001J0-96 for qemu-devel@nongnu.org; Fri, 05 Sep 2014 14:39:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4126) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPyQF-0001Io-14 for qemu-devel@nongnu.org; Fri, 05 Sep 2014 14:39:47 -0400 Date: Fri, 5 Sep 2014 15:39:34 -0300 From: Eduardo Habkost Message-ID: <20140905183934.GM32084@thinpad.lan.raisama.net> References: <1409906256-11368-1-git-send-email-arei.gonglei@huawei.com> <1409906256-11368-25-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1409906256-11368-25-git-send-email-arei.gonglei@huawei.com> Subject: Re: [Qemu-devel] [PATCH v7 24/28] ide: add bootindex to qom property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: arei.gonglei@huawei.com Cc: chenliang88@huawei.com, weidong.huang@huawei.com, mst@redhat.com, aik@ozlabs.ru, hutao@cn.fujitsu.com, qemu-devel@nongnu.org, armbru@redhat.com, kraxel@redhat.com, akong@redhat.com, agraf@suse.de, aliguori@amazon.com, luonengjun@huawei.com, peter.huangpeng@huawei.com, hani@linux.com, stefanha@redhat.com, pbonzini@redhat.com, lcapitulino@redhat.com, kwolf@redhat.com, peter.crosthwaite@xilinx.com, imammedo@redhat.com, afaerber@suse.de On Fri, Sep 05, 2014 at 04:37:32PM +0800, arei.gonglei@huawei.com wrote: > From: Gonglei > > Add a qom property with the same name 'bootindex', > when we remove it form qdev property, things will > continue to work just fine, and we can use qom features > which are not supported by qdev property. > > Signed-off-by: Gonglei > --- > hw/ide/qdev.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c > index efab95b..9e2ed40 100644 > --- a/hw/ide/qdev.c > +++ b/hw/ide/qdev.c > @@ -191,6 +191,17 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) > return 0; > } > > +static void ide_dev_instance_init(Object *obj) > +{ > + DeviceState *dev = DEVICE(obj); > + IDEDevice *d = DO_UPCAST(IDEDevice, qdev, dev); > + > + device_add_bootindex_property(obj, &d->conf.bootindex, > + "bootindex", > + d->unit ? "/disk@1" : "/disk@0", > + &d->qdev, NULL); > +} > + > static int ide_hd_initfn(IDEDevice *dev) > { > return ide_dev_initfn(dev, IDE_HD); > @@ -238,6 +249,7 @@ static const TypeInfo ide_hd_info = { > .parent = TYPE_IDE_DEVICE, > .instance_size = sizeof(IDEDrive), > .class_init = ide_hd_class_init, > + .instance_init = ide_dev_instance_init, > }; > > static Property ide_cd_properties[] = { > @@ -260,6 +272,7 @@ static const TypeInfo ide_cd_info = { > .parent = TYPE_IDE_DEVICE, > .instance_size = sizeof(IDEDrive), > .class_init = ide_cd_class_init, > + .instance_init = ide_dev_instance_init, > }; > > static Property ide_drive_properties[] = { > @@ -282,6 +295,7 @@ static const TypeInfo ide_drive_info = { > .parent = TYPE_IDE_DEVICE, > .instance_size = sizeof(IDEDrive), > .class_init = ide_drive_class_init, > + .instance_init = ide_dev_instance_init, > }; If all TYPE_IDE_DEVICE subclasses have the same instance_init, why not just set ide_device_type_info.instance_init = ide_dev_instance_init? -- Eduardo