From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57833) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUNfH-0006Eb-NS for qemu-devel@nongnu.org; Tue, 25 Aug 2015 19:30:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZUNfC-000163-O6 for qemu-devel@nongnu.org; Tue, 25 Aug 2015 19:30:03 -0400 Received: from e18.ny.us.ibm.com ([129.33.205.208]:50356) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUNfC-00015p-KD for qemu-devel@nongnu.org; Tue, 25 Aug 2015 19:29:58 -0400 Received: from /spool/local by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 25 Aug 2015 19:29:58 -0400 Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 41416C90042 for ; Tue, 25 Aug 2015 19:20:59 -0400 (EDT) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t7PNTsHp64618684 for ; Tue, 25 Aug 2015 23:29:54 GMT Received: from d01av02.pok.ibm.com (localhost [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t7PNTsd7004185 for ; Tue, 25 Aug 2015 19:29:54 -0400 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: References: <1440540624-7998-1-git-send-email-marcandre.lureau@redhat.com> <1440540624-7998-11-git-send-email-marcandre.lureau@redhat.com> <20150825230918.11069.54295@loki> Message-ID: <20150825232948.11069.70181@loki> Date: Tue, 25 Aug 2015 18:29:48 -0500 Subject: Re: [Qemu-devel] [PATCH v2 10/12] qga: add an optionnal qemu-ga.conf system configuration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Cc: QEMU Quoting Marc-Andr=C3=A9 Lureau (2015-08-25 18:18:16) > Hi > = > On Wed, Aug 26, 2015 at 1:09 AM, Michael Roth = wrote: > > We should probably do this in init_dfl_pathnames() for consistency. > = > QGA_FSFREEZE_HOOK_DEFAULT is also initialized here > = > in init_dfl_pathnames(), it depends on the value of > get_local_state_pathname() while here it's static. Ahh, yah I missed that. It's fine where it's at then. > = > >> > >> static struct { > >> const char *state_dir; > >> @@ -936,14 +937,80 @@ typedef struct GAConfig { > >> #ifdef _WIN32 > >> const char *service; > >> #endif > >> + gchar *bliststr; > >> GList *blacklist; > >> int daemonize; > >> GLogLevelFlags log_level; > >> } GAConfig; > >> > >> -static GAConfig *config_parse(int argc, char **argv) > >> +static void config_load(GAConfig *config) > >> +{ > >> + GError *gerr =3D NULL; > >> + GKeyFile *keyfile; > >> + > >> + /* read system config */ > >> + keyfile =3D g_key_file_new(); > >> + if (!g_key_file_load_from_file(keyfile, QGA_CONF_DEFAULT, 0, &ger= r)) { > >> + goto end; > >> + } > >> + if (g_key_file_has_key(keyfile, "general", "daemon", NULL)) { > >> + config->daemonize =3D > >> + g_key_file_get_boolean(keyfile, "general", "daemon", &ger= r); > >> + } > >> + if (g_key_file_has_key(keyfile, "general", "method", NULL)) { > >> + config->method =3D > >> + g_key_file_get_string(keyfile, "general", "method", &gerr= ); > >> + } > >> + if (g_key_file_has_key(keyfile, "general", "path", NULL)) { > >> + config->channel_path =3D > >> + g_key_file_get_string(keyfile, "general", "path", &gerr); > >> + } > >> + if (g_key_file_has_key(keyfile, "general", "logfile", NULL)) { > >> + config->log_filepath =3D > >> + g_key_file_get_string(keyfile, "general", "logfile", &ger= r); > >> + } > >> + if (g_key_file_has_key(keyfile, "general", "pidfile", NULL)) { > >> + config->pid_filepath =3D > >> + g_key_file_get_string(keyfile, "general", "pidfile", &ger= r); > >> + } > >> +#ifdef CONFIG_FSFREEZE > >> + if (g_key_file_has_key(keyfile, "general", "fsfreeze-hook", NULL)= ) { > >> + config->fsfreeze_hook =3D > >> + g_key_file_get_string(keyfile, > >> + "general", "fsfreeze-hook", &gerr); > >> + } > >> +#endif > >> + if (g_key_file_has_key(keyfile, "general", "statedir", NULL)) { > >> + config->state_dir =3D > >> + g_key_file_get_string(keyfile, "general", "statedir", &ge= rr); > >> + } > >> + if (g_key_file_has_key(keyfile, "general", "verbose", NULL) && > >> + g_key_file_get_boolean(keyfile, "general", "verbose", &gerr))= { > >> + /* enable all log levels */ > >> + config->log_level =3D G_LOG_LEVEL_MASK; > >> + } > >> + if (g_key_file_has_key(keyfile, "general", "blacklist", NULL)) { > >> + config->bliststr =3D > >> + g_key_file_get_string(keyfile, "general", "blacklist", &g= err); > >> + config->blacklist =3D g_list_concat(config->blacklist, > >> + split_list(config->bliststr= , ',')); > >> + } > >> + > >> +end: > >> + if (keyfile) { > >> + g_key_file_free(keyfile); > >> + } > >> + if (gerr && > >> + !(gerr->domain =3D=3D G_FILE_ERROR && gerr->code =3D=3D G_FIL= E_ERROR_NOENT)) { > >> + g_critical("error loading configuration from path: %s, %s", > >> + QGA_CONF_DEFAULT, gerr->message); > >> + exit(EXIT_FAILURE); > >> + } > >> + g_clear_error(&gerr); > > > > What about other file errors, like permission issues? Maybe just have > > config_load() return bool, and just spit out stringified gerr prior to > > return false? > = > all errors have a g_critical(), except for the case of file missing. Argh, missed the '!'. Looks good then: Reviewed-by: Michael Roth > = > = > -- = > Marc-Andr=C3=A9 Lureau >=20