Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NY07O-0000f3-FN for qemu-devel@nongnu.org; Thu, 21 Jan 2010 11:42:50 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NY07J-0000cQ-EL for qemu-devel@nongnu.org; Thu, 21 Jan 2010 11:42:49 -0500 Received: from [199.232.76.173] (port=36237 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NY07J-0000cK-3m for qemu-devel@nongnu.org; Thu, 21 Jan 2010 11:42:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45704) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NY07I-00079q-KI for qemu-devel@nongnu.org; Thu, 21 Jan 2010 11:42:44 -0500 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH 2/3] qdev: Add help for property value References: <4B54B749.5080304@mail.berlios.de> <1264024715-23417-1-git-send-email-weil@mail.berlios.de> <1264024715-23417-2-git-send-email-weil@mail.berlios.de> Date: Thu, 21 Jan 2010 17:42:40 +0100 In-Reply-To: <1264024715-23417-2-git-send-email-weil@mail.berlios.de> (Stefan Weil's message of "Wed, 20 Jan 2010 22:58:34 +0100") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: QEMU Developers Stefan Weil writes: > When called with property value "?", > a help text will be printed (instead of an error message). > > This is useful for command lines like > qemu -device e1000,mac=? > and is already standard for other command line options. > > A better help text could be provided by extending > the Property structure with a desc field. > > Signed-off-by: Stefan Weil > --- > hw/qdev-properties.c | 9 +++++++-- > 1 files changed, 7 insertions(+), 2 deletions(-) > > diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c > index 8547ad2..f5ca05f 100644 > --- a/hw/qdev-properties.c > +++ b/hw/qdev-properties.c > @@ -565,8 +565,13 @@ int qdev_prop_parse(DeviceState *dev, const char *name, const char *value) > return -1; > } > if (prop->info->parse(dev, prop, value) != 0) { > - fprintf(stderr, "property \"%s.%s\": failed to parse \"%s\"\n", > - dev->info->name, name, value); > + if (strcmp(value, "?") != 0) { > + fprintf(stderr, "property \"%s.%s\": failed to parse \"%s\"\n", > + dev->info->name, name, value); > + } else { > + fprintf(stderr, "%s.%s=%s\n", > + dev->info->name, name, prop->info->name); > + } > return -1; > } > return 0; This one is problematic. If prop->info->parse() accepts "?", help is inaccessible. PATCH 1/3 is immune to that problem, because we won't name a property "?". PATCH 1/3 already makes -device FOO,? print all property names. I figure it could just as well print all help along with names.