From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXt6x-0000uw-2o for qemu-devel@nongnu.org; Thu, 02 May 2013 08:59:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UXt6v-0006gR-Hw for qemu-devel@nongnu.org; Thu, 02 May 2013 08:59:47 -0400 Received: from e24smtp03.br.ibm.com ([32.104.18.24]:40260) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXt6v-0006eO-6F for qemu-devel@nongnu.org; Thu, 02 May 2013 08:59:45 -0400 Received: from /spool/local by e24smtp03.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 2 May 2013 09:59:41 -0300 Received: from d24relay03.br.ibm.com (d24relay03.br.ibm.com [9.13.184.25]) by d24dlp01.br.ibm.com (Postfix) with ESMTP id 9EA253520068 for ; Thu, 2 May 2013 08:59:39 -0400 (EDT) Received: from d24av02.br.ibm.com (d24av02.br.ibm.com [9.8.31.93]) by d24relay03.br.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r42CwhbX47317004 for ; Thu, 2 May 2013 09:58:44 -0300 Received: from d24av02.br.ibm.com (loopback [127.0.0.1]) by d24av02.br.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r42Cxd47003331 for ; Thu, 2 May 2013 09:59:39 -0300 From: Anthony Liguori In-Reply-To: <51823A77.7090809@suse.de> References: <1367005387-330-1-git-send-email-aliguori@us.ibm.com> <1367005387-330-2-git-send-email-aliguori@us.ibm.com> <51823A77.7090809@suse.de> Date: Thu, 02 May 2013 07:59:19 -0500 Message-ID: <87ehdp4jx4.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/3] ide: add drive-id property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?utf-8?Q?F=C3=A4rber?= Cc: Kevin Wolf , qemu-devel@nongnu.org Andreas F=C3=A4rber writes: > Am 26.04.2013 21:43, schrieb Anthony Liguori: >> This returns a string similar to what the guest would display in >> something like Linux's /dev/disk/by-id/ path. >>=20 >> Signed-off-by: Anthony Liguori >> --- >> hw/ide/qdev.c | 15 +++++++++++++++ >> 1 file changed, 15 insertions(+) >>=20 >> diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c >> index 8a9a891..94b1664 100644 >> --- a/hw/ide/qdev.c >> +++ b/hw/ide/qdev.c >> @@ -270,6 +270,20 @@ static const TypeInfo ide_drive_info =3D { >> .class_init =3D ide_drive_class_init, >> }; >>=20=20 >> +static char *ide_device_get_model(Object *obj, Error **errp) >> +{ >> + IDEDevice *dev =3D IDE_DEVICE(obj); >> + IDEBus *bus =3D DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus); > > IDEBus *bus =3D IDE_BUS(qdev_get_parent_bus(DEVICE(obj))); > > You're breaking your own rules. :) Yeah, I copy/pasted, I'll clean up. > >> + IDEState *s =3D bus->ifs + dev->unit; >> + >> + return g_strdup_printf("%s %s", s->drive_model_str, s->drive_serial= _str); >> +} >> + >> +static void ide_device_initfn(Object *obj) >> +{ >> + object_property_add_str(obj, "drive-id", ide_device_get_model, NULL= , NULL); >> +} >> + >> static void ide_device_class_init(ObjectClass *klass, void *data) >> { >> DeviceClass *k =3D DEVICE_CLASS(klass); >> @@ -285,6 +299,7 @@ static const TypeInfo ide_device_type_info =3D { >> .abstract =3D true, >> .class_size =3D sizeof(IDEDeviceClass), >> .class_init =3D ide_device_class_init, >> + .instance_init =3D ide_device_initfn, > > You recently said ..._initfn was only a workaround for avoiding ..._init > vs. ..._initfn name conflicts. I've therefore started changing new code > to that pattern. There is no conflicting ide_device_init here. > > I don't really care which suffix we choose, but consistency is good. I'm happy with using initfn consistently but I really don't care that much. Regards, Anthony Liguori > >> }; >>=20=20 >> static void ide_register_types(void) > > Regards, > Andreas > > --=20 > SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany > GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3= =BCrnberg