qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [RFC PATCH 2/3] implement -readconfig help=defconfig option
Date: Mon, 19 Mar 2012 12:08:41 -0300	[thread overview]
Message-ID: <1332169722-11126-3-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1332169722-11126-1-git-send-email-ehabkost@redhat.com>

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 <ehabkost@redhat.com>
---
 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);
-- 
1.7.3.2

  parent reply	other threads:[~2012-03-19 15:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-19 15:08 [Qemu-devel] [RFC PATCH 0/3] Move CPU model config file to /usr/share Eduardo Habkost
2012-03-19 15:08 ` [Qemu-devel] [RFC PATCH 1/3] move list of default config files to qemu-config-arch.c Eduardo Habkost
2012-03-19 15:08 ` Eduardo Habkost [this message]
2012-03-19 15:08 ` [Qemu-devel] [RFC PATCH 3/3] move cpudef config sections to /usr/share/qemu/cpudefs-x86_64.conf Eduardo Habkost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1332169722-11126-3-git-send-email-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).