xref: /openbmc/qemu/include/monitor/monitor.h (revision 7d87775f)
1 #ifndef MONITOR_H
2 #define MONITOR_H
3 
4 #include "block/block.h"
5 #include "qapi/qapi-types-misc.h"
6 #include "qemu/readline.h"
7 #include "exec/hwaddr.h"
8 
9 typedef struct MonitorHMP MonitorHMP;
10 typedef struct MonitorOptions MonitorOptions;
11 
12 #define QMP_REQ_QUEUE_LEN_MAX 8
13 
14 extern QemuOptsList qemu_mon_opts;
15 
16 Monitor *monitor_cur(void);
17 Monitor *monitor_set_cur(Coroutine *co, Monitor *mon);
18 bool monitor_cur_is_qmp(void);
19 
20 void monitor_init_globals(void);
21 void monitor_init_globals_core(void);
22 void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp);
23 void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp);
24 int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp);
25 int monitor_init_opts(QemuOpts *opts, Error **errp);
26 void monitor_cleanup(void);
27 
28 int monitor_suspend(Monitor *mon);
29 void monitor_resume(Monitor *mon);
30 
31 int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp);
32 int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp);
33 
34 int monitor_puts(Monitor *mon, const char *str);
35 int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
36     G_GNUC_PRINTF(2, 0);
37 int monitor_printf(Monitor *mon, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
38 void monitor_printc(Monitor *mon, int ch);
39 void monitor_flush(Monitor *mon);
40 int monitor_set_cpu(Monitor *mon, int cpu_index);
41 int monitor_get_cpu_index(Monitor *mon);
42 
43 int monitor_puts_locked(Monitor *mon, const char *str);
44 void monitor_flush_locked(Monitor *mon);
45 
46 void *gpa2hva(MemoryRegion **p_mr, hwaddr addr, uint64_t size, Error **errp);
47 
48 void monitor_read_command(MonitorHMP *mon, int show_prompt);
49 int monitor_read_password(MonitorHMP *mon, ReadLineFunc *readline_func,
50                           void *opaque);
51 
52 AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id,
53                                 const char *opaque, Error **errp);
54 int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags, Error **errp);
55 void monitor_fdset_dup_fd_remove(int dup_fd);
56 
57 void monitor_register_hmp(const char *name, bool info,
58                           void (*cmd)(Monitor *mon, const QDict *qdict));
59 void monitor_register_hmp_info_hrt(const char *name,
60                                    HumanReadableText *(*handler)(Error **errp));
61 
62 int error_vprintf_unless_qmp(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0);
63 int error_printf_unless_qmp(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
64 
65 #endif /* MONITOR_H */
66