[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 2/3] implement -readconfig help=defconfig option
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [RFC PATCH 2/3] implement -readconfig help=defconfig option |
Date: |
Mon, 19 Mar 2012 12:08:41 -0300 |
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 <address@hidden>
---
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