From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=53284 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pl2Dj-0003kV-E9 for qemu-devel@nongnu.org; Thu, 03 Feb 2011 11:39:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pl2Dh-0001jz-I8 for qemu-devel@nongnu.org; Thu, 03 Feb 2011 11:39:46 -0500 Received: from mail-iw0-f173.google.com ([209.85.214.173]:42128) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pl2Dh-0001js-CD for qemu-devel@nongnu.org; Thu, 03 Feb 2011 11:39:45 -0500 Received: by iwc10 with SMTP id 10so1339816iwc.4 for ; Thu, 03 Feb 2011 08:39:44 -0800 (PST) Message-ID: <4D4ADA4C.4030504@codemonkey.ws> Date: Thu, 03 Feb 2011 10:39:40 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 01/20] qdev: add print_options callback References: <1296678500-19497-1-git-send-email-alevy@redhat.com> <1296678500-19497-2-git-send-email-alevy@redhat.com> In-Reply-To: <1296678500-19497-2-git-send-email-alevy@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alon Levy Cc: qemu-devel@nongnu.org On 02/02/2011 02:28 PM, Alon Levy wrote: > another callback added to PropertyInfo, for later use by PROP_TYPE_ENUM. > Allows printing of runtime computed options when doing: > qemu -device foo,? > --- > hw/qdev.c | 10 +++++++++- > hw/qdev.h | 1 + > 2 files changed, 10 insertions(+), 1 deletions(-) > > diff --git a/hw/qdev.c b/hw/qdev.c > index c7fec44..0b2ad3d 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -187,7 +187,15 @@ int qdev_device_help(QemuOpts *opts) > if (!prop->info->parse) { > continue; /* no way to set it, don't show */ > } > - error_printf("%s.%s=%s\n", info->name, prop->name, prop->info->name); > + if (prop->info->print_options) { > + char buf[256]; > + int ret; > + ret = prop->info->print_options(info, prop, buf, sizeof(buf) - 3); > + error_printf("%s.%s=%s%s\n", info->name, prop->name, buf, > + ret == sizeof(buf) - 3 ? "..." : "" ); > + } else { > + error_printf("%s.%s=%s\n", info->name, prop->name, prop->info->name); > + } > } > return 1; > } > diff --git a/hw/qdev.h b/hw/qdev.h > index 9808f85..fa3221b 100644 > --- a/hw/qdev.h > +++ b/hw/qdev.h > @@ -109,6 +109,7 @@ struct PropertyInfo { > enum PropertyType type; > int (*parse)(DeviceState *dev, Property *prop, const char *str); > int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len); > + int (*print_options)(DeviceInfo *info, Property *prop, char *dest, size_t len); > I'm not clear what the different between print and print_options is and why two callbacks are needed. Can you explain and comments to the patch clarifying why two interfaces are needed. Even better would be if one interface could handle it. Regards, Anthony Liguori > void (*free)(DeviceState *dev, Property *prop); > }; > >