From patchwork Wed Jul 1 11:47:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 490098 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9A01E1402A6 for ; Wed, 1 Jul 2015 21:59:06 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=k3F6a5DR; dkim-atps=neutral Received: from localhost ([::1]:57462 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAGfP-0007Wr-PR for incoming@patchwork.ozlabs.org; Wed, 01 Jul 2015 07:59:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54914) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAGVM-0007HG-Co for qemu-devel@nongnu.org; Wed, 01 Jul 2015 07:48:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZAGVK-0005PW-HZ for qemu-devel@nongnu.org; Wed, 01 Jul 2015 07:48:40 -0400 Received: from mail-qk0-x233.google.com ([2607:f8b0:400d:c09::233]:34924) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAGVK-0005PR-DA for qemu-devel@nongnu.org; Wed, 01 Jul 2015 07:48:38 -0400 Received: by qkbp125 with SMTP id p125so26964711qkb.2 for ; Wed, 01 Jul 2015 04:48:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=UbLnNbCeFdP2CXPZmUK3TMs+D7G8V2Lm9IEbAkKUDdI=; b=k3F6a5DRn+7pip7d08iEgGpZ707DZTxq65i+YsOH7mzwcnoMwaztPov5UrZnrUIUfn bUC5n+74TbpriAyJRf2XGJc3DZNOkaOj3rWCrRFuUsIX4+spq32ei28KHx8Xf3ZH7yui aHaGkOBkl7EXFxV0uWhtkrzGQbn9RXPQfJwOMIvDa8eBz27bUYIVMSLHLWUFPIYOTZNo gpCxW7ZkQuQpcHQy2uSp+dVt4ggqnPE2oOpiVs+8H/NDZxuspPbzykbgjkHNJPlRgT9B uIen8tdrSz0tniw3CecnfVUoxZrMrVTOt9cd5kSRjS8geIUtzsDWFIBE4C7rrbM5bmTi wkxg== X-Received: by 10.140.97.230 with SMTP id m93mr32858105qge.32.1435751318037; Wed, 01 Jul 2015 04:48:38 -0700 (PDT) Received: from localhost (bne75-h02-31-39-163-232.dsl.sta.abo.bbox.fr. [31.39.163.232]) by mx.google.com with ESMTPSA id 29sm789099qkr.47.2015.07.01.04.48.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Jul 2015 04:48:37 -0700 (PDT) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 1 Jul 2015 13:47:45 +0200 Message-Id: <1435751267-26378-11-git-send-email-marcandre.lureau@gmail.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1435751267-26378-1-git-send-email-marcandre.lureau@gmail.com> References: <1435751267-26378-1-git-send-email-marcandre.lureau@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c09::233 Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , mdroth@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 10/12] qga: add --dump-conf 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 new option allows to review the agent configuration, and ease the task of writing a configuration file. Signed-off-by: Marc-André Lureau --- 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 \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); + + 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