From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 10/12] qga: add --dump-conf option
Date: Tue, 25 Aug 2015 12:11:38 -0500 [thread overview]
Message-ID: <20150825171138.11069.51537@loki> (raw)
In-Reply-To: <1435751267-26378-11-git-send-email-marcandre.lureau@gmail.com>
Quoting Marc-André Lureau (2015-07-01 06:47:45)
> This new option allows to review the agent configuration,
> and ease the task of writing a configuration file.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
> ---
> qga/main.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 45 insertions(+), 1 deletion(-)
>
> diff --git a/qga/main.c b/qga/main.c
> index bd87050..f6dbb3e 100644
> --- a/qga/main.c
> +++ b/qga/main.c
> @@ -215,6 +215,7 @@ static void usage(const char *cmd)
> #endif
> " -b, --blacklist comma-separated list of RPCs to disable (no spaces, \"?\"\n"
> " to list available RPCs)\n"
> +" -D, --dump-conf dump the configuration and exit\n"
> " -h, --help display this help and exit\n"
> "\n"
> "Report bugs to <mdroth@linux.vnet.ibm.com>\n"
> @@ -904,6 +905,21 @@ static void ga_print_cmd(QmpCommand *cmd, void *opaque)
> printf("%s\n", qmp_command_name(cmd));
> }
>
> +static gchar *list_join(GList *list, const gchar separator)
> +{
> + GString *str = g_string_new("");
> +
> + while (list) {
> + str = g_string_append(str, (gchar *)list->data);
> + list = g_list_next(list);
> + if (list) {
> + str = g_string_append_c(str, separator);
> + }
> + }
> +
> + return g_string_free(str, FALSE);
> +}
> +
> static GList *split_list(gchar *str, const gchar separator)
> {
> GList *list = NULL;
> @@ -936,9 +952,28 @@ static char *state_dir;
> static const char *service;
> #endif
> static GList *blacklist;
> -static int daemonize;
> +static int daemonize, dumpconf;
> static GLogLevelFlags log_level = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL;
>
> +static void dump_config(void)
> +{
> + gchar *bl = list_join(blacklist, ',');
> +
> + printf("[general]\n");
> + printf("daemonize = %d\n", daemonize);
> + printf("pidfile = %s\n", pid_filepath);
> + if (log_filepath) {
> + printf("logfile = %s\n", log_filepath);
> + }
> + printf("verbose = %d\n", log_level == G_LOG_LEVEL_MASK);
> + printf("method = %s\n", method);
> + printf("path = %s\n", device_path);
> + printf("statedir = %s\n", state_dir);
> + printf("blacklist = %s\n", bl);
I think we're missing fsfreeze_hook option here.
To me it seems cleaner to actually create the GKeyFile from current
options, then let GLib do all the work of generation a config file
we can spit out (g_key_file_to_data() should do it i think).
That, paired with the idea of having a GAConfig structure to
encapulate all the config options, might warrant restructuring
things a bit so that we have a
gkeyfile_to_gaconfig()/gkeyfile_from_gaconfig() pair to use for
reading/dumping configs while keeping all the options in an
easily trackable place.
> +
> + g_free(bl);
> +}
> +
> static void option_parse(int argc, char **argv)
> {
> const char *sopt = "hVvdm:p:l:f:F::b:s:t:D";
> @@ -946,6 +981,7 @@ static void option_parse(int argc, char **argv)
> const struct option lopt[] = {
> { "help", 0, NULL, 'h' },
> { "version", 0, NULL, 'V' },
> + { "dump-conf", 0, NULL, 'D' },
> { "logfile", 1, NULL, 'l' },
> { "pidfile", 1, NULL, 'f' },
> #ifdef CONFIG_FSFREEZE
> @@ -1031,6 +1067,9 @@ static void option_parse(int argc, char **argv)
> }
> break;
> #endif
> + case 'D':
> + dumpconf = 1;
> + break;
> case 'h':
> usage(argv[0]);
> exit(EXIT_SUCCESS);
> @@ -1205,6 +1244,11 @@ int main(int argc, char **argv)
> }
> }
>
> + if (dumpconf) {
> + dump_config();
> + goto end;
> + }
> +
> s->log_level = log_level;
> s->log_file = stderr;
> #ifdef CONFIG_FSFREEZE
> --
> 2.4.3
>
next prev parent reply other threads:[~2015-08-25 17:11 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-01 11:47 [Qemu-devel] [PATCH 00/12] qemu-ga: add a configuration file Marc-André Lureau
2015-07-01 11:47 ` [Qemu-devel] [PATCH 01/12] qga: misc spelling Marc-André Lureau
2015-07-30 15:05 ` Eric Blake
2015-08-25 18:17 ` Denis V. Lunev
2015-07-01 11:47 ` [Qemu-devel] [PATCH 02/12] qga: use exit() when parsing options Marc-André Lureau
2015-07-31 14:34 ` Eric Blake
2015-08-25 20:20 ` Denis V. Lunev
2015-07-01 11:47 ` [Qemu-devel] [PATCH 03/12] qga: move string split in seperate function Marc-André Lureau
2015-08-25 15:50 ` Michael Roth
2015-07-01 11:47 ` [Qemu-devel] [PATCH 04/12] qga: rename 'path' to 'device_path' Marc-André Lureau
2015-08-25 15:55 ` Michael Roth
2015-08-25 22:00 ` Marc-André Lureau
2015-07-01 11:47 ` [Qemu-devel] [PATCH 05/12] qga: copy argument strings Marc-André Lureau
2015-07-01 11:47 ` [Qemu-devel] [PATCH 06/12] qga: move option parsing to seperate function Marc-André Lureau
2015-08-25 16:24 ` Michael Roth
2015-08-25 21:59 ` Marc-André Lureau
2015-07-01 11:47 ` [Qemu-devel] [PATCH 07/12] qga: fill default options in main() Marc-André Lureau
2015-08-25 16:04 ` Michael Roth
2015-07-01 11:47 ` [Qemu-devel] [PATCH 08/12] qga: move agent run in a seperate function Marc-André Lureau
2015-08-25 16:51 ` Michael Roth
2015-08-25 21:59 ` Marc-André Lureau
2015-07-01 11:47 ` [Qemu-devel] [PATCH 09/12] qga: free a bit more Marc-André Lureau
2015-07-01 11:47 ` [Qemu-devel] [PATCH 10/12] qga: add --dump-conf option Marc-André Lureau
2015-08-25 17:11 ` Michael Roth [this message]
2015-08-25 21:58 ` Marc-André Lureau
2015-07-01 11:47 ` [Qemu-devel] [PATCH 11/12] qga: add an optionnal qemu-ga.conf system configuration Marc-André Lureau
2015-07-01 11:47 ` [Qemu-devel] [PATCH 12/12] qga: start a man page Marc-André Lureau
2015-08-25 17:43 ` Michael Roth
2015-08-25 21:57 ` Marc-André Lureau
2015-07-29 13:41 ` [Qemu-devel] [PATCH 00/12] qemu-ga: add a configuration file Marc-André Lureau
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=20150825171138.11069.51537@loki \
--to=mdroth@linux.vnet.ibm.com \
--cc=marcandre.lureau@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.