]>
Commit | Line | Data |
---|---|---|
bab46b81 MA |
1 | /* |
2 | * HMP commands related to run state | |
3 | * | |
4 | * Copyright IBM, Corp. 2011 | |
5 | * | |
6 | * Authors: | |
7 | * Anthony Liguori <aliguori@us.ibm.com> | |
8 | * | |
9 | * This work is licensed under the terms of the GNU GPL, version 2. See | |
10 | * the COPYING file in the top-level directory. | |
11 | * | |
12 | * Contributions after 2012-01-13 are licensed under the terms of the | |
13 | * GNU GPL, version 2 or (at your option) any later version. | |
14 | */ | |
15 | ||
16 | #include "qemu/osdep.h" | |
17 | #include "exec/cpu-common.h" | |
18 | #include "monitor/hmp.h" | |
19 | #include "monitor/monitor.h" | |
20 | #include "qapi/error.h" | |
21 | #include "qapi/qapi-commands-run-state.h" | |
22 | #include "qapi/qmp/qdict.h" | |
23 | ||
24 | void hmp_info_status(Monitor *mon, const QDict *qdict) | |
25 | { | |
26 | StatusInfo *info; | |
27 | ||
28 | info = qmp_query_status(NULL); | |
29 | ||
30 | monitor_printf(mon, "VM status: %s%s", | |
31 | info->running ? "running" : "paused", | |
32 | info->singlestep ? " (single step mode)" : ""); | |
33 | ||
34 | if (!info->running && info->status != RUN_STATE_PAUSED) { | |
35 | monitor_printf(mon, " (%s)", RunState_str(info->status)); | |
36 | } | |
37 | ||
38 | monitor_printf(mon, "\n"); | |
39 | ||
40 | qapi_free_StatusInfo(info); | |
41 | } | |
42 | ||
43 | void hmp_singlestep(Monitor *mon, const QDict *qdict) | |
44 | { | |
45 | const char *option = qdict_get_try_str(qdict, "option"); | |
46 | if (!option || !strcmp(option, "on")) { | |
47 | singlestep = 1; | |
48 | } else if (!strcmp(option, "off")) { | |
49 | singlestep = 0; | |
50 | } else { | |
51 | monitor_printf(mon, "unexpected option %s\n", option); | |
52 | } | |
53 | } | |
54 | ||
55 | void hmp_watchdog_action(Monitor *mon, const QDict *qdict) | |
56 | { | |
57 | Error *err = NULL; | |
58 | WatchdogAction action; | |
59 | char *qapi_value; | |
60 | ||
61 | qapi_value = g_ascii_strdown(qdict_get_str(qdict, "action"), -1); | |
62 | action = qapi_enum_parse(&WatchdogAction_lookup, qapi_value, -1, &err); | |
63 | g_free(qapi_value); | |
64 | if (err) { | |
65 | hmp_handle_error(mon, err); | |
66 | return; | |
67 | } | |
68 | qmp_watchdog_set_action(action, &error_abort); | |
69 | } | |
70 | ||
71 | void watchdog_action_completion(ReadLineState *rs, int nb_args, const char *str) | |
72 | { | |
73 | int i; | |
74 | ||
75 | if (nb_args != 2) { | |
76 | return; | |
77 | } | |
78 | readline_set_completion_index(rs, strlen(str)); | |
79 | for (i = 0; i < WATCHDOG_ACTION__MAX; i++) { | |
80 | readline_add_completion_of(rs, str, WatchdogAction_str(i)); | |
81 | } | |
82 | } |