aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 1 | #ifndef MONITOR_H |
| 2 | #define MONITOR_H |
| 3 | |
Paolo Bonzini | 737e150 | 2012-12-17 18:19:44 +0100 | [diff] [blame] | 4 | #include "block/block.h" |
Markus Armbruster | 112ed24 | 2018-02-26 17:13:27 -0600 | [diff] [blame] | 5 | #include "qapi/qapi-types-misc.h" |
Stefan Hajnoczi | 0150cd8 | 2013-11-14 11:54:15 +0100 | [diff] [blame] | 6 | #include "qemu/readline.h" |
Philippe Mathieu-Daudé | 5851909 | 2021-05-16 22:50:34 +0200 | [diff] [blame] | 7 | #include "exec/hwaddr.h" |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 8 | |
Kevin Wolf | 5f9dba1 | 2019-06-13 17:33:54 +0200 | [diff] [blame] | 9 | typedef struct MonitorHMP MonitorHMP; |
Kevin Wolf | f209872 | 2020-02-24 15:30:04 +0100 | [diff] [blame] | 10 | typedef struct MonitorOptions MonitorOptions; |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 11 | |
Peter Xu | 9ab8447 | 2018-10-09 14:27:13 +0800 | [diff] [blame] | 12 | #define QMP_REQ_QUEUE_LEN_MAX 8 |
| 13 | |
Kevin Wolf | c3e9555 | 2020-01-29 11:22:36 +0100 | [diff] [blame] | 14 | extern QemuOptsList qemu_mon_opts; |
| 15 | |
Kevin Wolf | 947e474 | 2020-10-05 17:58:44 +0200 | [diff] [blame] | 16 | Monitor *monitor_cur(void); |
Kevin Wolf | e69ee45 | 2020-10-05 17:58:48 +0200 | [diff] [blame] | 17 | Monitor *monitor_set_cur(Coroutine *co, Monitor *mon); |
Markus Armbruster | 489653b | 2015-03-06 20:01:05 +0100 | [diff] [blame] | 18 | bool monitor_cur_is_qmp(void); |
Markus Armbruster | 6620d3c | 2010-02-11 17:05:43 +0100 | [diff] [blame] | 19 | |
Peter Xu | 6adf08d | 2018-03-09 16:59:50 +0800 | [diff] [blame] | 20 | void monitor_init_globals(void); |
Kevin Wolf | 1d95db7 | 2019-06-13 17:34:02 +0200 | [diff] [blame] | 21 | void monitor_init_globals_core(void); |
Kevin Wolf | f27a9bb | 2020-02-24 15:30:05 +0100 | [diff] [blame] | 22 | void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp); |
Kevin Wolf | 8e9119a | 2020-02-24 15:30:06 +0100 | [diff] [blame] | 23 | void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp); |
Kevin Wolf | a2f411c | 2020-02-24 15:30:07 +0100 | [diff] [blame] | 24 | int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp); |
Kevin Wolf | c3e9555 | 2020-01-29 11:22:36 +0100 | [diff] [blame] | 25 | int monitor_init_opts(QemuOpts *opts, Error **errp); |
Marc-André Lureau | 2ef4571 | 2016-08-01 15:23:42 +0400 | [diff] [blame] | 26 | void monitor_cleanup(void); |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 27 | |
aliguori | cde76ee | 2009-03-05 23:01:51 +0000 | [diff] [blame] | 28 | int monitor_suspend(Monitor *mon); |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 29 | void monitor_resume(Monitor *mon); |
| 30 | |
Paolo Bonzini | a9940fc | 2012-09-20 16:50:32 +0200 | [diff] [blame] | 31 | int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp); |
Markus Armbruster | 1677f4c | 2015-02-09 14:03:19 +0100 | [diff] [blame] | 32 | int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp); |
Mark McLoughlin | 7768e04 | 2009-07-22 09:11:41 +0100 | [diff] [blame] | 33 | |
Alex Bennée | bf0c50d | 2022-09-29 12:42:12 +0100 | [diff] [blame] | 34 | int monitor_puts(Monitor *mon, const char *str); |
Markus Armbruster | 679cb8e | 2019-04-17 21:06:36 +0200 | [diff] [blame] | 35 | int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) |
Marc-André Lureau | 9edc631 | 2022-02-20 20:39:25 +0400 | [diff] [blame] | 36 | G_GNUC_PRINTF(2, 0); |
| 37 | int monitor_printf(Monitor *mon, const char *fmt, ...) G_GNUC_PRINTF(2, 3); |
Markus Armbruster | dd00d7f | 2023-01-24 13:19:41 +0100 | [diff] [blame] | 38 | void monitor_printc(Monitor *mon, int ch); |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 39 | void monitor_flush(Monitor *mon); |
Kevin Wolf | dcba65f | 2020-10-05 17:58:42 +0200 | [diff] [blame] | 40 | int monitor_set_cpu(Monitor *mon, int cpu_index); |
Kevin Wolf | 87e6f4a | 2020-10-05 17:58:43 +0200 | [diff] [blame] | 41 | int monitor_get_cpu_index(Monitor *mon); |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 42 | |
Paolo Bonzini | 4cb96b9 | 2023-05-17 14:46:49 +0200 | [diff] [blame] | 43 | int monitor_puts_locked(Monitor *mon, const char *str); |
| 44 | void monitor_flush_locked(Monitor *mon); |
| 45 | |
Tobin Feldman-Fitzthum | c7f7e69 | 2020-10-27 13:03:03 -0400 | [diff] [blame] | 46 | void *gpa2hva(MemoryRegion **p_mr, hwaddr addr, uint64_t size, Error **errp); |
| 47 | |
Kevin Wolf | 5f9dba1 | 2019-06-13 17:33:54 +0200 | [diff] [blame] | 48 | void monitor_read_command(MonitorHMP *mon, int show_prompt); |
| 49 | int monitor_read_password(MonitorHMP *mon, ReadLineFunc *readline_func, |
Anthony Liguori | 7060b47 | 2011-09-02 12:34:50 -0500 | [diff] [blame] | 50 | void *opaque); |
Markus Armbruster | d6f4683 | 2010-02-17 10:52:26 +0100 | [diff] [blame] | 51 | |
Corey Bryant | e446f70 | 2012-10-18 15:19:32 -0400 | [diff] [blame] | 52 | AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id, |
Markus Armbruster | 9492718 | 2022-11-04 17:06:59 +0100 | [diff] [blame] | 53 | const char *opaque, Error **errp); |
Daniel P. Berrangé | 60efffa | 2020-08-27 13:27:00 +0100 | [diff] [blame] | 54 | int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags); |
Michael S. Tsirkin | b3dd1b8 | 2014-08-17 11:45:17 +0200 | [diff] [blame] | 55 | void monitor_fdset_dup_fd_remove(int dup_fd); |
Yury Kotov | 854f63d | 2019-05-23 12:44:33 +0300 | [diff] [blame] | 56 | int64_t monitor_fdset_dup_fd_find(int dup_fd); |
Corey Bryant | adb696f | 2012-08-14 16:43:47 -0400 | [diff] [blame] | 57 | |
Gerd Hoffmann | f0e48cb | 2021-06-24 12:38:32 +0200 | [diff] [blame] | 58 | void monitor_register_hmp(const char *name, bool info, |
| 59 | void (*cmd)(Monitor *mon, const QDict *qdict)); |
Daniel P. Berrangé | f9429c6 | 2021-10-08 15:09:00 +0100 | [diff] [blame] | 60 | void monitor_register_hmp_info_hrt(const char *name, |
| 61 | HumanReadableText *(*handler)(Error **errp)); |
Gerd Hoffmann | f0e48cb | 2021-06-24 12:38:32 +0200 | [diff] [blame] | 62 | |
Marc-André Lureau | 756a98d | 2022-04-20 17:26:13 +0400 | [diff] [blame] | 63 | int error_vprintf_unless_qmp(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0); |
| 64 | int error_printf_unless_qmp(const char *fmt, ...) G_GNUC_PRINTF(1, 2); |
| 65 | |
Markus Armbruster | 175de52 | 2016-06-29 15:29:06 +0200 | [diff] [blame] | 66 | #endif /* MONITOR_H */ |