machine: Move HMP commands from monitor/ to hw/core/
This moves these commands from MAINTAINERS section "Human Monitor (HMP)" to "Machine core". Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230124121946.1139465-11-armbru@redhat.com>
This commit is contained in:
parent
d9c631ea9f
commit
85ea9dfedd
@ -134,3 +134,211 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict)
|
||||
qapi_free_MemdevList(memdev_list);
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
void hmp_info_kvm(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
KvmInfo *info;
|
||||
|
||||
info = qmp_query_kvm(NULL);
|
||||
monitor_printf(mon, "kvm support: ");
|
||||
if (info->present) {
|
||||
monitor_printf(mon, "%s\n", info->enabled ? "enabled" : "disabled");
|
||||
} else {
|
||||
monitor_printf(mon, "not compiled\n");
|
||||
}
|
||||
|
||||
qapi_free_KvmInfo(info);
|
||||
}
|
||||
|
||||
void hmp_info_uuid(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
UuidInfo *info;
|
||||
|
||||
info = qmp_query_uuid(NULL);
|
||||
monitor_printf(mon, "%s\n", info->UUID);
|
||||
qapi_free_UuidInfo(info);
|
||||
}
|
||||
|
||||
void hmp_info_balloon(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
BalloonInfo *info;
|
||||
Error *err = NULL;
|
||||
|
||||
info = qmp_query_balloon(&err);
|
||||
if (hmp_handle_error(mon, err)) {
|
||||
return;
|
||||
}
|
||||
|
||||
monitor_printf(mon, "balloon: actual=%" PRId64 "\n", info->actual >> 20);
|
||||
|
||||
qapi_free_BalloonInfo(info);
|
||||
}
|
||||
|
||||
void hmp_system_reset(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
qmp_system_reset(NULL);
|
||||
}
|
||||
|
||||
void hmp_system_powerdown(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
qmp_system_powerdown(NULL);
|
||||
}
|
||||
|
||||
void hmp_memsave(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
uint32_t size = qdict_get_int(qdict, "size");
|
||||
const char *filename = qdict_get_str(qdict, "filename");
|
||||
uint64_t addr = qdict_get_int(qdict, "val");
|
||||
Error *err = NULL;
|
||||
int cpu_index = monitor_get_cpu_index(mon);
|
||||
|
||||
if (cpu_index < 0) {
|
||||
monitor_printf(mon, "No CPU available\n");
|
||||
return;
|
||||
}
|
||||
|
||||
qmp_memsave(addr, size, filename, true, cpu_index, &err);
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
void hmp_pmemsave(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
uint32_t size = qdict_get_int(qdict, "size");
|
||||
const char *filename = qdict_get_str(qdict, "filename");
|
||||
uint64_t addr = qdict_get_int(qdict, "val");
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_pmemsave(addr, size, filename, &err);
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
void hmp_system_wakeup(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_system_wakeup(&err);
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
void hmp_nmi(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_inject_nmi(&err);
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
void hmp_balloon(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
int64_t value = qdict_get_int(qdict, "value");
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_balloon(value, &err);
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
Error *err = NULL;
|
||||
MemoryDeviceInfoList *info_list = qmp_query_memory_devices(&err);
|
||||
MemoryDeviceInfoList *info;
|
||||
VirtioPMEMDeviceInfo *vpi;
|
||||
VirtioMEMDeviceInfo *vmi;
|
||||
MemoryDeviceInfo *value;
|
||||
PCDIMMDeviceInfo *di;
|
||||
SgxEPCDeviceInfo *se;
|
||||
|
||||
for (info = info_list; info; info = info->next) {
|
||||
value = info->value;
|
||||
|
||||
if (value) {
|
||||
switch (value->type) {
|
||||
case MEMORY_DEVICE_INFO_KIND_DIMM:
|
||||
case MEMORY_DEVICE_INFO_KIND_NVDIMM:
|
||||
di = value->type == MEMORY_DEVICE_INFO_KIND_DIMM ?
|
||||
value->u.dimm.data : value->u.nvdimm.data;
|
||||
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
|
||||
MemoryDeviceInfoKind_str(value->type),
|
||||
di->id ? di->id : "");
|
||||
monitor_printf(mon, " addr: 0x%" PRIx64 "\n", di->addr);
|
||||
monitor_printf(mon, " slot: %" PRId64 "\n", di->slot);
|
||||
monitor_printf(mon, " node: %" PRId64 "\n", di->node);
|
||||
monitor_printf(mon, " size: %" PRIu64 "\n", di->size);
|
||||
monitor_printf(mon, " memdev: %s\n", di->memdev);
|
||||
monitor_printf(mon, " hotplugged: %s\n",
|
||||
di->hotplugged ? "true" : "false");
|
||||
monitor_printf(mon, " hotpluggable: %s\n",
|
||||
di->hotpluggable ? "true" : "false");
|
||||
break;
|
||||
case MEMORY_DEVICE_INFO_KIND_VIRTIO_PMEM:
|
||||
vpi = value->u.virtio_pmem.data;
|
||||
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
|
||||
MemoryDeviceInfoKind_str(value->type),
|
||||
vpi->id ? vpi->id : "");
|
||||
monitor_printf(mon, " memaddr: 0x%" PRIx64 "\n", vpi->memaddr);
|
||||
monitor_printf(mon, " size: %" PRIu64 "\n", vpi->size);
|
||||
monitor_printf(mon, " memdev: %s\n", vpi->memdev);
|
||||
break;
|
||||
case MEMORY_DEVICE_INFO_KIND_VIRTIO_MEM:
|
||||
vmi = value->u.virtio_mem.data;
|
||||
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
|
||||
MemoryDeviceInfoKind_str(value->type),
|
||||
vmi->id ? vmi->id : "");
|
||||
monitor_printf(mon, " memaddr: 0x%" PRIx64 "\n", vmi->memaddr);
|
||||
monitor_printf(mon, " node: %" PRId64 "\n", vmi->node);
|
||||
monitor_printf(mon, " requested-size: %" PRIu64 "\n",
|
||||
vmi->requested_size);
|
||||
monitor_printf(mon, " size: %" PRIu64 "\n", vmi->size);
|
||||
monitor_printf(mon, " max-size: %" PRIu64 "\n", vmi->max_size);
|
||||
monitor_printf(mon, " block-size: %" PRIu64 "\n",
|
||||
vmi->block_size);
|
||||
monitor_printf(mon, " memdev: %s\n", vmi->memdev);
|
||||
break;
|
||||
case MEMORY_DEVICE_INFO_KIND_SGX_EPC:
|
||||
se = value->u.sgx_epc.data;
|
||||
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
|
||||
MemoryDeviceInfoKind_str(value->type),
|
||||
se->id ? se->id : "");
|
||||
monitor_printf(mon, " memaddr: 0x%" PRIx64 "\n", se->memaddr);
|
||||
monitor_printf(mon, " size: %" PRIu64 "\n", se->size);
|
||||
monitor_printf(mon, " node: %" PRId64 "\n", se->node);
|
||||
monitor_printf(mon, " memdev: %s\n", se->memdev);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qapi_free_MemoryDeviceInfoList(info_list);
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
Error *err = NULL;
|
||||
GuidInfo *info = qmp_query_vm_generation_id(&err);
|
||||
if (info) {
|
||||
monitor_printf(mon, "%s\n", info->guid);
|
||||
}
|
||||
hmp_handle_error(mon, err);
|
||||
qapi_free_GuidInfo(info);
|
||||
}
|
||||
|
||||
void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
Error *err = NULL;
|
||||
MemoryInfo *info = qmp_query_memory_size_summary(&err);
|
||||
if (info) {
|
||||
monitor_printf(mon, "base memory: %" PRIu64 "\n",
|
||||
info->base_memory);
|
||||
|
||||
if (info->has_plugged_memory) {
|
||||
monitor_printf(mon, "plugged memory: %" PRIu64 "\n",
|
||||
info->plugged_memory);
|
||||
}
|
||||
|
||||
qapi_free_MemoryInfo(info);
|
||||
}
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "qapi/qapi-builtin-visit.h"
|
||||
#include "qapi/qapi-commands-block.h"
|
||||
#include "qapi/qapi-commands-control.h"
|
||||
#include "qapi/qapi-commands-machine.h"
|
||||
#include "qapi/qapi-commands-migration.h"
|
||||
#include "qapi/qapi-commands-misc.h"
|
||||
#include "qapi/qapi-commands-net.h"
|
||||
@ -108,21 +107,6 @@ void hmp_info_version(Monitor *mon, const QDict *qdict)
|
||||
qapi_free_VersionInfo(info);
|
||||
}
|
||||
|
||||
void hmp_info_kvm(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
KvmInfo *info;
|
||||
|
||||
info = qmp_query_kvm(NULL);
|
||||
monitor_printf(mon, "kvm support: ");
|
||||
if (info->present) {
|
||||
monitor_printf(mon, "%s\n", info->enabled ? "enabled" : "disabled");
|
||||
} else {
|
||||
monitor_printf(mon, "not compiled\n");
|
||||
}
|
||||
|
||||
qapi_free_KvmInfo(info);
|
||||
}
|
||||
|
||||
void hmp_info_status(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
StatusInfo *info;
|
||||
@ -142,15 +126,6 @@ void hmp_info_status(Monitor *mon, const QDict *qdict)
|
||||
qapi_free_StatusInfo(info);
|
||||
}
|
||||
|
||||
void hmp_info_uuid(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
UuidInfo *info;
|
||||
|
||||
info = qmp_query_uuid(NULL);
|
||||
monitor_printf(mon, "%s\n", info->UUID);
|
||||
qapi_free_UuidInfo(info);
|
||||
}
|
||||
|
||||
void hmp_info_migrate(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
MigrationInfo *info;
|
||||
@ -469,21 +444,6 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
|
||||
qapi_free_MigrationParameters(params);
|
||||
}
|
||||
|
||||
void hmp_info_balloon(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
BalloonInfo *info;
|
||||
Error *err = NULL;
|
||||
|
||||
info = qmp_query_balloon(&err);
|
||||
if (hmp_handle_error(mon, err)) {
|
||||
return;
|
||||
}
|
||||
|
||||
monitor_printf(mon, "balloon: actual=%" PRId64 "\n", info->actual >> 20);
|
||||
|
||||
qapi_free_BalloonInfo(info);
|
||||
}
|
||||
|
||||
static int hmp_info_pic_foreach(Object *obj, void *opaque)
|
||||
{
|
||||
InterruptStatsProvider *intc;
|
||||
@ -598,16 +558,6 @@ void hmp_sync_profile(Monitor *mon, const QDict *qdict)
|
||||
}
|
||||
}
|
||||
|
||||
void hmp_system_reset(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
qmp_system_reset(NULL);
|
||||
}
|
||||
|
||||
void hmp_system_powerdown(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
qmp_system_powerdown(NULL);
|
||||
}
|
||||
|
||||
void hmp_exit_preconfig(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
Error *err = NULL;
|
||||
@ -628,34 +578,6 @@ void hmp_cpu(Monitor *mon, const QDict *qdict)
|
||||
}
|
||||
}
|
||||
|
||||
void hmp_memsave(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
uint32_t size = qdict_get_int(qdict, "size");
|
||||
const char *filename = qdict_get_str(qdict, "filename");
|
||||
uint64_t addr = qdict_get_int(qdict, "val");
|
||||
Error *err = NULL;
|
||||
int cpu_index = monitor_get_cpu_index(mon);
|
||||
|
||||
if (cpu_index < 0) {
|
||||
monitor_printf(mon, "No CPU available\n");
|
||||
return;
|
||||
}
|
||||
|
||||
qmp_memsave(addr, size, filename, true, cpu_index, &err);
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
void hmp_pmemsave(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
uint32_t size = qdict_get_int(qdict, "size");
|
||||
const char *filename = qdict_get_str(qdict, "filename");
|
||||
uint64_t addr = qdict_get_int(qdict, "val");
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_pmemsave(addr, size, filename, &err);
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
void hmp_cont(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
Error *err = NULL;
|
||||
@ -664,22 +586,6 @@ void hmp_cont(Monitor *mon, const QDict *qdict)
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
void hmp_system_wakeup(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_system_wakeup(&err);
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
void hmp_nmi(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_inject_nmi(&err);
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
void hmp_set_link(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
const char *name = qdict_get_str(qdict, "name");
|
||||
@ -690,15 +596,6 @@ void hmp_set_link(Monitor *mon, const QDict *qdict)
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
void hmp_balloon(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
int64_t value = qdict_get_int(qdict, "value");
|
||||
Error *err = NULL;
|
||||
|
||||
qmp_balloon(value, &err);
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
void hmp_loadvm(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
int saved_vm_running = runstate_is_running();
|
||||
@ -1193,83 +1090,6 @@ void hmp_object_del(Monitor *mon, const QDict *qdict)
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
Error *err = NULL;
|
||||
MemoryDeviceInfoList *info_list = qmp_query_memory_devices(&err);
|
||||
MemoryDeviceInfoList *info;
|
||||
VirtioPMEMDeviceInfo *vpi;
|
||||
VirtioMEMDeviceInfo *vmi;
|
||||
MemoryDeviceInfo *value;
|
||||
PCDIMMDeviceInfo *di;
|
||||
SgxEPCDeviceInfo *se;
|
||||
|
||||
for (info = info_list; info; info = info->next) {
|
||||
value = info->value;
|
||||
|
||||
if (value) {
|
||||
switch (value->type) {
|
||||
case MEMORY_DEVICE_INFO_KIND_DIMM:
|
||||
case MEMORY_DEVICE_INFO_KIND_NVDIMM:
|
||||
di = value->type == MEMORY_DEVICE_INFO_KIND_DIMM ?
|
||||
value->u.dimm.data : value->u.nvdimm.data;
|
||||
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
|
||||
MemoryDeviceInfoKind_str(value->type),
|
||||
di->id ? di->id : "");
|
||||
monitor_printf(mon, " addr: 0x%" PRIx64 "\n", di->addr);
|
||||
monitor_printf(mon, " slot: %" PRId64 "\n", di->slot);
|
||||
monitor_printf(mon, " node: %" PRId64 "\n", di->node);
|
||||
monitor_printf(mon, " size: %" PRIu64 "\n", di->size);
|
||||
monitor_printf(mon, " memdev: %s\n", di->memdev);
|
||||
monitor_printf(mon, " hotplugged: %s\n",
|
||||
di->hotplugged ? "true" : "false");
|
||||
monitor_printf(mon, " hotpluggable: %s\n",
|
||||
di->hotpluggable ? "true" : "false");
|
||||
break;
|
||||
case MEMORY_DEVICE_INFO_KIND_VIRTIO_PMEM:
|
||||
vpi = value->u.virtio_pmem.data;
|
||||
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
|
||||
MemoryDeviceInfoKind_str(value->type),
|
||||
vpi->id ? vpi->id : "");
|
||||
monitor_printf(mon, " memaddr: 0x%" PRIx64 "\n", vpi->memaddr);
|
||||
monitor_printf(mon, " size: %" PRIu64 "\n", vpi->size);
|
||||
monitor_printf(mon, " memdev: %s\n", vpi->memdev);
|
||||
break;
|
||||
case MEMORY_DEVICE_INFO_KIND_VIRTIO_MEM:
|
||||
vmi = value->u.virtio_mem.data;
|
||||
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
|
||||
MemoryDeviceInfoKind_str(value->type),
|
||||
vmi->id ? vmi->id : "");
|
||||
monitor_printf(mon, " memaddr: 0x%" PRIx64 "\n", vmi->memaddr);
|
||||
monitor_printf(mon, " node: %" PRId64 "\n", vmi->node);
|
||||
monitor_printf(mon, " requested-size: %" PRIu64 "\n",
|
||||
vmi->requested_size);
|
||||
monitor_printf(mon, " size: %" PRIu64 "\n", vmi->size);
|
||||
monitor_printf(mon, " max-size: %" PRIu64 "\n", vmi->max_size);
|
||||
monitor_printf(mon, " block-size: %" PRIu64 "\n",
|
||||
vmi->block_size);
|
||||
monitor_printf(mon, " memdev: %s\n", vmi->memdev);
|
||||
break;
|
||||
case MEMORY_DEVICE_INFO_KIND_SGX_EPC:
|
||||
se = value->u.sgx_epc.data;
|
||||
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
|
||||
MemoryDeviceInfoKind_str(value->type),
|
||||
se->id ? se->id : "");
|
||||
monitor_printf(mon, " memaddr: 0x%" PRIx64 "\n", se->memaddr);
|
||||
monitor_printf(mon, " size: %" PRIu64 "\n", se->size);
|
||||
monitor_printf(mon, " node: %" PRId64 "\n", se->node);
|
||||
monitor_printf(mon, " memdev: %s\n", se->memdev);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qapi_free_MemoryDeviceInfoList(info_list);
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
void hmp_info_iothreads(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
IOThreadInfoList *info_list = qmp_query_iothreads(NULL);
|
||||
@ -1585,35 +1405,6 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QDict *qdict)
|
||||
qapi_free_RockerOfDpaGroupList(list);
|
||||
}
|
||||
|
||||
void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
Error *err = NULL;
|
||||
GuidInfo *info = qmp_query_vm_generation_id(&err);
|
||||
if (info) {
|
||||
monitor_printf(mon, "%s\n", info->guid);
|
||||
}
|
||||
hmp_handle_error(mon, err);
|
||||
qapi_free_GuidInfo(info);
|
||||
}
|
||||
|
||||
void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
Error *err = NULL;
|
||||
MemoryInfo *info = qmp_query_memory_size_summary(&err);
|
||||
if (info) {
|
||||
monitor_printf(mon, "base memory: %" PRIu64 "\n",
|
||||
info->base_memory);
|
||||
|
||||
if (info->has_plugged_memory) {
|
||||
monitor_printf(mon, "plugged memory: %" PRIu64 "\n",
|
||||
info->plugged_memory);
|
||||
}
|
||||
|
||||
qapi_free_MemoryInfo(info);
|
||||
}
|
||||
hmp_handle_error(mon, err);
|
||||
}
|
||||
|
||||
static void print_stats_schema_value(Monitor *mon, StatsSchemaValue *value)
|
||||
{
|
||||
const char *unit = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user