qga: relocate path to default configuration and hook

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2020-08-18 11:59:00 +02:00
parent f761b41a62
commit a9eacf8b4d

View File

@ -29,6 +29,7 @@
#include "qapi/error.h" #include "qapi/error.h"
#include "channel.h" #include "channel.h"
#include "qemu/bswap.h" #include "qemu/bswap.h"
#include "qemu/cutils.h"
#include "qemu/help_option.h" #include "qemu/help_option.h"
#include "qemu/sockets.h" #include "qemu/sockets.h"
#include "qemu/systemd.h" #include "qemu/systemd.h"
@ -968,7 +969,7 @@ static void config_load(GAConfig *config)
{ {
GError *gerr = NULL; GError *gerr = NULL;
GKeyFile *keyfile; GKeyFile *keyfile;
const char *conf = g_getenv("QGA_CONF") ?: QGA_CONF_DEFAULT; g_autofree char *conf = g_strdup(g_getenv("QGA_CONF")) ?: get_relocated_path(QGA_CONF_DEFAULT);
/* read system config */ /* read system config */
keyfile = g_key_file_new(); keyfile = g_key_file_new();
@ -1027,7 +1028,7 @@ end:
if (gerr && if (gerr &&
!(gerr->domain == G_FILE_ERROR && gerr->code == G_FILE_ERROR_NOENT)) { !(gerr->domain == G_FILE_ERROR && gerr->code == G_FILE_ERROR_NOENT)) {
g_critical("error loading configuration from path: %s, %s", g_critical("error loading configuration from path: %s, %s",
QGA_CONF_DEFAULT, gerr->message); conf, gerr->message);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
g_clear_error(&gerr); g_clear_error(&gerr);
@ -1141,7 +1142,7 @@ static void config_parse(GAConfig *config, int argc, char **argv)
#ifdef CONFIG_FSFREEZE #ifdef CONFIG_FSFREEZE
case 'F': case 'F':
g_free(config->fsfreeze_hook); g_free(config->fsfreeze_hook);
config->fsfreeze_hook = g_strdup(optarg ?: QGA_FSFREEZE_HOOK_DEFAULT); config->fsfreeze_hook = optarg ? g_strdup(optarg) : get_relocated_path(QGA_FSFREEZE_HOOK_DEFAULT);
break; break;
#endif #endif
case 't': case 't':
@ -1463,6 +1464,7 @@ int main(int argc, char **argv)
config->log_level = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL; config->log_level = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL;
qemu_init_exec_dir(argv[0]);
qga_qmp_init_marshal(&ga_commands); qga_qmp_init_marshal(&ga_commands);
init_dfl_pathnames(); init_dfl_pathnames();