#include "sysemu/char.h"
#include "ui/qemu-spice.h"
#include "sysemu/sysemu.h"
+#include "sysemu/numa.h"
#include "monitor/monitor.h"
#include "qemu/readline.h"
#include "ui/console.h"
#include "block/qapi.h"
#include "qapi/qmp-event.h"
#include "qapi-event.h"
+#include "sysemu/block-backend.h"
/* for hmp_info_irq/pic */
#if defined(TARGET_SPARC)
int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func,
void *opaque)
{
- if (monitor_ctrl_mode(mon)) {
- qerror_report(QERR_MISSING_PARAMETER, "password");
- return -EINVAL;
- } else if (mon->rs) {
+ if (mon->rs) {
readline_start(mon->rs, "Password: ", 1, readline_func, opaque);
/* prompt is printed on return from the command handler */
return 0;
}
static int client_migrate_info(Monitor *mon, const QDict *qdict,
- MonitorCompletion cb, void *opaque)
+ QObject **ret_data)
{
const char *protocol = qdict_get_str(qdict, "protocol");
const char *hostname = qdict_get_str(qdict, "hostname");
const char *subject = qdict_get_try_str(qdict, "cert-subject");
int port = qdict_get_try_int(qdict, "port", -1);
int tls_port = qdict_get_try_int(qdict, "tls-port", -1);
- Error *err;
+ Error *err = NULL;
int ret;
if (strcmp(protocol, "spice") == 0) {
if (!qemu_using_spice(&err)) {
qerror_report_err(err);
+ error_free(err);
return -1;
}
return -1;
}
- ret = qemu_spice_migrate_info(hostname, port, tls_port, subject,
- cb, opaque);
+ ret = qemu_spice_migrate_info(hostname, port, tls_port, subject);
if (ret != 0) {
qerror_report(QERR_UNDEFINED_ERROR);
return -1;
sum = 0;
for(addr = start; addr < (start + size); addr++) {
- uint8_t val = ldub_phys(&address_space_memory, addr);
+ uint8_t val = address_space_ldub(&address_space_memory, addr,
+ MEMTXATTRS_UNSPECIFIED, NULL);
/* BSD sum algorithm ('sum' Unix command) */
sum = (sum >> 1) | (sum << 15);
sum += val;
#ifdef CONFIG_PROFILER
-int64_t qemu_time;
+int64_t tcg_time;
int64_t dev_time;
static void hmp_info_profile(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "async time %" PRId64 " (%0.3f)\n",
dev_time, dev_time / (double)get_ticks_per_sec());
monitor_printf(mon, "qemu time %" PRId64 " (%0.3f)\n",
- qemu_time, qemu_time / (double)get_ticks_per_sec());
- qemu_time = 0;
+ tcg_time, tcg_time / (double)get_ticks_per_sec());
+ tcg_time = 0;
dev_time = 0;
}
#else
.help = "show qdev device model list",
.mhandler.cmd = hmp_info_qdm,
},
+ {
+ .name = "qom-tree",
+ .args_type = "path:s?",
+ .params = "[path]",
+ .help = "show QOM composition tree",
+ .mhandler.cmd = hmp_info_qom_tree,
+ },
{
.name = "roms",
.args_type = "",
if (cmd->sub_table) {
/* do the job again */
- return monitor_find_completion_by_table(mon, cmd->sub_table,
- &args[1], nb_args - 1);
+ monitor_find_completion_by_table(mon, cmd->sub_table,
+ &args[1], nb_args - 1);
+ return;
}
if (cmd->command_completion) {
- return cmd->command_completion(mon->rs, nb_args, args[nb_args - 1]);
+ cmd->command_completion(mon->rs, nb_args, args[nb_args - 1]);
+ return;
}
ptype = next_arg_type(cmd->args_type);
return (mon->suspend_cnt == 0) ? 1 : 0;
}
-static int invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd)
+static bool invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd)
{
- int is_cap = cmd->mhandler.cmd_new == do_qmp_capabilities;
- return (qmp_cmd_mode(mon) ? is_cap : !is_cap);
+ bool is_cap = cmd->mhandler.cmd_new == do_qmp_capabilities;
+ if (is_cap && qmp_cmd_mode(mon)) {
+ qerror_report(ERROR_CLASS_COMMAND_NOT_FOUND,
+ "Capabilities negotiation is already complete, command "
+ "'%s' ignored", cmd->name);
+ return true;
+ }
+ if (!is_cap && !qmp_cmd_mode(mon)) {
+ qerror_report(ERROR_CLASS_COMMAND_NOT_FOUND,
+ "Expecting capabilities negotiation with "
+ "'qmp_capabilities' before command '%s'", cmd->name);
+ return true;
+ }
+ return false;
}
/*
cmd_name = qdict_get_str(input, "execute");
trace_handle_qmp_command(mon, cmd_name);
cmd = qmp_find_cmd(cmd_name);
- if (!cmd || invalid_qmp_mode(mon, cmd)) {
+ if (!cmd) {
qerror_report(ERROR_CLASS_COMMAND_NOT_FOUND,
"The command %s has not been found", cmd_name);
goto err_out;
}
+ if (invalid_qmp_mode(mon, cmd)) {
+ goto err_out;
+ }
obj = qdict_get(input, "arguments");
if (!obj) {
BlockCompletionFunc *completion_cb,
void *opaque)
{
- Error *local_err = NULL;
int err;
- bdrv_add_key(bs, NULL, &local_err);
- if (!local_err) {
- if (completion_cb)
- completion_cb(opaque, 0);
- return 0;
- }
-
- /* Need a key for @bs */
-
- if (monitor_ctrl_mode(mon)) {
- qerror_report_err(local_err);
- return -1;
- }
-
monitor_printf(mon, "%s (%s) is encrypted.\n", bdrv_get_device_name(bs),
bdrv_get_encrypted_filename(bs));
BlockCompletionFunc *completion_cb,
void *opaque)
{
- BlockDriverState *bs;
+ Error *err = NULL;
+ BlockBackend *blk;
- bs = bdrv_find(device);
- if (!bs) {
+ blk = blk_by_name(device);
+ if (!blk) {
monitor_printf(mon, "Device not found %s\n", device);
return -1;
}
- return monitor_read_bdrv_key_start(mon, bs, completion_cb, opaque);
+ bdrv_add_key(blk_bs(blk), NULL, &err);
+ if (err) {
+ error_free(err);
+ return monitor_read_bdrv_key_start(mon, blk_bs(blk), completion_cb, opaque);
+ }
+
+ if (completion_cb) {
+ completion_cb(opaque, 0);
+ }
+ return 0;
}
QemuOptsList qemu_mon_opts = {