]>
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" | |
93cbd6c9 | 23 | #include "qemu/accel.h" |
bab46b81 MA |
24 | |
25 | void hmp_info_status(Monitor *mon, const QDict *qdict) | |
26 | { | |
27 | StatusInfo *info; | |
28 | ||
29 | info = qmp_query_status(NULL); | |
30 | ||
e726acd5 PM |
31 | monitor_printf(mon, "VM status: %s", |
32 | info->running ? "running" : "paused"); | |
bab46b81 MA |
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 | ||
e9ccfdd9 | 43 | void hmp_one_insn_per_tb(Monitor *mon, const QDict *qdict) |
bab46b81 MA |
44 | { |
45 | const char *option = qdict_get_try_str(qdict, "option"); | |
93cbd6c9 PM |
46 | AccelState *accel = current_accel(); |
47 | bool newval; | |
48 | ||
49 | if (!object_property_find(OBJECT(accel), "one-insn-per-tb")) { | |
50 | monitor_printf(mon, | |
51 | "This accelerator does not support setting one-insn-per-tb\n"); | |
52 | return; | |
53 | } | |
54 | ||
bab46b81 | 55 | if (!option || !strcmp(option, "on")) { |
93cbd6c9 | 56 | newval = true; |
bab46b81 | 57 | } else if (!strcmp(option, "off")) { |
93cbd6c9 | 58 | newval = false; |
bab46b81 MA |
59 | } else { |
60 | monitor_printf(mon, "unexpected option %s\n", option); | |
93cbd6c9 | 61 | return; |
bab46b81 | 62 | } |
93cbd6c9 PM |
63 | /* If the property exists then setting it can never fail */ |
64 | object_property_set_bool(OBJECT(accel), "one-insn-per-tb", | |
65 | newval, &error_abort); | |
bab46b81 MA |
66 | } |
67 | ||
68 | void hmp_watchdog_action(Monitor *mon, const QDict *qdict) | |
69 | { | |
70 | Error *err = NULL; | |
71 | WatchdogAction action; | |
72 | char *qapi_value; | |
73 | ||
74 | qapi_value = g_ascii_strdown(qdict_get_str(qdict, "action"), -1); | |
75 | action = qapi_enum_parse(&WatchdogAction_lookup, qapi_value, -1, &err); | |
76 | g_free(qapi_value); | |
77 | if (err) { | |
78 | hmp_handle_error(mon, err); | |
79 | return; | |
80 | } | |
81 | qmp_watchdog_set_action(action, &error_abort); | |
82 | } | |
83 | ||
84 | void watchdog_action_completion(ReadLineState *rs, int nb_args, const char *str) | |
85 | { | |
86 | int i; | |
87 | ||
88 | if (nb_args != 2) { | |
89 | return; | |
90 | } | |
91 | readline_set_completion_index(rs, strlen(str)); | |
92 | for (i = 0; i < WATCHDOG_ACTION__MAX; i++) { | |
93 | readline_add_completion_of(rs, str, WatchdogAction_str(i)); | |
94 | } | |
95 | } |