Anthony Liguori | 48a32be | 2011-09-02 12:34:48 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Human Monitor Interface |
| 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 | */ |
| 13 | |
| 14 | #include "hmp.h" |
| 15 | #include "qmp-commands.h" |
| 16 | |
| 17 | void hmp_info_name(Monitor *mon) |
| 18 | { |
| 19 | NameInfo *info; |
| 20 | |
| 21 | info = qmp_query_name(NULL); |
| 22 | if (info->has_name) { |
| 23 | monitor_printf(mon, "%s\n", info->name); |
| 24 | } |
| 25 | qapi_free_NameInfo(info); |
| 26 | } |
Luiz Capitulino | b9c15f1 | 2011-08-26 17:38:13 -0300 | [diff] [blame] | 27 | |
| 28 | void hmp_info_version(Monitor *mon) |
| 29 | { |
| 30 | VersionInfo *info; |
| 31 | |
| 32 | info = qmp_query_version(NULL); |
| 33 | |
| 34 | monitor_printf(mon, "%" PRId64 ".%" PRId64 ".%" PRId64 "%s\n", |
| 35 | info->qemu.major, info->qemu.minor, info->qemu.micro, |
| 36 | info->package); |
| 37 | |
| 38 | qapi_free_VersionInfo(info); |
| 39 | } |
Luiz Capitulino | 292a260 | 2011-09-12 15:10:53 -0300 | [diff] [blame] | 40 | |
| 41 | void hmp_info_kvm(Monitor *mon) |
| 42 | { |
| 43 | KvmInfo *info; |
| 44 | |
| 45 | info = qmp_query_kvm(NULL); |
| 46 | monitor_printf(mon, "kvm support: "); |
| 47 | if (info->present) { |
| 48 | monitor_printf(mon, "%s\n", info->enabled ? "enabled" : "disabled"); |
| 49 | } else { |
| 50 | monitor_printf(mon, "not compiled\n"); |
| 51 | } |
| 52 | |
| 53 | qapi_free_KvmInfo(info); |
| 54 | } |
| 55 | |
Luiz Capitulino | 1fa9a5e | 2011-09-12 17:54:20 -0300 | [diff] [blame] | 56 | void hmp_info_status(Monitor *mon) |
| 57 | { |
| 58 | StatusInfo *info; |
| 59 | |
| 60 | info = qmp_query_status(NULL); |
| 61 | |
| 62 | monitor_printf(mon, "VM status: %s%s", |
| 63 | info->running ? "running" : "paused", |
| 64 | info->singlestep ? " (single step mode)" : ""); |
| 65 | |
| 66 | if (!info->running && info->status != RUN_STATE_PAUSED) { |
| 67 | monitor_printf(mon, " (%s)", RunState_lookup[info->status]); |
| 68 | } |
| 69 | |
| 70 | monitor_printf(mon, "\n"); |
| 71 | |
| 72 | qapi_free_StatusInfo(info); |
| 73 | } |
| 74 | |
Luiz Capitulino | efab767 | 2011-09-13 17:16:25 -0300 | [diff] [blame] | 75 | void hmp_info_uuid(Monitor *mon) |
| 76 | { |
| 77 | UuidInfo *info; |
| 78 | |
| 79 | info = qmp_query_uuid(NULL); |
| 80 | monitor_printf(mon, "%s\n", info->UUID); |
| 81 | qapi_free_UuidInfo(info); |
| 82 | } |
Luiz Capitulino | c5a415a | 2011-09-14 16:05:49 -0300 | [diff] [blame] | 83 | |
| 84 | void hmp_info_chardev(Monitor *mon) |
| 85 | { |
| 86 | ChardevInfoList *char_info, *info; |
| 87 | |
| 88 | char_info = qmp_query_chardev(NULL); |
| 89 | for (info = char_info; info; info = info->next) { |
| 90 | monitor_printf(mon, "%s: filename=%s\n", info->value->label, |
| 91 | info->value->filename); |
| 92 | } |
| 93 | |
| 94 | qapi_free_ChardevInfoList(char_info); |
| 95 | } |
Luiz Capitulino | 7a7f325 | 2011-09-15 14:20:28 -0300 | [diff] [blame] | 96 | |
| 97 | void hmp_quit(Monitor *mon, const QDict *qdict) |
| 98 | { |
| 99 | monitor_suspend(mon); |
| 100 | qmp_quit(NULL); |
| 101 | } |
Luiz Capitulino | 5f158f2 | 2011-09-15 14:34:39 -0300 | [diff] [blame] | 102 | |
| 103 | void hmp_stop(Monitor *mon, const QDict *qdict) |
| 104 | { |
| 105 | qmp_stop(NULL); |
| 106 | } |
Luiz Capitulino | 38d2265 | 2011-09-15 14:41:46 -0300 | [diff] [blame] | 107 | |
| 108 | void hmp_system_reset(Monitor *mon, const QDict *qdict) |
| 109 | { |
| 110 | qmp_system_reset(NULL); |
| 111 | } |
Luiz Capitulino | 5bc465e | 2011-09-28 11:06:15 -0300 | [diff] [blame] | 112 | |
| 113 | void hmp_system_powerdown(Monitor *mon, const QDict *qdict) |
| 114 | { |
| 115 | qmp_system_powerdown(NULL); |
| 116 | } |