From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:37438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RuPb6-0004gk-Mg for qemu-devel@nongnu.org; Mon, 06 Feb 2012 09:31:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RuPb1-00033O-A5 for qemu-devel@nongnu.org; Mon, 06 Feb 2012 09:31:12 -0500 Received: from mail-pw0-f45.google.com ([209.85.160.45]:38662) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RuPb1-000338-5J for qemu-devel@nongnu.org; Mon, 06 Feb 2012 09:31:07 -0500 Received: by pbaa11 with SMTP id a11so6792003pba.4 for ; Mon, 06 Feb 2012 06:31:06 -0800 (PST) Message-ID: <4F2FE427.4080508@codemonkey.ws> Date: Mon, 06 Feb 2012 08:31:03 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1328342577-25732-1-git-send-email-pbonzini@redhat.com> <1328342577-25732-15-git-send-email-pbonzini@redhat.com> In-Reply-To: <1328342577-25732-15-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 14/27] qdev: allow reusing get/set for legacy property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org On 02/04/2012 02:02 AM, Paolo Bonzini wrote: > In some cases, a legacy property does need a special print method > but not a special parse method. In this case, we can reuse the get/set > from the static (non-legacy) property. > > If neither parse nor print is needed, though, do not register the > legacy property at all. The previous patch ensures that the right > fallback will be used. > > Signed-off-by: Paolo Bonzini Reviewed-by: Anthony Liguori Regards, Anthony Liguori > --- > hw/qdev.c | 11 +++++++---- > 1 files changed, 7 insertions(+), 4 deletions(-) > > diff --git a/hw/qdev.c b/hw/qdev.c > index a731e41..660ee38 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -550,21 +550,24 @@ static void qdev_set_legacy_property(Object *obj, Visitor *v, void *opaque, > * Do not use this is new code! Properties added through this interface will > * be given names and types in the "legacy" namespace. > * > - * Legacy properties are always processed as strings. The format of the string > - * depends on the property type. > + * Legacy properties are string versions of other OOM properties. The format > + * of the string depends on the property type. > */ > void qdev_property_add_legacy(DeviceState *dev, Property *prop, > Error **errp) > { > gchar *name, *type; > > + if (!prop->info->print&& !prop->info->parse) { > + return; > + } > name = g_strdup_printf("legacy-%s", prop->name); > type = g_strdup_printf("legacy<%s>", > prop->info->legacy_name ?: prop->info->name); > > object_property_add(OBJECT(dev), name, type, > - prop->info->print ? qdev_get_legacy_property : NULL, > - prop->info->parse ? qdev_set_legacy_property : NULL, > + prop->info->print ? qdev_get_legacy_property : prop->info->get, > + prop->info->parse ? qdev_set_legacy_property : prop->info->set, > NULL, > prop, errp); >