Monitor patches for 2020-02-15

-----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAl5KlHwSHGFybWJydUBy
 ZWRoYXQuY29tAAoJEDhwtADrkYZTKToP/jcMcvCoLRzKDzuaMqRLaHpVkMP1ewew
 G0s5EikybW+8lJO+1CiZIfeHkpPs3yOmU9xRW1cPArh1rJzvnAWqQyyCsYCFv71c
 W/HX86ilSUZCBJCWMUUnLnENKGVDaEk/nsVox2aA4RYMIhpfIiutDGXH0M0d21nB
 tYvPTaEHU+t56O85zPw6ITel5hFjMitGbOGMayGnnCUw6NWx1iSWwikq7c/R5cXB
 qBYaXRwK/dH0KinRfm8EnlzuYOvw4d2kyisuujPml5tmC/nOPQNzYjV9n1qFVJY2
 ICVHEJa9hNC1Mr01fxa2DDFy7t6bxWHFzlow1dI+7ISlW9d+3RpDbM4P1+AkKF9F
 BX9QbdJAu+9opu693MkFv2vLbW5nqN/Fm7ylSZJfXGbtqpOFWbuBv+5ug/qD3G8t
 nABJpU2Y29Y8N5LCb/SsacyOgZjjsjiWP5iojlSRsu+c9lCX9/8y74PGz5KqBIst
 4RjzJ4l7I0IpkSa1Puln0XYoXX6mSw+IQZcHBh0D/L8gh3LI6rLsKSSwW2NepvxL
 t98zqJYWJv6CBdpqwJLOr7x8yB06GbSDmaLM2HTlnf5O7kbucCPbY4TdwmttsaNw
 +LA7eixaO+MX6DOKH2rx2AtJvUf2iUWoNDCMyp3F6yB46fh91Ht9VHF6mIvE8qRp
 B+nZDOpEoNV8
 =B1lO
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/armbru/tags/pull-monitor-2020-02-15-v2' into staging

Monitor patches for 2020-02-15

# gpg: Signature made Mon 17 Feb 2020 13:26:20 GMT
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "armbru@redhat.com"
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-monitor-2020-02-15-v2:
  qemu-doc: Clarify extent of build platform support
  monitor: Move qmp_query_qmp_schema to qmp-cmds-control.c
  monitor: Collect "control" command handlers in qmp-cmds.control.c
  qapi: Split control.json off misc.json
  monitor: Move monitor option parsing to monitor/monitor.c

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2020-02-17 13:32:25 +00:00
commit 6c599282f8
18 changed files with 460 additions and 407 deletions

View File

@ -10,12 +10,15 @@ typedef struct MonitorHMP MonitorHMP;
#define QMP_REQ_QUEUE_LEN_MAX 8 #define QMP_REQ_QUEUE_LEN_MAX 8
extern QemuOptsList qemu_mon_opts;
bool monitor_cur_is_qmp(void); bool monitor_cur_is_qmp(void);
void monitor_init_globals(void); void monitor_init_globals(void);
void monitor_init_globals_core(void); void monitor_init_globals_core(void);
void monitor_init_qmp(Chardev *chr, bool pretty); void monitor_init_qmp(Chardev *chr, bool pretty);
void monitor_init_hmp(Chardev *chr, bool use_readline); void monitor_init_hmp(Chardev *chr, bool use_readline);
int monitor_init_opts(QemuOpts *opts, Error **errp);
void monitor_cleanup(void); void monitor_cleanup(void);
int monitor_suspend(Monitor *mon); int monitor_suspend(Monitor *mon);

View File

@ -125,7 +125,6 @@ extern QemuOptsList qemu_netdev_opts;
extern QemuOptsList qemu_nic_opts; extern QemuOptsList qemu_nic_opts;
extern QemuOptsList qemu_net_opts; extern QemuOptsList qemu_net_opts;
extern QemuOptsList qemu_global_opts; extern QemuOptsList qemu_global_opts;
extern QemuOptsList qemu_mon_opts;
extern QemuOptsList qemu_semihosting_config_opts; extern QemuOptsList qemu_semihosting_config_opts;
#endif #endif

View File

@ -1,3 +1,4 @@
obj-y += misc.o obj-y += misc.o
common-obj-y += monitor.o qmp.o hmp.o common-obj-y += monitor.o qmp.o hmp.o
common-obj-y += qmp-cmds.o hmp-cmds.o common-obj-y += qmp-cmds.o qmp-cmds-control.o
common-obj-y += hmp-cmds.o

View File

@ -31,6 +31,7 @@
#include "qapi/qapi-builtin-visit.h" #include "qapi/qapi-builtin-visit.h"
#include "qapi/qapi-commands-block.h" #include "qapi/qapi-commands-block.h"
#include "qapi/qapi-commands-char.h" #include "qapi/qapi-commands-char.h"
#include "qapi/qapi-commands-control.h"
#include "qapi/qapi-commands-migration.h" #include "qapi/qapi-commands-migration.h"
#include "qapi/qapi-commands-misc.h" #include "qapi/qapi-commands-misc.h"
#include "qapi/qapi-commands-net.h" #include "qapi/qapi-commands-net.h"

View File

@ -67,15 +67,14 @@
#include "qemu/thread.h" #include "qemu/thread.h"
#include "block/qapi.h" #include "block/qapi.h"
#include "qapi/qapi-commands-char.h" #include "qapi/qapi-commands-char.h"
#include "qapi/qapi-commands-control.h"
#include "qapi/qapi-commands-migration.h" #include "qapi/qapi-commands-migration.h"
#include "qapi/qapi-commands-misc.h" #include "qapi/qapi-commands-misc.h"
#include "qapi/qapi-commands-qom.h" #include "qapi/qapi-commands-qom.h"
#include "qapi/qapi-commands-trace.h" #include "qapi/qapi-commands-trace.h"
#include "qapi/qapi-emit-events.h"
#include "qapi/qapi-init-commands.h" #include "qapi/qapi-init-commands.h"
#include "qapi/error.h" #include "qapi/error.h"
#include "qapi/qmp-event.h" #include "qapi/qmp-event.h"
#include "qapi/qapi-introspect.h"
#include "sysemu/cpus.h" #include "sysemu/cpus.h"
#include "qemu/cutils.h" #include "qemu/cutils.h"
#include "tcg/tcg.h" #include "tcg/tcg.h"
@ -232,73 +231,6 @@ static void hmp_info_help(Monitor *mon, const QDict *qdict)
help_cmd(mon, "info"); help_cmd(mon, "info");
} }
static void query_commands_cb(QmpCommand *cmd, void *opaque)
{
CommandInfoList *info, **list = opaque;
if (!cmd->enabled) {
return;
}
info = g_malloc0(sizeof(*info));
info->value = g_malloc0(sizeof(*info->value));
info->value->name = g_strdup(cmd->name);
info->next = *list;
*list = info;
}
CommandInfoList *qmp_query_commands(Error **errp)
{
CommandInfoList *list = NULL;
MonitorQMP *mon;
assert(monitor_is_qmp(cur_mon));
mon = container_of(cur_mon, MonitorQMP, common);
qmp_for_each_command(mon->commands, query_commands_cb, &list);
return list;
}
EventInfoList *qmp_query_events(Error **errp)
{
/*
* TODO This deprecated command is the only user of
* QAPIEvent_str() and QAPIEvent_lookup[]. When the command goes,
* they should go, too.
*/
EventInfoList *info, *ev_list = NULL;
QAPIEvent e;
for (e = 0 ; e < QAPI_EVENT__MAX ; e++) {
const char *event_name = QAPIEvent_str(e);
assert(event_name != NULL);
info = g_malloc0(sizeof(*info));
info->value = g_malloc0(sizeof(*info->value));
info->value->name = g_strdup(event_name);
info->next = ev_list;
ev_list = info;
}
return ev_list;
}
/*
* Minor hack: generated marshalling suppressed for this command
* ('gen': false in the schema) so we can parse the JSON string
* directly into QObject instead of first parsing it with
* visit_type_SchemaInfoList() into a SchemaInfoList, then marshal it
* to QObject with generated output marshallers, every time. Instead,
* we do it in test-qobject-input-visitor.c, just to make sure
* qapi-gen.py's output actually conforms to the schema.
*/
static void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data,
Error **errp)
{
*ret_data = qobject_from_qlit(&qmp_schema_qlit);
}
static void monitor_init_qmp_commands(void) static void monitor_init_qmp_commands(void)
{ {
/* /*
@ -322,63 +254,6 @@ static void monitor_init_qmp_commands(void)
qmp_marshal_qmp_capabilities, QCO_ALLOW_PRECONFIG); qmp_marshal_qmp_capabilities, QCO_ALLOW_PRECONFIG);
} }
/*
* Accept QMP capabilities in @list for @mon.
* On success, set mon->qmp.capab[], and return true.
* On error, set @errp, and return false.
*/
static bool qmp_caps_accept(MonitorQMP *mon, QMPCapabilityList *list,
Error **errp)
{
GString *unavailable = NULL;
bool capab[QMP_CAPABILITY__MAX];
memset(capab, 0, sizeof(capab));
for (; list; list = list->next) {
if (!mon->capab_offered[list->value]) {
if (!unavailable) {
unavailable = g_string_new(QMPCapability_str(list->value));
} else {
g_string_append_printf(unavailable, ", %s",
QMPCapability_str(list->value));
}
}
capab[list->value] = true;
}
if (unavailable) {
error_setg(errp, "Capability %s not available", unavailable->str);
g_string_free(unavailable, true);
return false;
}
memcpy(mon->capab, capab, sizeof(capab));
return true;
}
void qmp_qmp_capabilities(bool has_enable, QMPCapabilityList *enable,
Error **errp)
{
MonitorQMP *mon;
assert(monitor_is_qmp(cur_mon));
mon = container_of(cur_mon, MonitorQMP, common);
if (mon->commands == &qmp_commands) {
error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
"Capabilities negotiation is already complete, command "
"ignored");
return;
}
if (!qmp_caps_accept(mon, enable, errp)) {
return;
}
mon->commands = &qmp_commands;
}
/* Set the current CPU defined by the user. Callers must hold BQL. */ /* Set the current CPU defined by the user. Callers must hold BQL. */
int monitor_set_cpu(int cpu_index) int monitor_set_cpu(int cpu_index)
{ {

View File

@ -27,6 +27,7 @@
#include "chardev/char-fe.h" #include "chardev/char-fe.h"
#include "monitor/monitor.h" #include "monitor/monitor.h"
#include "qapi/qapi-types-control.h"
#include "qapi/qmp/dispatch.h" #include "qapi/qmp/dispatch.h"
#include "qapi/qmp/json-parser.h" #include "qapi/qmp/json-parser.h"
#include "qemu/readline.h" #include "qemu/readline.h"
@ -179,4 +180,7 @@ void help_cmd(Monitor *mon, const char *name);
void handle_hmp_command(MonitorHMP *mon, const char *cmdline); void handle_hmp_command(MonitorHMP *mon, const char *cmdline);
int hmp_compare_cmd(const char *name, const char *list); int hmp_compare_cmd(const char *name, const char *list);
void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data,
Error **errp);
#endif #endif

View File

@ -609,6 +609,54 @@ void monitor_init_globals_core(void)
NULL); NULL);
} }
int monitor_init_opts(QemuOpts *opts, Error **errp)
{
Chardev *chr;
bool qmp;
bool pretty = false;
const char *chardev;
const char *mode;
mode = qemu_opt_get(opts, "mode");
if (mode == NULL) {
mode = "readline";
}
if (strcmp(mode, "readline") == 0) {
qmp = false;
} else if (strcmp(mode, "control") == 0) {
qmp = true;
} else {
error_setg(errp, "unknown monitor mode \"%s\"", mode);
return -1;
}
if (!qmp && qemu_opt_get(opts, "pretty")) {
warn_report("'pretty' is deprecated for HMP monitors, it has no effect "
"and will be removed in future versions");
}
if (qemu_opt_get_bool(opts, "pretty", 0)) {
pretty = true;
}
chardev = qemu_opt_get(opts, "chardev");
if (!chardev) {
error_report("chardev is required");
exit(1);
}
chr = qemu_chr_find(chardev);
if (chr == NULL) {
error_setg(errp, "chardev \"%s\" not found", chardev);
return -1;
}
if (qmp) {
monitor_init_qmp(chr, pretty);
} else {
monitor_init_hmp(chr, true);
}
return 0;
}
QemuOptsList qemu_mon_opts = { QemuOptsList qemu_mon_opts = {
.name = "mon", .name = "mon",
.implied_opt_name = "chardev", .implied_opt_name = "chardev",

169
monitor/qmp-cmds-control.c Normal file
View File

@ -0,0 +1,169 @@
/*
* QMP commands related to the monitor (common to sysemu and tools)
*
* Copyright (c) 2003-2004 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "qemu/osdep.h"
#include "monitor-internal.h"
#include "qemu-version.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-control.h"
#include "qapi/qapi-emit-events.h"
#include "qapi/qapi-introspect.h"
/*
* Accept QMP capabilities in @list for @mon.
* On success, set mon->qmp.capab[], and return true.
* On error, set @errp, and return false.
*/
static bool qmp_caps_accept(MonitorQMP *mon, QMPCapabilityList *list,
Error **errp)
{
GString *unavailable = NULL;
bool capab[QMP_CAPABILITY__MAX];
memset(capab, 0, sizeof(capab));
for (; list; list = list->next) {
if (!mon->capab_offered[list->value]) {
if (!unavailable) {
unavailable = g_string_new(QMPCapability_str(list->value));
} else {
g_string_append_printf(unavailable, ", %s",
QMPCapability_str(list->value));
}
}
capab[list->value] = true;
}
if (unavailable) {
error_setg(errp, "Capability %s not available", unavailable->str);
g_string_free(unavailable, true);
return false;
}
memcpy(mon->capab, capab, sizeof(capab));
return true;
}
void qmp_qmp_capabilities(bool has_enable, QMPCapabilityList *enable,
Error **errp)
{
MonitorQMP *mon;
assert(monitor_is_qmp(cur_mon));
mon = container_of(cur_mon, MonitorQMP, common);
if (mon->commands == &qmp_commands) {
error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND,
"Capabilities negotiation is already complete, command "
"ignored");
return;
}
if (!qmp_caps_accept(mon, enable, errp)) {
return;
}
mon->commands = &qmp_commands;
}
VersionInfo *qmp_query_version(Error **errp)
{
VersionInfo *info = g_new0(VersionInfo, 1);
info->qemu = g_new0(VersionTriple, 1);
info->qemu->major = QEMU_VERSION_MAJOR;
info->qemu->minor = QEMU_VERSION_MINOR;
info->qemu->micro = QEMU_VERSION_MICRO;
info->package = g_strdup(QEMU_PKGVERSION);
return info;
}
static void query_commands_cb(QmpCommand *cmd, void *opaque)
{
CommandInfoList *info, **list = opaque;
if (!cmd->enabled) {
return;
}
info = g_malloc0(sizeof(*info));
info->value = g_malloc0(sizeof(*info->value));
info->value->name = g_strdup(cmd->name);
info->next = *list;
*list = info;
}
CommandInfoList *qmp_query_commands(Error **errp)
{
CommandInfoList *list = NULL;
MonitorQMP *mon;
assert(monitor_is_qmp(cur_mon));
mon = container_of(cur_mon, MonitorQMP, common);
qmp_for_each_command(mon->commands, query_commands_cb, &list);
return list;
}
EventInfoList *qmp_query_events(Error **errp)
{
/*
* TODO This deprecated command is the only user of
* QAPIEvent_str() and QAPIEvent_lookup[]. When the command goes,
* they should go, too.
*/
EventInfoList *info, *ev_list = NULL;
QAPIEvent e;
for (e = 0 ; e < QAPI_EVENT__MAX ; e++) {
const char *event_name = QAPIEvent_str(e);
assert(event_name != NULL);
info = g_malloc0(sizeof(*info));
info->value = g_malloc0(sizeof(*info->value));
info->value->name = g_strdup(event_name);
info->next = ev_list;
ev_list = info;
}
return ev_list;
}
/*
* Minor hack: generated marshalling suppressed for this command
* ('gen': false in the schema) so we can parse the JSON string
* directly into QObject instead of first parsing it with
* visit_type_SchemaInfoList() into a SchemaInfoList, then marshal it
* to QObject with generated output marshallers, every time. Instead,
* we do it in test-qobject-input-visitor.c, just to make sure
* qapi-gen.py's output actually conforms to the schema.
*/
void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data,
Error **errp)
{
*ret_data = qobject_from_qlit(&qmp_schema_qlit);
}

View File

@ -15,7 +15,6 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qemu-common.h" #include "qemu-common.h"
#include "qemu-version.h"
#include "qemu/cutils.h" #include "qemu/cutils.h"
#include "qemu/option.h" #include "qemu/option.h"
#include "monitor/monitor.h" #include "monitor/monitor.h"
@ -32,6 +31,7 @@
#include "sysemu/block-backend.h" #include "sysemu/block-backend.h"
#include "qapi/error.h" #include "qapi/error.h"
#include "qapi/qapi-commands-block-core.h" #include "qapi/qapi-commands-block-core.h"
#include "qapi/qapi-commands-control.h"
#include "qapi/qapi-commands-machine.h" #include "qapi/qapi-commands-machine.h"
#include "qapi/qapi-commands-misc.h" #include "qapi/qapi-commands-misc.h"
#include "qapi/qapi-commands-ui.h" #include "qapi/qapi-commands-ui.h"
@ -51,19 +51,6 @@ NameInfo *qmp_query_name(Error **errp)
return info; return info;
} }
VersionInfo *qmp_query_version(Error **errp)
{
VersionInfo *info = g_new0(VersionInfo, 1);
info->qemu = g_new0(VersionTriple, 1);
info->qemu->major = QEMU_VERSION_MAJOR;
info->qemu->minor = QEMU_VERSION_MINOR;
info->qemu->micro = QEMU_VERSION_MICRO;
info->package = g_strdup(QEMU_PKGVERSION);
return info;
}
KvmInfo *qmp_query_kvm(Error **errp) KvmInfo *qmp_query_kvm(Error **errp)
{ {
KvmInfo *info = g_malloc0(sizeof(*info)); KvmInfo *info = g_malloc0(sizeof(*info));

View File

@ -27,7 +27,7 @@
#include "chardev/char-io.h" #include "chardev/char-io.h"
#include "monitor-internal.h" #include "monitor-internal.h"
#include "qapi/error.h" #include "qapi/error.h"
#include "qapi/qapi-commands-misc.h" #include "qapi/qapi-commands-control.h"
#include "qapi/qmp/qdict.h" #include "qapi/qmp/qdict.h"
#include "qapi/qmp/qjson.h" #include "qapi/qmp/qjson.h"
#include "qapi/qmp/qlist.h" #include "qapi/qmp/qlist.h"

View File

@ -5,9 +5,9 @@ util-obj-y += opts-visitor.o qapi-clone-visitor.o
util-obj-y += qmp-event.o util-obj-y += qmp-event.o
util-obj-y += qapi-util.o util-obj-y += qapi-util.o
QAPI_COMMON_MODULES = audio authz block-core block char common crypto QAPI_COMMON_MODULES = audio authz block-core block char common control crypto
QAPI_COMMON_MODULES += dump error introspect job machine migration misc net QAPI_COMMON_MODULES += dump error introspect job machine migration misc
QAPI_COMMON_MODULES += qdev qom rdma rocker run-state sockets tpm QAPI_COMMON_MODULES += net qdev qom rdma rocker run-state sockets tpm
QAPI_COMMON_MODULES += trace transaction ui QAPI_COMMON_MODULES += trace transaction ui
QAPI_TARGET_MODULES = machine-target misc-target QAPI_TARGET_MODULES = machine-target misc-target
QAPI_MODULES = $(QAPI_COMMON_MODULES) $(QAPI_TARGET_MODULES) QAPI_MODULES = $(QAPI_COMMON_MODULES) $(QAPI_TARGET_MODULES)

218
qapi/control.json Normal file
View File

@ -0,0 +1,218 @@
# -*- Mode: Python -*-
#
##
# = QMP monitor control
##
##
# @qmp_capabilities:
#
# Enable QMP capabilities.
#
# Arguments:
#
# @enable: An optional list of QMPCapability values to enable. The
# client must not enable any capability that is not
# mentioned in the QMP greeting message. If the field is not
# provided, it means no QMP capabilities will be enabled.
# (since 2.12)
#
# Example:
#
# -> { "execute": "qmp_capabilities",
# "arguments": { "enable": [ "oob" ] } }
# <- { "return": {} }
#
# Notes: This command is valid exactly when first connecting: it must be
# issued before any other command will be accepted, and will fail once the
# monitor is accepting other commands. (see qemu docs/interop/qmp-spec.txt)
#
# The QMP client needs to explicitly enable QMP capabilities, otherwise
# all the QMP capabilities will be turned off by default.
#
# Since: 0.13
#
##
{ 'command': 'qmp_capabilities',
'data': { '*enable': [ 'QMPCapability' ] },
'allow-preconfig': true }
##
# @QMPCapability:
#
# Enumeration of capabilities to be advertised during initial client
# connection, used for agreeing on particular QMP extension behaviors.
#
# @oob: QMP ability to support out-of-band requests.
# (Please refer to qmp-spec.txt for more information on OOB)
#
# Since: 2.12
#
##
{ 'enum': 'QMPCapability',
'data': [ 'oob' ] }
##
# @VersionTriple:
#
# A three-part version number.
#
# @major: The major version number.
#
# @minor: The minor version number.
#
# @micro: The micro version number.
#
# Since: 2.4
##
{ 'struct': 'VersionTriple',
'data': {'major': 'int', 'minor': 'int', 'micro': 'int'} }
##
# @VersionInfo:
#
# A description of QEMU's version.
#
# @qemu: The version of QEMU. By current convention, a micro
# version of 50 signifies a development branch. A micro version
# greater than or equal to 90 signifies a release candidate for
# the next minor version. A micro version of less than 50
# signifies a stable release.
#
# @package: QEMU will always set this field to an empty string. Downstream
# versions of QEMU should set this to a non-empty string. The
# exact format depends on the downstream however it highly
# recommended that a unique name is used.
#
# Since: 0.14.0
##
{ 'struct': 'VersionInfo',
'data': {'qemu': 'VersionTriple', 'package': 'str'} }
##
# @query-version:
#
# Returns the current version of QEMU.
#
# Returns: A @VersionInfo object describing the current version of QEMU.
#
# Since: 0.14.0
#
# Example:
#
# -> { "execute": "query-version" }
# <- {
# "return":{
# "qemu":{
# "major":0,
# "minor":11,
# "micro":5
# },
# "package":""
# }
# }
#
##
{ 'command': 'query-version', 'returns': 'VersionInfo',
'allow-preconfig': true }
##
# @CommandInfo:
#
# Information about a QMP command
#
# @name: The command name
#
# Since: 0.14.0
##
{ 'struct': 'CommandInfo', 'data': {'name': 'str'} }
##
# @query-commands:
#
# Return a list of supported QMP commands by this server
#
# Returns: A list of @CommandInfo for all supported commands
#
# Since: 0.14.0
#
# Example:
#
# -> { "execute": "query-commands" }
# <- {
# "return":[
# {
# "name":"query-balloon"
# },
# {
# "name":"system_powerdown"
# }
# ]
# }
#
# Note: This example has been shortened as the real response is too long.
#
##
{ 'command': 'query-commands', 'returns': ['CommandInfo'],
'allow-preconfig': true }
##
# @EventInfo:
#
# Information about a QMP event
#
# @name: The event name
#
# Since: 1.2.0
##
{ 'struct': 'EventInfo', 'data': {'name': 'str'} }
##
# @query-events:
#
# Return information on QMP events.
#
# Returns: A list of @EventInfo.
#
# Since: 1.2.0
#
# Note: This command is deprecated, because its output doesn't reflect
# compile-time configuration. Use query-qmp-schema instead.
#
# Example:
#
# -> { "execute": "query-events" }
# <- {
# "return": [
# {
# "name":"SHUTDOWN"
# },
# {
# "name":"RESET"
# }
# ]
# }
#
# Note: This example has been shortened as the real response is too long.
#
##
{ 'command': 'query-events', 'returns': ['EventInfo'] }
##
# @quit:
#
# This command will cause the QEMU process to exit gracefully. While every
# attempt is made to send the QMP response before terminating, this is not
# guaranteed. When using this interface, a premature EOF would not be
# unexpected.
#
# Since: 0.14.0
#
# Example:
#
# -> { "execute": "quit" }
# <- { "return": {} }
##
{ 'command': 'quit' }

View File

@ -7,159 +7,6 @@
{ 'include': 'common.json' } { 'include': 'common.json' }
##
# @qmp_capabilities:
#
# Enable QMP capabilities.
#
# Arguments:
#
# @enable: An optional list of QMPCapability values to enable. The
# client must not enable any capability that is not
# mentioned in the QMP greeting message. If the field is not
# provided, it means no QMP capabilities will be enabled.
# (since 2.12)
#
# Example:
#
# -> { "execute": "qmp_capabilities",
# "arguments": { "enable": [ "oob" ] } }
# <- { "return": {} }
#
# Notes: This command is valid exactly when first connecting: it must be
# issued before any other command will be accepted, and will fail once the
# monitor is accepting other commands. (see qemu docs/interop/qmp-spec.txt)
#
# The QMP client needs to explicitly enable QMP capabilities, otherwise
# all the QMP capabilities will be turned off by default.
#
# Since: 0.13
#
##
{ 'command': 'qmp_capabilities',
'data': { '*enable': [ 'QMPCapability' ] },
'allow-preconfig': true }
##
# @QMPCapability:
#
# Enumeration of capabilities to be advertised during initial client
# connection, used for agreeing on particular QMP extension behaviors.
#
# @oob: QMP ability to support out-of-band requests.
# (Please refer to qmp-spec.txt for more information on OOB)
#
# Since: 2.12
#
##
{ 'enum': 'QMPCapability',
'data': [ 'oob' ] }
##
# @VersionTriple:
#
# A three-part version number.
#
# @major: The major version number.
#
# @minor: The minor version number.
#
# @micro: The micro version number.
#
# Since: 2.4
##
{ 'struct': 'VersionTriple',
'data': {'major': 'int', 'minor': 'int', 'micro': 'int'} }
##
# @VersionInfo:
#
# A description of QEMU's version.
#
# @qemu: The version of QEMU. By current convention, a micro
# version of 50 signifies a development branch. A micro version
# greater than or equal to 90 signifies a release candidate for
# the next minor version. A micro version of less than 50
# signifies a stable release.
#
# @package: QEMU will always set this field to an empty string. Downstream
# versions of QEMU should set this to a non-empty string. The
# exact format depends on the downstream however it highly
# recommended that a unique name is used.
#
# Since: 0.14.0
##
{ 'struct': 'VersionInfo',
'data': {'qemu': 'VersionTriple', 'package': 'str'} }
##
# @query-version:
#
# Returns the current version of QEMU.
#
# Returns: A @VersionInfo object describing the current version of QEMU.
#
# Since: 0.14.0
#
# Example:
#
# -> { "execute": "query-version" }
# <- {
# "return":{
# "qemu":{
# "major":0,
# "minor":11,
# "micro":5
# },
# "package":""
# }
# }
#
##
{ 'command': 'query-version', 'returns': 'VersionInfo',
'allow-preconfig': true }
##
# @CommandInfo:
#
# Information about a QMP command
#
# @name: The command name
#
# Since: 0.14.0
##
{ 'struct': 'CommandInfo', 'data': {'name': 'str'} }
##
# @query-commands:
#
# Return a list of supported QMP commands by this server
#
# Returns: A list of @CommandInfo for all supported commands
#
# Since: 0.14.0
#
# Example:
#
# -> { "execute": "query-commands" }
# <- {
# "return":[
# {
# "name":"query-balloon"
# },
# {
# "name":"system_powerdown"
# }
# ]
# }
#
# Note: This example has been shortened as the real response is too long.
#
##
{ 'command': 'query-commands', 'returns': ['CommandInfo'],
'allow-preconfig': true }
## ##
# @LostTickPolicy: # @LostTickPolicy:
# #
@ -312,48 +159,6 @@
## ##
{ 'command': 'query-uuid', 'returns': 'UuidInfo', 'allow-preconfig': true } { 'command': 'query-uuid', 'returns': 'UuidInfo', 'allow-preconfig': true }
##
# @EventInfo:
#
# Information about a QMP event
#
# @name: The event name
#
# Since: 1.2.0
##
{ 'struct': 'EventInfo', 'data': {'name': 'str'} }
##
# @query-events:
#
# Return information on QMP events.
#
# Returns: A list of @EventInfo.
#
# Since: 1.2.0
#
# Note: This command is deprecated, because its output doesn't reflect
# compile-time configuration. Use query-qmp-schema instead.
#
# Example:
#
# -> { "execute": "query-events" }
# <- {
# "return": [
# {
# "name":"SHUTDOWN"
# },
# {
# "name":"RESET"
# }
# ]
# }
#
# Note: This example has been shortened as the real response is too long.
#
##
{ 'command': 'query-events', 'returns': ['EventInfo'] }
## ##
# @IOThreadInfo: # @IOThreadInfo:
# #
@ -774,23 +579,6 @@
## ##
{ 'command': 'query-pci', 'returns': ['PciInfo'] } { 'command': 'query-pci', 'returns': ['PciInfo'] }
##
# @quit:
#
# This command will cause the QEMU process to exit gracefully. While every
# attempt is made to send the QMP response before terminating, this is not
# guaranteed. When using this interface, a premature EOF would not be
# unexpected.
#
# Since: 0.14.0
#
# Example:
#
# -> { "execute": "quit" }
# <- { "return": {} }
##
{ 'command': 'quit' }
## ##
# @stop: # @stop:
# #

View File

@ -98,6 +98,7 @@
{ 'include': 'migration.json' } { 'include': 'migration.json' }
{ 'include': 'transaction.json' } { 'include': 'transaction.json' }
{ 'include': 'trace.json' } { 'include': 'trace.json' }
{ 'include': 'control.json' }
{ 'include': 'introspect.json' } { 'include': 'introspect.json' }
{ 'include': 'qom.json' } { 'include': 'qom.json' }
{ 'include': 'qdev.json' } { 'include': 'qdev.json' }

View File

@ -2880,10 +2880,11 @@ lifetime distros will be assumed to ship similar software versions.
For distributions with long-lifetime releases, the project will aim to support For distributions with long-lifetime releases, the project will aim to support
the most recent major version at all times. Support for the previous major the most recent major version at all times. Support for the previous major
version will be dropped 2 years after the new major version is released. For version will be dropped 2 years after the new major version is released,
the purposes of identifying supported software versions, the project will look or when it reaches ``end of life''. For the purposes of identifying
at RHEL, Debian, Ubuntu LTS, and SLES distros. Other long-lifetime distros will supported software versions, the project will look at RHEL, Debian,
be assumed to ship similar software versions. Ubuntu LTS, and SLES distros. Other long-lifetime distros will be
assumed to ship similar software versions.
@section Windows @section Windows

View File

@ -13,7 +13,7 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "libqtest.h" #include "libqtest.h"
#include "qapi/error.h" #include "qapi/error.h"
#include "qapi/qapi-visit-misc.h" #include "qapi/qapi-visit-control.h"
#include "qapi/qmp/qdict.h" #include "qapi/qmp/qdict.h"
#include "qapi/qmp/qlist.h" #include "qapi/qmp/qlist.h"
#include "qapi/qobject-input-visitor.h" #include "qapi/qobject-input-visitor.h"

View File

@ -32,6 +32,7 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qapi/error.h" #include "qapi/error.h"
#include "qapi/qapi-commands-control.h"
#include "qapi/qapi-commands-misc.h" #include "qapi/qapi-commands-misc.h"
#include "qemu/cutils.h" #include "qemu/cutils.h"

45
vl.c
View File

@ -2127,50 +2127,7 @@ static int fsdev_init_func(void *opaque, QemuOpts *opts, Error **errp)
static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp) static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp)
{ {
Chardev *chr; return monitor_init_opts(opts, errp);
bool qmp;
bool pretty = false;
const char *chardev;
const char *mode;
mode = qemu_opt_get(opts, "mode");
if (mode == NULL) {
mode = "readline";
}
if (strcmp(mode, "readline") == 0) {
qmp = false;
} else if (strcmp(mode, "control") == 0) {
qmp = true;
} else {
error_setg(errp, "unknown monitor mode \"%s\"", mode);
return -1;
}
if (!qmp && qemu_opt_get(opts, "pretty")) {
warn_report("'pretty' is deprecated for HMP monitors, it has no effect "
"and will be removed in future versions");
}
if (qemu_opt_get_bool(opts, "pretty", 0)) {
pretty = true;
}
chardev = qemu_opt_get(opts, "chardev");
if (!chardev) {
error_report("chardev is required");
exit(1);
}
chr = qemu_chr_find(chardev);
if (chr == NULL) {
error_setg(errp, "chardev \"%s\" not found", chardev);
return -1;
}
if (qmp) {
monitor_init_qmp(chr, pretty);
} else {
monitor_init_hmp(chr, true);
}
return 0;
} }
static void monitor_parse(const char *optarg, const char *mode, bool pretty) static void monitor_parse(const char *optarg, const char *mode, bool pretty)