From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:51488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXqOY-00012l-So for qemu-devel@nongnu.org; Thu, 02 May 2013 06:05:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UXqOX-0008EI-58 for qemu-devel@nongnu.org; Thu, 02 May 2013 06:05:46 -0400 Received: from cantor2.suse.de ([195.135.220.15]:37920 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXqOW-0008Dh-Ro for qemu-devel@nongnu.org; Thu, 02 May 2013 06:05:45 -0400 Message-ID: <51823A77.7090809@suse.de> Date: Thu, 02 May 2013 12:05:43 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1367005387-330-1-git-send-email-aliguori@us.ibm.com> <1367005387-330-2-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1367005387-330-2-git-send-email-aliguori@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 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: Anthony Liguori Cc: Kevin Wolf , qemu-devel@nongnu.org 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 > +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. :) > + IDEState *s =3D bus->ifs + dev->unit; > + > + return g_strdup_printf("%s %s", s->drive_model_str, s->drive_seria= l_str); > +} > + > +static void ide_device_initfn(Object *obj) > +{ > + object_property_add_str(obj, "drive-id", ide_device_get_model, NUL= L, 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. > }; > =20 > static void ide_register_types(void) Regards, Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg