From patchwork Mon Mar 19 15:08:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 147545 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 62281B6FA8 for ; Tue, 20 Mar 2012 02:09:08 +1100 (EST) Received: from localhost ([::1]:41250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9eCn-0001Xn-JE for incoming@patchwork.ozlabs.org; Mon, 19 Mar 2012 11:09:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9eCb-0001Tm-LJ for qemu-devel@nongnu.org; Mon, 19 Mar 2012 11:08:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S9eCS-0000Ev-OO for qemu-devel@nongnu.org; Mon, 19 Mar 2012 11:08:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57739) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9eCS-0000EV-Fm for qemu-devel@nongnu.org; Mon, 19 Mar 2012 11:08:44 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2JF8hca017660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 19 Mar 2012 11:08:43 -0400 Received: from blackpad.lan.raisama.net (ovpn-116-25.ams2.redhat.com [10.36.116.25]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q2JF8fSF008044 for ; Mon, 19 Mar 2012 11:08:42 -0400 Received: by blackpad.lan.raisama.net (Postfix, from userid 500) id F2566200C54; Mon, 19 Mar 2012 12:08:42 -0300 (BRT) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Mon, 19 Mar 2012 12:08:41 -0300 Message-Id: <1332169722-11126-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1332169722-11126-1-git-send-email-ehabkost@redhat.com> References: <1332169722-11126-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 2/3] implement -readconfig help=defconfig option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This method will list the paths of all default config files. This is where the placement of qemu_read_config_arg() on qemu-config-arch.c becomes necessary: we have to use the list of config files to implement the new help option. Signed-off-by: Eduardo Habkost --- qemu-config-arch.c | 27 ++++++++++++++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-) diff --git a/qemu-config-arch.c b/qemu-config-arch.c index 83a0c89..832f0b0 100644 --- a/qemu-config-arch.c +++ b/qemu-config-arch.c @@ -41,6 +41,10 @@ static QemuOptsList qemu_readconfig_opts = { .name = "fd", .type = QEMU_OPT_NUMBER, }, + { + .name = "help", + .type = QEMU_OPT_STRING, + }, { /*End of list */ } }, }; @@ -70,6 +74,22 @@ static struct DefaultConfigFile arch_default_configs[] = { {NULL, NULL}, }; +/* print -readconfig help information + */ +static void readconfig_help(const char *arg) +{ + if (!strcmp(arg, "defconfig")) { + const struct DefaultConfigFile *cfg; + printf("Default config files:\n"); + for (cfg = arch_default_configs; cfg->path; cfg++) { + printf("\t%s:\t%s\n", cfg->type, cfg->path); + } + } else { + fprintf(stderr, "Invalid readconfig help option: %s\n", arg); + exit(1); + } +} + /* Read Qemu config file based on parsed QemuOpts object * * Returns 0 on success, -errno on failure. @@ -79,12 +99,17 @@ static int qemu_read_config_opts(QemuOpts *opts) int fd = -1; uint64_t fd_arg = qemu_opt_get_number(opts, "fd", (uint64_t)-1); const char *path = qemu_opt_get(opts, "path"); + const char *help = qemu_opt_get(opts, "help"); + if (fd_arg != (uint64_t)-1) { fd = fd_arg; } - if (path) { + if (help) { + readconfig_help(help); + exit(0); + } else if (path) { return qemu_read_config_filename(path); } else if (fd >= 0) { return qemu_read_config_fd(fd);