From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:52112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPJq7-0002IA-L0 for qemu-devel@nongnu.org; Tue, 01 May 2012 16:38:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SPJq5-00054h-L4 for qemu-devel@nongnu.org; Tue, 01 May 2012 16:38:27 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:33075) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPJq5-00054U-E1 for qemu-devel@nongnu.org; Tue, 01 May 2012 16:38:25 -0400 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 1 May 2012 16:38:21 -0400 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 5700A6E805D for ; Tue, 1 May 2012 16:38:18 -0400 (EDT) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q41KbNiD432500 for ; Tue, 1 May 2012 16:37:24 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q4228FmU013876 for ; Tue, 1 May 2012 22:08:15 -0400 Message-ID: <4FA0497D.3060103@us.ibm.com> Date: Tue, 01 May 2012 15:37:17 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1335896294-9530-1-git-send-email-aliguori@us.ibm.com> <1335896294-9530-4-git-send-email-aliguori@us.ibm.com> <4FA033EC.1050800@suse.de> In-Reply-To: <4FA033EC.1050800@suse.de> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 03/14] qdev: add qdev_add_properties List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?ISO-8859-15?Q?Andreas_F=E4rber?= Cc: Wanpeng Li , Peter Maydell , qemu-devel@nongnu.org, Paolo Bonzini On 05/01/2012 02:05 PM, Andreas Färber wrote: > Am 01.05.2012 20:18, schrieb Anthony Liguori: >> This allows a base class to easily add properties. >> >> Signed-off-by: Anthony Liguori > > Implementation looks okay but /me not so happy with it: This conflicts > with the move of the qdev static property infrastructure from > DeviceState to Object. > > Consider rebasing this onto part of Paolo's series and call it > object_add_properties? Eh? There's nothing object_ about these properties and there's no way I'm willing to put legacy properties in object... So I'm not quite sure what you're suggesting. Regards, Anthony Liguori > > Andreas > >> --- >> hw/qdev.c | 25 ++++++++++++------------- >> hw/qdev.h | 2 ++ >> 2 files changed, 14 insertions(+), 13 deletions(-) >> >> diff --git a/hw/qdev.c b/hw/qdev.c >> index 6a8f6bd..e17a9ab 100644 >> --- a/hw/qdev.c >> +++ b/hw/qdev.c >> @@ -76,22 +76,26 @@ bool qdev_exists(const char *name) >> static void qdev_property_add_legacy(DeviceState *dev, Property *prop, >> Error **errp); >> >> -void qdev_set_parent_bus(DeviceState *dev, BusState *bus) >> +void qdev_add_properties(DeviceState *dev, Property *props) >> { >> Property *prop; >> >> + for (prop = props; prop&& prop->name; prop++) { >> + qdev_property_add_legacy(dev, prop, NULL); >> + qdev_property_add_static(dev, prop, NULL); >> + } >> + qdev_prop_set_defaults(dev, props); >> +} >> + >> +void qdev_set_parent_bus(DeviceState *dev, BusState *bus) >> +{ >> if (qdev_hotplug) { >> assert(bus->allow_hotplug); >> } >> >> dev->parent_bus = bus; >> QTAILQ_INSERT_HEAD(&bus->children, dev, sibling); >> - >> - for (prop = qdev_get_bus_info(dev)->props; prop&& prop->name; prop++) { >> - qdev_property_add_legacy(dev, prop, NULL); >> - qdev_property_add_static(dev, prop, NULL); >> - } >> - qdev_prop_set_defaults(dev, dev->parent_bus->info->props); >> + qdev_add_properties(dev, dev->parent_bus->info->props); >> } >> >> /* Create a new device. This only initializes the device state structure >> @@ -633,13 +637,8 @@ static void device_initfn(Object *obj) >> dev->instance_id_alias = -1; >> dev->state = DEV_STATE_CREATED; >> >> - for (prop = qdev_get_props(dev); prop&& prop->name; prop++) { >> - qdev_property_add_legacy(dev, prop, NULL); >> - qdev_property_add_static(dev, prop, NULL); >> - } >> - >> + qdev_add_properties(dev, qdev_get_props(dev)); >> object_property_add_str(OBJECT(dev), "type", qdev_get_type, NULL, NULL); >> - qdev_prop_set_defaults(dev, qdev_get_props(dev)); >> } >> >> /* Unlink device from bus and free the structure. */ >> diff --git a/hw/qdev.h b/hw/qdev.h >> index 4e90119..ca8386a 100644 >> --- a/hw/qdev.h >> +++ b/hw/qdev.h >> @@ -360,4 +360,6 @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus); >> >> extern int qdev_hotplug; >> >> +void qdev_add_properties(DeviceState *dev, Property *props); >> + >> #endif > >