Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/armbru/tags/pull-monitor-2019-0…
Browse files Browse the repository at this point in the history
…6-17-v2' into staging

Monitor patches for 2019-06-17

# gpg: Signature made Tue 18 Jun 2019 07:20:25 BST
# 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-2019-06-17-v2:
  vl: Deprecate -mon pretty=... for HMP monitors
  monitor: Replace monitor_init() with monitor_init_{hmp, qmp}()
  monitor: Split Monitor.flags into separate bools
  monitor: Split out monitor/monitor.c
  monitor: Split out monitor/hmp.c
  monitor: Split out monitor/qmp.c
  monitor: Create monitor-internal.h with common definitions
  monitor: Move {hmp, qmp}.c to monitor/{hmp, qmp}-cmds.c
  Move monitor.c to monitor/misc.c
  monitor: Rename HMP command type and tables
  monitor: Remove Monitor.cmd_table indirection
  monitor: Create MonitorHMP with readline state
  monitor: Make MonitorQMP a child class of Monitor
  monitor: Split monitor_init in HMP and QMP function
  monitor: Remove unused password prompting fields
  monitor: Fix return type of monitor_fdset_dup_fd_find

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Jun 18, 2019
2 parents 076243f + 3c45f62 commit cdfaa27
Show file tree
Hide file tree
Showing 24 changed files with 5,073 additions and 4,777 deletions.
13 changes: 9 additions & 4 deletions MAINTAINERS
Expand Up @@ -1918,8 +1918,11 @@ F: qapi/run-state.json
Human Monitor (HMP)
M: Dr. David Alan Gilbert <dgilbert@redhat.com>
S: Maintained
F: monitor.c
F: hmp.[ch]
F: monitor/monitor-internal.h
F: monitor/misc.c
F: monitor/monitor.c
F: monitor/hmp*
F: hmp.h
F: hmp-commands*.hx
F: include/monitor/hmp-target.h
F: tests/test-hmp.c
Expand Down Expand Up @@ -2039,8 +2042,10 @@ F: tests/check-qom-proplist.c
QMP
M: Markus Armbruster <armbru@redhat.com>
S: Supported
F: qmp.c
F: monitor.c
F: monitor/monitor-internal.h
F: monitor/qmp*
F: monitor/misc.c
F: monitor/monitor.c
F: docs/devel/*qmp-*
F: docs/interop/*qmp-*
F: scripts/qmp/
Expand Down
4 changes: 3 additions & 1 deletion Makefile.objs
Expand Up @@ -46,6 +46,7 @@ ifeq ($(CONFIG_SOFTMMU),y)
common-obj-y = blockdev.o blockdev-nbd.o block/
common-obj-y += bootdevice.o iothread.o
common-obj-y += job-qmp.o
common-obj-y += monitor/
common-obj-y += net/
common-obj-y += qdev-monitor.o device-hotplug.o
common-obj-$(CONFIG_WIN32) += os-win32.o
Expand Down Expand Up @@ -83,8 +84,8 @@ common-obj-$(CONFIG_FDT) += device_tree.o
######################################################################
# qapi

common-obj-y += qmp.o hmp.o
common-obj-y += qapi/
common-obj-y += monitor/
endif

#######################################################################
Expand Down Expand Up @@ -130,6 +131,7 @@ trace-events-subdirs =
trace-events-subdirs += accel/kvm
trace-events-subdirs += accel/tcg
trace-events-subdirs += crypto
trace-events-subdirs += monitor
ifeq ($(CONFIG_USER_ONLY),y)
trace-events-subdirs += linux-user
endif
Expand Down
3 changes: 2 additions & 1 deletion Makefile.target
Expand Up @@ -148,9 +148,10 @@ endif #CONFIG_BSD_USER
#########################################################
# System emulator target
ifdef CONFIG_SOFTMMU
obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
obj-y += arch_init.o cpus.o gdbstub.o balloon.o ioport.o numa.o
obj-y += qtest.o
obj-y += hw/
obj-y += monitor/
obj-y += qapi/
obj-y += memory.o
obj-y += memory_mapping.o
Expand Down
2 changes: 1 addition & 1 deletion chardev/char.c
Expand Up @@ -731,7 +731,7 @@ Chardev *qemu_chr_new_noreplay(const char *label, const char *filename,

if (qemu_opt_get_bool(opts, "mux", 0)) {
assert(permit_mux_mon);
monitor_init(chr, MONITOR_USE_READLINE);
monitor_init_hmp(chr, true);
}

out:
Expand Down
11 changes: 6 additions & 5 deletions docs/devel/writing-qmp-commands.txt
Expand Up @@ -20,7 +20,7 @@ new QMP command.

2. Write the QMP command itself, which is a regular C function. Preferably,
the command should be exported by some QEMU subsystem. But it can also be
added to the qmp.c file
added to the monitor/qmp-cmds.c file

3. At this point the command can be tested under the QMP protocol

Expand Down Expand Up @@ -101,7 +101,8 @@ protocol data.

The next step is to write the "hello-world" implementation. As explained
earlier, it's preferable for commands to live in QEMU subsystems. But
"hello-world" doesn't pertain to any, so we put its implementation in qmp.c:
"hello-world" doesn't pertain to any, so we put its implementation in
monitor/qmp-cmds.c:

void qmp_hello_world(Error **errp)
{
Expand Down Expand Up @@ -146,7 +147,7 @@ for mandatory arguments). Finally, 'str' is the argument's type, which
stands for "string". The QAPI also supports integers, booleans, enumerations
and user defined types.

Now, let's update our C implementation in qmp.c:
Now, let's update our C implementation in monitor/qmp-cmds.c:

void qmp_hello_world(bool has_message, const char *message, Error **errp)
{
Expand Down Expand Up @@ -267,7 +268,7 @@ monitor (HMP).

With the introduction of the QAPI, HMP commands make QMP calls. Most of the
time HMP commands are simple wrappers. All HMP commands implementation exist in
the hmp.c file.
the monitor/hmp-cmds.c file.

Here's the implementation of the "hello-world" HMP command:

Expand Down Expand Up @@ -470,7 +471,7 @@ it's good practice to always check for errors.

Another important detail is that HMP's "info" commands don't go into the
hmp-commands.hx. Instead, they go into the info_cmds[] table, which is defined
in the monitor.c file. The entry for the "info alarmclock" follows:
in the monitor/misc.c file. The entry for the "info alarmclock" follows:

{
.name = "alarmclock",
Expand Down
2 changes: 1 addition & 1 deletion gdbstub.c
Expand Up @@ -3344,7 +3344,7 @@ int gdbserver_start(const char *device)
/* Initialize a monitor terminal for gdb */
mon_chr = qemu_chardev_new(NULL, TYPE_CHARDEV_GDB,
NULL, NULL, &error_abort);
monitor_init(mon_chr, 0);
monitor_init_hmp(mon_chr, false);
} else {
qemu_chr_fe_deinit(&s->chr, true);
mon_chr = s->mon_chr;
Expand Down
2 changes: 1 addition & 1 deletion hmp-commands.hx
Expand Up @@ -1934,7 +1934,7 @@ ETEXI
.params = "[subcommand]",
.help = "show various information about the system state",
.cmd = hmp_info_help,
.sub_table = info_cmds,
.sub_table = hmp_info_cmds,
.flags = "p",
},

Expand Down
17 changes: 7 additions & 10 deletions include/monitor/monitor.h
Expand Up @@ -6,19 +6,16 @@
#include "qemu/readline.h"

extern __thread Monitor *cur_mon;

/* flags for monitor_init */
/* 0x01 unused */
#define MONITOR_USE_READLINE 0x02
#define MONITOR_USE_CONTROL 0x04
#define MONITOR_USE_PRETTY 0x08
typedef struct MonitorHMP MonitorHMP;

#define QMP_REQ_QUEUE_LEN_MAX 8

bool monitor_cur_is_qmp(void);

void monitor_init_globals(void);
void monitor_init(Chardev *chr, int flags);
void monitor_init_globals_core(void);
void monitor_init_qmp(Chardev *chr, bool pretty);
void monitor_init_hmp(Chardev *chr, bool use_readline);
void monitor_cleanup(void);

int monitor_suspend(Monitor *mon);
Expand All @@ -34,8 +31,8 @@ void monitor_flush(Monitor *mon);
int monitor_set_cpu(int cpu_index);
int monitor_get_cpu_index(void);

void monitor_read_command(Monitor *mon, int show_prompt);
int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func,
void monitor_read_command(MonitorHMP *mon, int show_prompt);
int monitor_read_password(MonitorHMP *mon, ReadLineFunc *readline_func,
void *opaque);

AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id,
Expand All @@ -44,6 +41,6 @@ AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id,
int monitor_fdset_get_fd(int64_t fdset_id, int flags);
int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd);
void monitor_fdset_dup_fd_remove(int dup_fd);
int monitor_fdset_dup_fd_find(int dup_fd);
int64_t monitor_fdset_dup_fd_find(int dup_fd);

#endif /* MONITOR_H */

0 comments on commit cdfaa27

Please sign in to comment.