]>
Commit | Line | Data |
---|---|---|
42074a9d MR |
1 | /* |
2 | * QEMU Guest Agent common/cross-platform command implementations | |
3 | * | |
4 | * Copyright IBM Corp. 2012 | |
5 | * | |
6 | * Authors: | |
7 | * Michael Roth <[email protected]> | |
8 | * | |
9 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | |
10 | * See the COPYING file in the top-level directory. | |
11 | */ | |
12 | ||
13 | #include <glib.h> | |
14 | #include "qga/guest-agent-core.h" | |
15 | #include "qga-qmp-commands.h" | |
16 | #include "qerror.h" | |
17 | ||
18 | /* Note: in some situations, like with the fsfreeze, logging may be | |
19 | * temporarilly disabled. if it is necessary that a command be able | |
20 | * to log for accounting purposes, check ga_logging_enabled() beforehand, | |
21 | * and use the QERR_QGA_LOGGING_DISABLED to generate an error | |
22 | */ | |
23 | void slog(const gchar *fmt, ...) | |
24 | { | |
25 | va_list ap; | |
26 | ||
27 | va_start(ap, fmt); | |
28 | g_logv("syslog", G_LOG_LEVEL_INFO, fmt, ap); | |
29 | va_end(ap); | |
30 | } | |
31 | ||
32 | int64_t qmp_guest_sync(int64_t id, Error **errp) | |
33 | { | |
34 | return id; | |
35 | } | |
36 | ||
37 | void qmp_guest_ping(Error **err) | |
38 | { | |
39 | slog("guest-ping called"); | |
40 | } | |
41 | ||
42 | struct GuestAgentInfo *qmp_guest_info(Error **err) | |
43 | { | |
44 | GuestAgentInfo *info = g_malloc0(sizeof(GuestAgentInfo)); | |
45 | GuestAgentCommandInfo *cmd_info; | |
46 | GuestAgentCommandInfoList *cmd_info_list; | |
47 | char **cmd_list_head, **cmd_list; | |
48 | ||
49 | info->version = g_strdup(QGA_VERSION); | |
50 | ||
51 | cmd_list_head = cmd_list = qmp_get_command_list(); | |
52 | if (*cmd_list_head == NULL) { | |
53 | goto out; | |
54 | } | |
55 | ||
56 | while (*cmd_list) { | |
57 | cmd_info = g_malloc0(sizeof(GuestAgentCommandInfo)); | |
58 | cmd_info->name = strdup(*cmd_list); | |
59 | cmd_info->enabled = qmp_command_is_enabled(cmd_info->name); | |
60 | ||
61 | cmd_info_list = g_malloc0(sizeof(GuestAgentCommandInfoList)); | |
62 | cmd_info_list->value = cmd_info; | |
63 | cmd_info_list->next = info->supported_commands; | |
64 | info->supported_commands = cmd_info_list; | |
65 | ||
66 | g_free(*cmd_list); | |
67 | cmd_list++; | |
68 | } | |
69 | ||
70 | out: | |
71 | g_free(cmd_list_head); | |
72 | return info; | |
73 | } |