summaryrefslogtreecommitdiff
path: root/qga
diff options
context:
space:
mode:
Diffstat (limited to 'qga')
-rw-r--r--qga/commands.c2
-rw-r--r--qga/guest-agent-core.h2
-rw-r--r--qga/main.c19
3 files changed, 13 insertions, 10 deletions
diff --git a/qga/commands.c b/qga/commands.c
index edd3e830e6..4d92946820 100644
--- a/qga/commands.c
+++ b/qga/commands.c
@@ -75,7 +75,7 @@ struct GuestAgentInfo *qmp_guest_info(Error **errp)
GuestAgentInfo *info = g_new0(GuestAgentInfo, 1);
info->version = g_strdup(QEMU_VERSION);
- qmp_for_each_command(qmp_command_info, info);
+ qmp_for_each_command(&ga_commands, qmp_command_info, info);
return info;
}
diff --git a/qga/guest-agent-core.h b/qga/guest-agent-core.h
index 63e9d398ae..3e8a4acff2 100644
--- a/qga/guest-agent-core.h
+++ b/qga/guest-agent-core.h
@@ -18,7 +18,9 @@
typedef struct GAState GAState;
typedef struct GACommandState GACommandState;
+
extern GAState *ga_state;
+extern QmpCommandList ga_commands;
GList *ga_command_blacklist_init(GList *blacklist);
void ga_command_state_init(GAState *s, GACommandState *cs);
diff --git a/qga/main.c b/qga/main.c
index 675ef81dc2..92658bc0e2 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -93,6 +93,7 @@ struct GAState {
};
struct GAState *ga_state;
+QmpCommandList ga_commands;
/* commands that are safe to issue while filesystems are frozen */
static const char *ga_freeze_whitelist[] = {
@@ -402,7 +403,7 @@ static void ga_disable_non_whitelisted(QmpCommand *cmd, void *opaque)
}
if (!whitelisted) {
g_debug("disabling command: %s", name);
- qmp_disable_command(name);
+ qmp_disable_command(&ga_commands, name);
}
}
@@ -415,7 +416,7 @@ static void ga_enable_non_blacklisted(QmpCommand *cmd, void *opaque)
if (g_list_find_custom(blacklist, name, ga_strcmp) == NULL &&
!qmp_command_is_enabled(cmd)) {
g_debug("enabling command: %s", name);
- qmp_enable_command(name);
+ qmp_enable_command(&ga_commands, name);
}
}
@@ -452,7 +453,7 @@ void ga_set_frozen(GAState *s)
return;
}
/* disable all non-whitelisted (for frozen state) commands */
- qmp_for_each_command(ga_disable_non_whitelisted, NULL);
+ qmp_for_each_command(&ga_commands, ga_disable_non_whitelisted, NULL);
g_warning("disabling logging due to filesystem freeze");
ga_disable_logging(s);
s->frozen = true;
@@ -488,7 +489,7 @@ void ga_unset_frozen(GAState *s)
}
/* enable all disabled, non-blacklisted commands */
- qmp_for_each_command(ga_enable_non_blacklisted, s->blacklist);
+ qmp_for_each_command(&ga_commands, ga_enable_non_blacklisted, s->blacklist);
s->frozen = false;
if (!ga_delete_file(s->state_filepath_isfrozen)) {
g_warning("unable to delete %s, fsfreeze may not function properly",
@@ -587,7 +588,7 @@ static void process_command(GAState *s, QDict *req)
g_assert(req);
g_debug("processing command");
- rsp = qmp_dispatch(QOBJECT(req));
+ rsp = qmp_dispatch(&ga_commands, QOBJECT(req));
if (rsp) {
ret = send_response(s, rsp);
if (ret < 0) {
@@ -1155,7 +1156,7 @@ static void config_parse(GAConfig *config, int argc, char **argv)
break;
case 'b': {
if (is_help_option(optarg)) {
- qmp_for_each_command(ga_print_cmd, NULL);
+ qmp_for_each_command(&ga_commands, ga_print_cmd, NULL);
exit(EXIT_SUCCESS);
}
config->blacklist = g_list_concat(config->blacklist,
@@ -1283,7 +1284,7 @@ static int run_agent(GAState *s, GAConfig *config)
s->deferred_options.log_filepath = config->log_filepath;
}
ga_disable_logging(s);
- qmp_for_each_command(ga_disable_non_whitelisted, NULL);
+ qmp_for_each_command(&ga_commands, ga_disable_non_whitelisted, NULL);
} else {
if (config->daemonize) {
become_daemon(config->pid_filepath);
@@ -1313,7 +1314,7 @@ static int run_agent(GAState *s, GAConfig *config)
s->blacklist = config->blacklist;
do {
g_debug("disabling command: %s", (char *)l->data);
- qmp_disable_command(l->data);
+ qmp_disable_command(&ga_commands, l->data);
l = g_list_next(l);
} while (l);
}
@@ -1360,7 +1361,7 @@ int main(int argc, char **argv)
config->log_level = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL;
- module_call_init(MODULE_INIT_QAPI);
+ qga_qmp_init_marshal(&ga_commands);
init_dfl_pathnames();
config_load(config);