#include "qemu/config-file.h"
#include "qemu/option.h"
#include "qemu/timer.h"
-#include "qmp-commands.h"
#include "qemu/sockets.h"
#include "monitor/monitor.h"
#include "monitor/qdev.h"
+#include "qapi/error.h"
#include "qapi/opts-visitor.h"
+#include "qapi/qapi-builtin-visit.h"
+#include "qapi/qapi-commands-block.h"
+#include "qapi/qapi-commands-char.h"
+#include "qapi/qapi-commands-migration.h"
+#include "qapi/qapi-commands-misc.h"
+#include "qapi/qapi-commands-net.h"
+#include "qapi/qapi-commands-rocker.h"
+#include "qapi/qapi-commands-run-state.h"
+#include "qapi/qapi-commands-tpm.h"
+#include "qapi/qapi-commands-ui.h"
+#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qerror.h"
#include "qapi/string-input-visitor.h"
#include "qapi/string-output-visitor.h"
-#include "qapi/util.h"
-#include "qapi-visit.h"
#include "qom/object_interfaces.h"
#include "ui/console.h"
#include "block/nbd.h"
info->singlestep ? " (single step mode)" : "");
if (!info->running && info->status != RUN_STATE_PAUSED) {
- monitor_printf(mon, " (%s)", RunState_lookup[info->status]);
+ monitor_printf(mon, " (%s)", RunState_str(info->status));
}
monitor_printf(mon, "\n");
monitor_printf(mon, "capabilities: ");
for (cap = caps; cap; cap = cap->next) {
monitor_printf(mon, "%s: %s ",
- MigrationCapability_lookup[cap->value->capability],
+ MigrationCapability_str(cap->value->capability),
cap->value->state ? "on" : "off");
}
monitor_printf(mon, "\n");
if (info->has_status) {
monitor_printf(mon, "Migration status: %s",
- MigrationStatus_lookup[info->status]);
+ MigrationStatus_str(info->status));
if (info->status == MIGRATION_STATUS_FAILED &&
info->has_error_desc) {
monitor_printf(mon, " (%s)\n", info->error_desc);
info->ram->dirty_sync_count);
monitor_printf(mon, "page size: %" PRIu64 " kbytes\n",
info->ram->page_size >> 10);
+ monitor_printf(mon, "multifd bytes: %" PRIu64 " kbytes\n",
+ info->ram->multifd_bytes >> 10);
if (info->ram->dirty_pages_rate) {
monitor_printf(mon, "dirty pages rate: %" PRIu64 " pages\n",
info->xbzrle_cache->overflow);
}
+ if (info->has_compression) {
+ monitor_printf(mon, "compression pages: %" PRIu64 " pages\n",
+ info->compression->pages);
+ monitor_printf(mon, "compression busy: %" PRIu64 "\n",
+ info->compression->busy);
+ monitor_printf(mon, "compression busy rate: %0.2f\n",
+ info->compression->busy_rate);
+ monitor_printf(mon, "compressed size: %" PRIu64 "\n",
+ info->compression->compressed_size);
+ monitor_printf(mon, "compression rate: %0.2f\n",
+ info->compression->compression_rate);
+ }
+
if (info->has_cpu_throttle_percentage) {
monitor_printf(mon, "cpu throttle percentage: %" PRIu64 "\n",
info->cpu_throttle_percentage);
}
+ if (info->has_postcopy_blocktime) {
+ monitor_printf(mon, "postcopy blocktime: %u\n",
+ info->postcopy_blocktime);
+ }
+
+ if (info->has_postcopy_vcpu_blocktime) {
+ Visitor *v;
+ char *str;
+ v = string_output_visitor_new(false, &str);
+ visit_type_uint32List(v, NULL, &info->postcopy_vcpu_blocktime, NULL);
+ visit_complete(v, &str);
+ monitor_printf(mon, "postcopy vcpu blocktime: %s\n", str);
+ g_free(str);
+ visit_free(v);
+ }
qapi_free_MigrationInfo(info);
qapi_free_MigrationCapabilityStatusList(caps);
}
if (caps) {
for (cap = caps; cap; cap = cap->next) {
monitor_printf(mon, "%s: %s\n",
- MigrationCapability_lookup[cap->value->capability],
+ MigrationCapability_str(cap->value->capability),
cap->value->state ? "on" : "off");
}
}
if (params) {
assert(params->has_compress_level);
- monitor_printf(mon, "%s: %" PRId64 "\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_COMPRESS_LEVEL],
+ monitor_printf(mon, "%s: %u\n",
+ MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_LEVEL),
params->compress_level);
assert(params->has_compress_threads);
- monitor_printf(mon, "%s: %" PRId64 "\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_COMPRESS_THREADS],
+ monitor_printf(mon, "%s: %u\n",
+ MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_THREADS),
params->compress_threads);
+ assert(params->has_compress_wait_thread);
+ monitor_printf(mon, "%s: %s\n",
+ MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD),
+ params->compress_wait_thread ? "on" : "off");
assert(params->has_decompress_threads);
- monitor_printf(mon, "%s: %" PRId64 "\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_DECOMPRESS_THREADS],
+ monitor_printf(mon, "%s: %u\n",
+ MigrationParameter_str(MIGRATION_PARAMETER_DECOMPRESS_THREADS),
params->decompress_threads);
assert(params->has_cpu_throttle_initial);
- monitor_printf(mon, "%s: %" PRId64 "\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL],
+ monitor_printf(mon, "%s: %u\n",
+ MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL),
params->cpu_throttle_initial);
assert(params->has_cpu_throttle_increment);
- monitor_printf(mon, "%s: %" PRId64 "\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT],
+ monitor_printf(mon, "%s: %u\n",
+ MigrationParameter_str(MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT),
params->cpu_throttle_increment);
+ assert(params->has_max_cpu_throttle);
+ monitor_printf(mon, "%s: %u\n",
+ MigrationParameter_str(MIGRATION_PARAMETER_MAX_CPU_THROTTLE),
+ params->max_cpu_throttle);
+ assert(params->has_tls_creds);
monitor_printf(mon, "%s: '%s'\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_CREDS],
- params->has_tls_creds ? params->tls_creds : "");
+ MigrationParameter_str(MIGRATION_PARAMETER_TLS_CREDS),
+ params->tls_creds);
+ assert(params->has_tls_hostname);
monitor_printf(mon, "%s: '%s'\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_TLS_HOSTNAME],
- params->has_tls_hostname ? params->tls_hostname : "");
+ MigrationParameter_str(MIGRATION_PARAMETER_TLS_HOSTNAME),
+ params->tls_hostname);
assert(params->has_max_bandwidth);
- monitor_printf(mon, "%s: %" PRId64 " bytes/second\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_MAX_BANDWIDTH],
+ monitor_printf(mon, "%s: %" PRIu64 " bytes/second\n",
+ MigrationParameter_str(MIGRATION_PARAMETER_MAX_BANDWIDTH),
params->max_bandwidth);
assert(params->has_downtime_limit);
- monitor_printf(mon, "%s: %" PRId64 " milliseconds\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_DOWNTIME_LIMIT],
+ monitor_printf(mon, "%s: %" PRIu64 " milliseconds\n",
+ MigrationParameter_str(MIGRATION_PARAMETER_DOWNTIME_LIMIT),
params->downtime_limit);
assert(params->has_x_checkpoint_delay);
- monitor_printf(mon, "%s: %" PRId64 "\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_X_CHECKPOINT_DELAY],
+ monitor_printf(mon, "%s: %u\n",
+ MigrationParameter_str(MIGRATION_PARAMETER_X_CHECKPOINT_DELAY),
params->x_checkpoint_delay);
assert(params->has_block_incremental);
monitor_printf(mon, "%s: %s\n",
- MigrationParameter_lookup[MIGRATION_PARAMETER_BLOCK_INCREMENTAL],
- params->block_incremental ? "on" : "off");
+ MigrationParameter_str(MIGRATION_PARAMETER_BLOCK_INCREMENTAL),
+ params->block_incremental ? "on" : "off");
+ monitor_printf(mon, "%s: %u\n",
+ MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_CHANNELS),
+ params->x_multifd_channels);
+ monitor_printf(mon, "%s: %u\n",
+ MigrationParameter_str(MIGRATION_PARAMETER_X_MULTIFD_PAGE_COUNT),
+ params->x_multifd_page_count);
+ monitor_printf(mon, "%s: %" PRIu64 "\n",
+ MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE),
+ params->xbzrle_cache_size);
+ monitor_printf(mon, "%s: %" PRIu64 "\n",
+ MigrationParameter_str(MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH),
+ params->max_postcopy_bandwidth);
}
qapi_free_MigrationParameters(params);
void hmp_info_cpus(Monitor *mon, const QDict *qdict)
{
- CpuInfoList *cpu_list, *cpu;
+ CpuInfoFastList *cpu_list, *cpu;
- cpu_list = qmp_query_cpus(NULL);
+ cpu_list = qmp_query_cpus_fast(NULL);
for (cpu = cpu_list; cpu; cpu = cpu->next) {
int active = ' ';
- if (cpu->value->CPU == monitor_get_cpu_index()) {
+ if (cpu->value->cpu_index == monitor_get_cpu_index()) {
active = '*';
}
- monitor_printf(mon, "%c CPU #%" PRId64 ":", active, cpu->value->CPU);
-
- switch (cpu->value->arch) {
- case CPU_INFO_ARCH_X86:
- monitor_printf(mon, " pc=0x%016" PRIx64, cpu->value->u.x86.pc);
- break;
- case CPU_INFO_ARCH_PPC:
- monitor_printf(mon, " nip=0x%016" PRIx64, cpu->value->u.ppc.nip);
- break;
- case CPU_INFO_ARCH_SPARC:
- monitor_printf(mon, " pc=0x%016" PRIx64,
- cpu->value->u.q_sparc.pc);
- monitor_printf(mon, " npc=0x%016" PRIx64,
- cpu->value->u.q_sparc.npc);
- break;
- case CPU_INFO_ARCH_MIPS:
- monitor_printf(mon, " PC=0x%016" PRIx64, cpu->value->u.q_mips.PC);
- break;
- case CPU_INFO_ARCH_TRICORE:
- monitor_printf(mon, " PC=0x%016" PRIx64, cpu->value->u.tricore.PC);
- break;
- default:
- break;
- }
-
- if (cpu->value->halted) {
- monitor_printf(mon, " (halted)");
- }
-
+ monitor_printf(mon, "%c CPU #%" PRId64 ":", active,
+ cpu->value->cpu_index);
monitor_printf(mon, " thread_id=%" PRId64 "\n", cpu->value->thread_id);
}
- qapi_free_CpuInfoList(cpu_list);
+ qapi_free_CpuInfoFastList(cpu_list);
}
static void print_block_info(Monitor *mon, BlockInfo *info,
}
if (info->has_io_status && info->io_status != BLOCK_DEVICE_IO_STATUS_OK) {
monitor_printf(mon, " I/O status: %s\n",
- BlockDeviceIoStatus_lookup[info->io_status]);
+ BlockDeviceIoStatus_str(info->io_status));
}
if (info->removable) {
if (inserted->detect_zeroes != BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF) {
monitor_printf(mon, " Detect zeroes: %s\n",
- BlockdevDetectZeroesOptions_lookup[inserted->detect_zeroes]);
+ BlockdevDetectZeroesOptions_str(inserted->detect_zeroes));
}
if (inserted->bps || inserted->bps_rd || inserted->bps_wr ||
qapi_free_BlockStatsList(stats_list);
}
+#ifdef CONFIG_VNC
/* Helper for hmp_info_vnc_clients, _servers */
static void hmp_info_VncBasicInfo(Monitor *mon, VncBasicInfo *info,
const char *name)
name,
info->host,
info->service,
- NetworkAddressFamily_lookup[info->family],
+ NetworkAddressFamily_str(info->family),
info->websocket ? " (Websocket)" : "");
}
VncVencryptSubAuth *vencrypt)
{
monitor_printf(mon, "%sAuth: %s (Sub: %s)\n", indent,
- VncPrimaryAuth_lookup[auth],
- vencrypt ? VncVencryptSubAuth_lookup[*vencrypt] : "none");
+ VncPrimaryAuth_str(auth),
+ vencrypt ? VncVencryptSubAuth_str(*vencrypt) : "none");
}
static void hmp_info_vnc_clients(Monitor *mon, VncClientInfoList *client)
info2l = qmp_query_vnc_servers(&err);
if (err) {
- error_report_err(err);
+ hmp_handle_error(mon, &err);
return;
}
if (!info2l) {
qapi_free_VncInfo2List(info2l);
}
+#endif
#ifdef CONFIG_SPICE
void hmp_info_spice(Monitor *mon, const QDict *qdict)
monitor_printf(mon, " auth: %s\n", info->auth);
monitor_printf(mon, " compiled: %s\n", info->compiled_version);
monitor_printf(mon, " mouse-mode: %s\n",
- SpiceQueryMouseMode_lookup[info->mouse_mode]);
+ SpiceQueryMouseMode_str(info->mouse_mode));
if (!info->has_channels || info->channels == NULL) {
monitor_printf(mon, "Channels: none\n");
info = qmp_query_balloon(&err);
if (err) {
- error_report_err(err);
+ hmp_handle_error(mon, &err);
return;
}
monitor_printf(mon, ": PCI device %04" PRIx64 ":%04" PRIx64 "\n",
dev->id->vendor, dev->id->device);
+ monitor_printf(mon, " PCI subsystem %04" PRIx64 ":%04" PRIx64 "\n",
+ dev->id->subsystem_vendor, dev->id->subsystem);
if (dev->has_irq) {
monitor_printf(mon, " IRQ %" PRId64 ".\n", dev->irq);
Error *err = NULL;
unsigned int c = 0;
TPMPassthroughOptions *tpo;
+ TPMEmulatorOptions *teo;
info_list = qmp_query_tpm(&err);
if (err) {
for (info = info_list; info; info = info->next) {
TPMInfo *ti = info->value;
monitor_printf(mon, " tpm%d: model=%s\n",
- c, TpmModel_lookup[ti->model]);
+ c, TpmModel_str(ti->model));
monitor_printf(mon, " \\ %s: type=%s",
- ti->id, TpmTypeOptionsKind_lookup[ti->options->type]);
+ ti->id, TpmTypeOptionsKind_str(ti->options->type));
switch (ti->options->type) {
case TPM_TYPE_OPTIONS_KIND_PASSTHROUGH:
tpo->has_cancel_path ? ",cancel-path=" : "",
tpo->has_cancel_path ? tpo->cancel_path : "");
break;
+ case TPM_TYPE_OPTIONS_KIND_EMULATOR:
+ teo = ti->options->u.emulator.data;
+ monitor_printf(mon, ",chardev=%s", teo->chardev);
+ break;
case TPM_TYPE_OPTIONS_KIND__MAX:
break;
}
qmp_stop(NULL);
}
+void hmp_sync_profile(Monitor *mon, const QDict *qdict)
+{
+ const char *op = qdict_get_try_str(qdict, "op");
+
+ if (op == NULL) {
+ bool on = qsp_is_enabled();
+
+ monitor_printf(mon, "sync-profile is %s\n", on ? "on" : "off");
+ return;
+ }
+ if (!strcmp(op, "on")) {
+ qsp_enable();
+ } else if (!strcmp(op, "off")) {
+ qsp_disable();
+ } else if (!strcmp(op, "reset")) {
+ qsp_reset();
+ } else {
+ Error *err = NULL;
+
+ error_setg(&err, QERR_INVALID_PARAMETER, op);
+ hmp_handle_error(mon, &err);
+ }
+}
+
void hmp_system_reset(Monitor *mon, const QDict *qdict)
{
qmp_system_reset(NULL);
qmp_system_powerdown(NULL);
}
+void hmp_exit_preconfig(Monitor *mon, const QDict *qdict)
+{
+ Error *err = NULL;
+
+ qmp_x_exit_preconfig(&err);
+ hmp_handle_error(mon, &err);
+}
+
void hmp_cpu(Monitor *mon, const QDict *qdict)
{
int64_t cpu_index;
data = qmp_ringbuf_read(chardev, size, false, 0, &err);
if (err) {
- error_report_err(err);
+ hmp_handle_error(mon, &err);
return;
}
Error *err = NULL;
qmp_balloon(value, &err);
- if (err) {
- error_report_err(err);
- }
+ hmp_handle_error(mon, &err);
}
void hmp_block_resize(Monitor *mon, const QDict *qdict)
void hmp_delvm(Monitor *mon, const QDict *qdict)
{
BlockDriverState *bs;
- Error *err;
+ Error *err = NULL;
const char *name = qdict_get_str(qdict, "name");
if (bdrv_all_delete_snapshot(name, &bs, &err) < 0) {
qmp_migrate_cancel(NULL);
}
+void hmp_migrate_continue(Monitor *mon, const QDict *qdict)
+{
+ Error *err = NULL;
+ const char *state = qdict_get_str(qdict, "state");
+ int val = qapi_enum_parse(&MigrationStatus_lookup, state, -1, &err);
+
+ if (val >= 0) {
+ qmp_migrate_continue(val, &err);
+ }
+
+ hmp_handle_error(mon, &err);
+}
+
void hmp_migrate_incoming(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
hmp_handle_error(mon, &err);
}
+void hmp_migrate_recover(Monitor *mon, const QDict *qdict)
+{
+ Error *err = NULL;
+ const char *uri = qdict_get_str(qdict, "uri");
+
+ qmp_migrate_recover(uri, &err);
+
+ hmp_handle_error(mon, &err);
+}
+
+void hmp_migrate_pause(Monitor *mon, const QDict *qdict)
+{
+ Error *err = NULL;
+
+ qmp_migrate_pause(&err);
+
+ hmp_handle_error(mon, &err);
+}
+
/* Kept for backwards compatibility */
void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
qmp_migrate_set_cache_size(value, &err);
- if (err) {
- error_report_err(err);
- return;
- }
+ hmp_handle_error(mon, &err);
}
/* Kept for backwards compatibility */
bool state = qdict_get_bool(qdict, "state");
Error *err = NULL;
MigrationCapabilityStatusList *caps = g_malloc0(sizeof(*caps));
- int i;
+ int val;
- for (i = 0; i < MIGRATION_CAPABILITY__MAX; i++) {
- if (strcmp(cap, MigrationCapability_lookup[i]) == 0) {
- caps->value = g_malloc0(sizeof(*caps->value));
- caps->value->capability = i;
- caps->value->state = state;
- caps->next = NULL;
- qmp_migrate_set_capabilities(caps, &err);
- break;
- }
+ val = qapi_enum_parse(&MigrationCapability_lookup, cap, -1, &err);
+ if (val < 0) {
+ goto end;
}
- if (i == MIGRATION_CAPABILITY__MAX) {
- error_setg(&err, QERR_INVALID_PARAMETER, cap);
- }
+ caps->value = g_malloc0(sizeof(*caps->value));
+ caps->value->capability = val;
+ caps->value->state = state;
+ caps->next = NULL;
+ qmp_migrate_set_capabilities(caps, &err);
+end:
qapi_free_MigrationCapabilityStatusList(caps);
-
- if (err) {
- error_report_err(err);
- }
+ hmp_handle_error(mon, &err);
}
void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
const char *param = qdict_get_str(qdict, "parameter");
const char *valuestr = qdict_get_str(qdict, "value");
Visitor *v = string_input_visitor_new(valuestr);
+ MigrateSetParameters *p = g_new0(MigrateSetParameters, 1);
uint64_t valuebw = 0;
- int64_t valueint = 0;
- bool valuebool = false;
- Error *err = NULL;
- bool use_int_value = false;
- int i, ret;
-
- for (i = 0; i < MIGRATION_PARAMETER__MAX; i++) {
- if (strcmp(param, MigrationParameter_lookup[i]) == 0) {
- MigrationParameters p = { 0 };
- switch (i) {
- case MIGRATION_PARAMETER_COMPRESS_LEVEL:
- p.has_compress_level = true;
- use_int_value = true;
- break;
- case MIGRATION_PARAMETER_COMPRESS_THREADS:
- p.has_compress_threads = true;
- use_int_value = true;
- break;
- case MIGRATION_PARAMETER_DECOMPRESS_THREADS:
- p.has_decompress_threads = true;
- use_int_value = true;
- break;
- case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL:
- p.has_cpu_throttle_initial = true;
- use_int_value = true;
- break;
- case MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT:
- p.has_cpu_throttle_increment = true;
- use_int_value = true;
- break;
- case MIGRATION_PARAMETER_TLS_CREDS:
- p.has_tls_creds = true;
- p.tls_creds = (char *) valuestr;
- break;
- case MIGRATION_PARAMETER_TLS_HOSTNAME:
- p.has_tls_hostname = true;
- p.tls_hostname = (char *) valuestr;
- break;
- case MIGRATION_PARAMETER_MAX_BANDWIDTH:
- p.has_max_bandwidth = true;
- ret = qemu_strtosz_MiB(valuestr, NULL, &valuebw);
- if (ret < 0 || valuebw > INT64_MAX
- || (size_t)valuebw != valuebw) {
- error_setg(&err, "Invalid size %s", valuestr);
- goto cleanup;
- }
- p.max_bandwidth = valuebw;
- break;
- case MIGRATION_PARAMETER_DOWNTIME_LIMIT:
- p.has_downtime_limit = true;
- use_int_value = true;
- break;
- case MIGRATION_PARAMETER_X_CHECKPOINT_DELAY:
- p.has_x_checkpoint_delay = true;
- use_int_value = true;
- break;
- case MIGRATION_PARAMETER_BLOCK_INCREMENTAL:
- p.has_block_incremental = true;
- visit_type_bool(v, param, &valuebool, &err);
- if (err) {
- goto cleanup;
- }
- p.block_incremental = valuebool;
- break;
- }
-
- if (use_int_value) {
- visit_type_int(v, param, &valueint, &err);
- if (err) {
- goto cleanup;
- }
- /* Set all integers; only one has_FOO will be set, and
- * the code ignores the remaining values */
- p.compress_level = valueint;
- p.compress_threads = valueint;
- p.decompress_threads = valueint;
- p.cpu_throttle_initial = valueint;
- p.cpu_throttle_increment = valueint;
- p.downtime_limit = valueint;
- p.x_checkpoint_delay = valueint;
- }
-
- qmp_migrate_set_parameters(&p, &err);
+ uint64_t cache_size;
+ Error *err = NULL;
+ int val, ret;
+
+ val = qapi_enum_parse(&MigrationParameter_lookup, param, -1, &err);
+ if (val < 0) {
+ goto cleanup;
+ }
+
+ switch (val) {
+ case MIGRATION_PARAMETER_COMPRESS_LEVEL:
+ p->has_compress_level = true;
+ visit_type_int(v, param, &p->compress_level, &err);
+ break;
+ case MIGRATION_PARAMETER_COMPRESS_THREADS:
+ p->has_compress_threads = true;
+ visit_type_int(v, param, &p->compress_threads, &err);
+ break;
+ case MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD:
+ p->has_compress_wait_thread = true;
+ visit_type_bool(v, param, &p->compress_wait_thread, &err);
+ break;
+ case MIGRATION_PARAMETER_DECOMPRESS_THREADS:
+ p->has_decompress_threads = true;
+ visit_type_int(v, param, &p->decompress_threads, &err);
+ break;
+ case MIGRATION_PARAMETER_CPU_THROTTLE_INITIAL:
+ p->has_cpu_throttle_initial = true;
+ visit_type_int(v, param, &p->cpu_throttle_initial, &err);
+ break;
+ case MIGRATION_PARAMETER_CPU_THROTTLE_INCREMENT:
+ p->has_cpu_throttle_increment = true;
+ visit_type_int(v, param, &p->cpu_throttle_increment, &err);
+ break;
+ case MIGRATION_PARAMETER_MAX_CPU_THROTTLE:
+ p->has_max_cpu_throttle = true;
+ visit_type_int(v, param, &p->max_cpu_throttle, &err);
+ break;
+ case MIGRATION_PARAMETER_TLS_CREDS:
+ p->has_tls_creds = true;
+ p->tls_creds = g_new0(StrOrNull, 1);
+ p->tls_creds->type = QTYPE_QSTRING;
+ visit_type_str(v, param, &p->tls_creds->u.s, &err);
+ break;
+ case MIGRATION_PARAMETER_TLS_HOSTNAME:
+ p->has_tls_hostname = true;
+ p->tls_hostname = g_new0(StrOrNull, 1);
+ p->tls_hostname->type = QTYPE_QSTRING;
+ visit_type_str(v, param, &p->tls_hostname->u.s, &err);
+ break;
+ case MIGRATION_PARAMETER_MAX_BANDWIDTH:
+ p->has_max_bandwidth = true;
+ /*
+ * Can't use visit_type_size() here, because it
+ * defaults to Bytes rather than Mebibytes.
+ */
+ ret = qemu_strtosz_MiB(valuestr, NULL, &valuebw);
+ if (ret < 0 || valuebw > INT64_MAX
+ || (size_t)valuebw != valuebw) {
+ error_setg(&err, "Invalid size %s", valuestr);
+ break;
+ }
+ p->max_bandwidth = valuebw;
+ break;
+ case MIGRATION_PARAMETER_DOWNTIME_LIMIT:
+ p->has_downtime_limit = true;
+ visit_type_int(v, param, &p->downtime_limit, &err);
+ break;
+ case MIGRATION_PARAMETER_X_CHECKPOINT_DELAY:
+ p->has_x_checkpoint_delay = true;
+ visit_type_int(v, param, &p->x_checkpoint_delay, &err);
+ break;
+ case MIGRATION_PARAMETER_BLOCK_INCREMENTAL:
+ p->has_block_incremental = true;
+ visit_type_bool(v, param, &p->block_incremental, &err);
+ break;
+ case MIGRATION_PARAMETER_X_MULTIFD_CHANNELS:
+ p->has_x_multifd_channels = true;
+ visit_type_int(v, param, &p->x_multifd_channels, &err);
+ break;
+ case MIGRATION_PARAMETER_X_MULTIFD_PAGE_COUNT:
+ p->has_x_multifd_page_count = true;
+ visit_type_int(v, param, &p->x_multifd_page_count, &err);
+ break;
+ case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE:
+ p->has_xbzrle_cache_size = true;
+ visit_type_size(v, param, &cache_size, &err);
+ if (err || cache_size > INT64_MAX
+ || (size_t)cache_size != cache_size) {
+ error_setg(&err, "Invalid size %s", valuestr);
break;
}
+ p->xbzrle_cache_size = cache_size;
+ break;
+ case MIGRATION_PARAMETER_MAX_POSTCOPY_BANDWIDTH:
+ p->has_max_postcopy_bandwidth = true;
+ visit_type_size(v, param, &p->max_postcopy_bandwidth, &err);
+ break;
+ default:
+ assert(0);
}
- if (i == MIGRATION_PARAMETER__MAX) {
- error_setg(&err, QERR_INVALID_PARAMETER, param);
+ if (err) {
+ goto cleanup;
}
+ qmp_migrate_set_parameters(p, &err);
+
cleanup:
+ qapi_free_MigrateSetParameters(p);
visit_free(v);
- if (err) {
- error_report_err(err);
- }
+ hmp_handle_error(mon, &err);
}
void hmp_client_migrate_info(Monitor *mon, const QDict *qdict)
hmp_handle_error(mon, &err);
}
+#ifdef CONFIG_VNC
static void hmp_change_read_arg(void *opaque, const char *password,
void *readline_opaque)
{
qmp_change_vnc_password(password, NULL);
monitor_read_command(opaque, 1);
}
+#endif
void hmp_change(Monitor *mon, const QDict *qdict)
{
BlockdevChangeReadOnlyMode read_only_mode = 0;
Error *err = NULL;
+#ifdef CONFIG_VNC
if (strcmp(device, "vnc") == 0) {
if (read_only) {
monitor_printf(mon,
}
}
qmp_change("vnc", target, !!arg, arg, &err);
- } else {
+ } else
+#endif
+ {
if (read_only) {
read_only_mode =
- qapi_enum_parse(BlockdevChangeReadOnlyMode_lookup,
- read_only, BLOCKDEV_CHANGE_READ_ONLY_MODE__MAX,
+ qapi_enum_parse(&BlockdevChangeReadOnlyMode_lookup,
+ read_only,
BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN, &err);
if (err) {
hmp_handle_error(mon, &err);
void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
+ char *device = (char *) qdict_get_str(qdict, "device");
BlockIOThrottle throttle = {
- .has_device = true,
- .device = (char *) qdict_get_str(qdict, "device"),
.bps = qdict_get_int(qdict, "bps"),
.bps_rd = qdict_get_int(qdict, "bps_rd"),
.bps_wr = qdict_get_int(qdict, "bps_wr"),
.iops_wr = qdict_get_int(qdict, "iops_wr"),
};
+ /* qmp_block_set_io_throttle has separate parameters for the
+ * (deprecated) block device name and the qdev ID but the HMP
+ * version has only one, so we must decide which one to pass. */
+ if (blk_by_name(device)) {
+ throttle.has_device = true;
+ throttle.device = device;
+ } else {
+ throttle.has_id = true;
+ throttle.id = device;
+ }
+
qmp_block_set_io_throttle(&throttle, &err);
hmp_handle_error(mon, &err);
}
int64_t speed = qdict_get_try_int(qdict, "speed", 0);
qmp_block_stream(true, device, device, base != NULL, base, false, NULL,
- false, NULL, qdict_haskey(qdict, "speed"), speed,
- true, BLOCKDEV_ON_ERROR_REPORT, &error);
+ false, NULL, qdict_haskey(qdict, "speed"), speed, true,
+ BLOCKDEV_ON_ERROR_REPORT, false, false, false, false,
+ &error);
hmp_handle_error(mon, &error);
}
}
monitor_resume(status->mon);
timer_del(status->timer);
+ timer_free(status->timer);
g_free(status);
}
bool detach = qdict_get_try_bool(qdict, "detach", false);
bool blk = qdict_get_try_bool(qdict, "blk", false);
bool inc = qdict_get_try_bool(qdict, "inc", false);
+ bool resume = qdict_get_try_bool(qdict, "resume", false);
const char *uri = qdict_get_str(qdict, "uri");
Error *err = NULL;
- qmp_migrate(uri, !!blk, blk, !!inc, inc, false, false, &err);
+ qmp_migrate(uri, !!blk, blk, !!inc, inc,
+ false, false, true, resume, &err);
if (err) {
- error_report_err(err);
+ hmp_handle_error(mon, &err);
return;
}
void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
+ bool win_dmp = qdict_get_try_bool(qdict, "windmp", false);
bool paging = qdict_get_try_bool(qdict, "paging", false);
bool zlib = qdict_get_try_bool(qdict, "zlib", false);
bool lzo = qdict_get_try_bool(qdict, "lzo", false);
enum DumpGuestMemoryFormat dump_format = DUMP_GUEST_MEMORY_FORMAT_ELF;
char *prot;
- if (zlib + lzo + snappy > 1) {
- error_setg(&err, "only one of '-z|-l|-s' can be set");
+ if (zlib + lzo + snappy + win_dmp > 1) {
+ error_setg(&err, "only one of '-z|-l|-s|-w' can be set");
hmp_handle_error(mon, &err);
return;
}
+ if (win_dmp) {
+ dump_format = DUMP_GUEST_MEMORY_FORMAT_WIN_DMP;
+ }
+
if (zlib) {
dump_format = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB;
}
int has_hold_time = qdict_haskey(qdict, "hold-time");
int hold_time = qdict_get_try_int(qdict, "hold-time", -1);
Error *err = NULL;
- char *separator;
+ const char *separator;
int keyname_len;
while (1) {
- separator = strchr(keys, '-');
- keyname_len = separator ? separator - keys : strlen(keys);
+ separator = qemu_strchrnul(keys, '-');
+ keyname_len = separator - keys;
/* Be compatible with old interface, convert user inputted "<" */
if (keys[0] == '<' && keyname_len == 1) {
keylist->value->u.qcode.data = idx;
}
- if (!separator) {
+ if (!*separator) {
break;
}
keys = separator + 1;
void hmp_screendump(Monitor *mon, const QDict *qdict)
{
const char *filename = qdict_get_str(qdict, "filename");
+ const char *id = qdict_get_try_str(qdict, "device");
+ int64_t head = qdict_get_try_int(qdict, "head", 0);
Error *err = NULL;
- qmp_screendump(filename, &err);
+ qmp_screendump(filename, id != NULL, id, id != NULL, head, &err);
hmp_handle_error(mon, &err);
}
continue;
}
- qmp_nbd_server_add(info->value->device, true, writable, &local_err);
+ qmp_nbd_server_add(info->value->device, false, NULL,
+ true, writable, &local_err);
if (local_err != NULL) {
qmp_nbd_server_stop(NULL);
void hmp_nbd_server_add(Monitor *mon, const QDict *qdict)
{
const char *device = qdict_get_str(qdict, "device");
+ const char *name = qdict_get_try_str(qdict, "name");
bool writable = qdict_get_try_bool(qdict, "writable", false);
Error *local_err = NULL;
- qmp_nbd_server_add(device, true, writable, &local_err);
+ qmp_nbd_server_add(device, !!name, name, true, writable, &local_err);
+ hmp_handle_error(mon, &local_err);
+}
- if (local_err != NULL) {
- hmp_handle_error(mon, &local_err);
- }
+void hmp_nbd_server_remove(Monitor *mon, const QDict *qdict)
+{
+ const char *name = qdict_get_str(qdict, "name");
+ bool force = qdict_get_try_bool(qdict, "force", false);
+ Error *err = NULL;
+
+ /* Rely on NBD_SERVER_REMOVE_MODE_SAFE being the default */
+ qmp_nbd_server_remove(name, force, NBD_SERVER_REMOVE_MODE_HARD, &err);
+ hmp_handle_error(mon, &err);
}
void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
{
BlockBackend *blk;
BlockBackend *local_blk = NULL;
- AioContext *aio_context;
const char* device = qdict_get_str(qdict, "device");
const char* command = qdict_get_str(qdict, "command");
Error *err = NULL;
}
}
- aio_context = blk_get_aio_context(blk);
- aio_context_acquire(aio_context);
-
/*
* Notably absent: Proper permission management. This is sad, but it seems
* almost impossible to achieve without changing the semantics and thereby
*/
qemuio_command(blk, command);
- aio_context_release(aio_context);
-
fail:
blk_unref(local_blk);
hmp_handle_error(mon, &err);
monitor_printf(mon, " prealloc: %s\n",
m->value->prealloc ? "true" : "false");
monitor_printf(mon, " policy: %s\n",
- HostMemPolicy_lookup[m->value->policy]);
+ HostMemPolicy_str(m->value->policy));
visit_complete(v, &str);
monitor_printf(mon, " host nodes: %s\n", str);
monitor_printf(mon, "\n");
qapi_free_MemdevList(memdev_list);
+ hmp_handle_error(mon, &err);
}
void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
switch (value->type) {
case MEMORY_DEVICE_INFO_KIND_DIMM:
di = value->u.dimm.data;
+ break;
+ case MEMORY_DEVICE_INFO_KIND_NVDIMM:
+ di = value->u.nvdimm.data;
+ break;
+
+ default:
+ di = NULL;
+ break;
+ }
+
+ if (di) {
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
- MemoryDeviceInfoKind_lookup[value->type],
+ 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);
di->hotplugged ? "true" : "false");
monitor_printf(mon, " hotpluggable: %s\n",
di->hotpluggable ? "true" : "false");
- break;
- default:
- break;
}
}
}
qapi_free_MemoryDeviceInfoList(info_list);
+ hmp_handle_error(mon, &err);
}
void hmp_info_iothreads(Monitor *mon, const QDict *qdict)
DumpQueryResult *result = qmp_query_dump(NULL);
assert(result && result->status < DUMP_STATUS__MAX);
- monitor_printf(mon, "Status: %s\n", DumpStatus_lookup[result->status]);
+ monitor_printf(mon, "Status: %s\n", DumpStatus_str(result->status));
if (result->status == DUMP_STATUS_ACTIVE) {
float percent = 0;
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);
+}