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