From patchwork Thu Mar 4 15:56:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 46929 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C9FD2B7CF7 for ; Fri, 5 Mar 2010 03:25:06 +1100 (EST) Received: from localhost ([127.0.0.1]:53690 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NnDr9-000203-2y for incoming@patchwork.ozlabs.org; Thu, 04 Mar 2010 11:24:59 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NnDQo-0000gD-4g for qemu-devel@nongnu.org; Thu, 04 Mar 2010 10:57:46 -0500 Received: from [199.232.76.173] (port=35963 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NnDQk-0000ce-8n for qemu-devel@nongnu.org; Thu, 04 Mar 2010 10:57:42 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NnDQY-0000LS-IY for qemu-devel@nongnu.org; Thu, 04 Mar 2010 10:57:41 -0500 Received: from oxygen.pond.sub.org ([213.239.205.148]:39641) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NnDQV-0000K2-Qm for qemu-devel@nongnu.org; Thu, 04 Mar 2010 10:57:29 -0500 Received: from blackfin.pond.sub.org (pD9E38041.dip.t-dialin.net [217.227.128.65]) by oxygen.pond.sub.org (Postfix) with ESMTPA id A5F92276DBE for ; Thu, 4 Mar 2010 16:57:15 +0100 (CET) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id 8430611A; Thu, 4 Mar 2010 16:57:13 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 4 Mar 2010 16:56:47 +0100 Message-Id: <1267718231-13303-27-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1267718231-13303-1-git-send-email-armbru@redhat.com> References: <1267718231-13303-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Luiz Capitulino Subject: [Qemu-devel] [PATCH 26/50] qdev: Hide "ptr" properties from users X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Users can't set them, so qdev_device_help() shouldn't list them. Fix that. Also make qdev_prop_parse() hide them instead of printing a meaningless "has no parser" error message. Their value means nothing to users, so qdev_print_props() shouldn't print it. Fix by removing their print method. Their only use is dirty hacks. Document that. Signed-off-by: Markus Armbruster --- hw/qdev-properties.c | 21 ++++++++------------- hw/qdev.c | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 277ff9e..11f7b76 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -399,17 +399,11 @@ PropertyInfo qdev_prop_vlan = { /* --- pointer --- */ -static int print_ptr(DeviceState *dev, Property *prop, char *dest, size_t len) -{ - void **ptr = qdev_get_prop_ptr(dev, prop); - return snprintf(dest, len, "<%p>", *ptr); -} - +/* Not a proper property, just for dirty hacks. TODO Remove it! */ PropertyInfo qdev_prop_ptr = { .name = "ptr", .type = PROP_TYPE_PTR, .size = sizeof(void*), - .print = print_ptr, }; /* --- mac address --- */ @@ -543,16 +537,17 @@ int qdev_prop_parse(DeviceState *dev, const char *name, const char *value) Property *prop; prop = qdev_prop_find(dev, name); - if (!prop) { + /* + * TODO Properties without a parse method are just for dirty + * hacks. qdev_prop_ptr is the only such PropertyInfo. It's + * marked for removal. The test !prop->info->parse should be + * removed along with it. + */ + if (!prop || !prop->info->parse) { fprintf(stderr, "property \"%s.%s\" not found\n", dev->info->name, name); return -1; } - if (!prop->info->parse) { - fprintf(stderr, "property \"%s.%s\" has no parser\n", - dev->info->name, name); - 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); diff --git a/hw/qdev.c b/hw/qdev.c index 5ebf013..1a6f257 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -180,6 +180,15 @@ int qdev_device_help(QemuOpts *opts) } for (prop = info->props; prop && prop->name; prop++) { + /* + * TODO Properties without a parser are just for dirty hacks. + * qdev_prop_ptr is the only such PropertyInfo. It's marked + * for removal. This conditional should be removed along with + * it. + */ + 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); } return 1; @@ -682,6 +691,12 @@ static void qdev_print_props(Monitor *mon, DeviceState *dev, Property *props, if (!props) return; while (props->name) { + /* + * TODO Properties without a print method are just for dirty + * hacks. qdev_prop_ptr is the only such PropertyInfo. It's + * marked for removal. The test props->info->print should be + * removed along with it. + */ if (props->info->print) { props->info->print(dev, props, buf, sizeof(buf)); qdev_printf("%s-prop: %s = %s\n", prefix, props->name, buf);