From: Michael Roth <mdroth@linux.vnet.ibm.com>
To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 11/12] qga: add --dump-conf option
Date: Tue, 25 Aug 2015 18:13:18 -0500 [thread overview]
Message-ID: <20150825231318.11069.90786@loki> (raw)
In-Reply-To: <1440540624-7998-12-git-send-email-marcandre.lureau@redhat.com>
Quoting marcandre.lureau@redhat.com (2015-08-25 17:10:23)
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> 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@redhat.com>
> ---
> qga/main.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 62 insertions(+)
>
> diff --git a/qga/main.c b/qga/main.c
> index 154975c..a47310b 100644
> --- a/qga/main.c
> +++ b/qga/main.c
> @@ -941,6 +941,7 @@ typedef struct GAConfig {
> GList *blacklist;
> int daemonize;
> GLogLevelFlags log_level;
> + int dumpconf;
> } GAConfig;
>
> static void config_load(GAConfig *config)
> @@ -1009,6 +1010,58 @@ end:
> g_clear_error(&gerr);
> }
>
> +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 void config_dump(GAConfig *config)
> +{
> + GError *error = NULL;
> + GKeyFile *keyfile;
> + gchar *tmp;
> +
> + keyfile = g_key_file_new();
> + g_key_file_set_boolean(keyfile, "general", "daemon", config->daemonize);
> + g_key_file_set_string(keyfile, "general", "method", config->method);
> + g_key_file_set_string(keyfile, "general", "path", config->channel_path);
> + if (config->log_filepath) {
> + g_key_file_set_string(keyfile, "general", "logfile",
> + config->log_filepath);
> + }
> + g_key_file_set_string(keyfile, "general", "pidfile", config->pid_filepath);
> +#ifdef CONFIG_FSFREEZE
> + if (config->fsfreeze_hook) {
> + g_key_file_set_string(keyfile, "general", "fsfreeze-hook",
> + config->fsfreeze_hook);
> + }
> +#endif
> + g_key_file_set_string(keyfile, "general", "statedir", config->state_dir);
> + g_key_file_set_boolean(keyfile, "general", "verbose",
> + config->log_level == G_LOG_LEVEL_MASK);
> + tmp = list_join(config->blacklist, ',');
Since we have the list_join() helper to convert config->blacklist, it
makes me wonder if there's really any need to add/init config->bliststr
in the previous patch.
This patch looks good though:
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> + g_key_file_set_string(keyfile, "general", "blacklist", tmp);
> + g_free(tmp);
> +
> + tmp = g_key_file_to_data(keyfile, NULL, &error);
> + printf("%s", tmp);
> +
> + g_free(tmp);
> + if (keyfile) {
> + g_key_file_free(keyfile);
> + }
> +}
> +
> static void config_parse(GAConfig *config, int argc, char **argv)
> {
> const char *sopt = "hVvdm:p:l:f:F::b:s:t:D";
> @@ -1016,6 +1069,7 @@ static void config_parse(GAConfig *config, 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
> @@ -1067,6 +1121,9 @@ static void config_parse(GAConfig *config, int argc, char **argv)
> case 'd':
> config->daemonize = 1;
> break;
> + case 'D':
> + config->dumpconf = 1;
> + break;
> case 'b': {
> if (is_help_option(optarg)) {
> qmp_for_each_command(ga_print_cmd, NULL);
> @@ -1310,6 +1367,11 @@ int main(int argc, char **argv)
> config->state_dir);
> s->frozen = check_is_frozen(s);
>
> + if (config->dumpconf) {
> + config_dump(config);
> + goto end;
> + }
> +
> ret = run_agent(s, config);
>
> end:
> --
> 2.4.3
>
next prev parent reply other threads:[~2015-08-25 23:13 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-25 22:10 [Qemu-devel] [PATCH v2 00/12] qemu-ga: add a configuration file marcandre.lureau
2015-08-25 22:10 ` [Qemu-devel] [PATCH v2 01/12] qga: misc spelling marcandre.lureau
2015-08-25 22:26 ` Michael Roth
2015-08-25 22:30 ` Eric Blake
2015-08-25 22:36 ` Marc-André Lureau
2015-08-25 22:10 ` [Qemu-devel] [PATCH v2 02/12] qga: use exit() when parsing options marcandre.lureau
2015-08-25 22:27 ` Michael Roth
2015-08-25 22:10 ` [Qemu-devel] [PATCH v2 03/12] qga: move string split in separate function marcandre.lureau
2015-08-25 22:10 ` [Qemu-devel] [PATCH v2 04/12] qga: rename 'path' to 'channel_path' marcandre.lureau
2015-08-25 22:29 ` Michael Roth
2015-08-25 22:10 ` [Qemu-devel] [PATCH v2 05/12] qga: copy argument strings marcandre.lureau
2015-08-25 22:31 ` Michael Roth
2015-08-25 22:10 ` [Qemu-devel] [PATCH v2 06/12] qga: move option parsing to seperate function marcandre.lureau
2015-08-25 22:40 ` Michael Roth
2015-08-25 22:10 ` [Qemu-devel] [PATCH v2 07/12] qga: fill default options in main() marcandre.lureau
2015-08-25 22:46 ` Michael Roth
2015-08-25 22:59 ` Marc-André Lureau
2015-08-25 22:10 ` [Qemu-devel] [PATCH v2 08/12] qga: move agent run in a seperate function marcandre.lureau
2015-08-25 22:55 ` Michael Roth
2015-08-25 22:10 ` [Qemu-devel] [PATCH v2 09/12] qga: free a bit more marcandre.lureau
2015-08-25 22:10 ` [Qemu-devel] [PATCH v2 10/12] qga: add an optionnal qemu-ga.conf system configuration marcandre.lureau
2015-08-25 23:09 ` Michael Roth
2015-08-25 23:18 ` Marc-André Lureau
2015-08-25 23:29 ` Michael Roth
2015-08-26 8:01 ` Markus Armbruster
2015-08-25 22:10 ` [Qemu-devel] [PATCH v2 11/12] qga: add --dump-conf option marcandre.lureau
2015-08-25 23:13 ` Michael Roth [this message]
2015-08-25 23:31 ` Marc-André Lureau
2015-08-25 22:10 ` [Qemu-devel] [PATCH v2 12/12] qga: start a man page marcandre.lureau
2015-08-25 23:16 ` Michael Roth
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=20150825231318.11069.90786@loki \
--to=mdroth@linux.vnet.ibm.com \
--cc=marcandre.lureau@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).