1#ifndef MONITOR_H
2#define MONITOR_H
3
4#include "qemu-common.h"
5#include "qemu-char.h"
6#include "qerror.h"
7#include "qdict.h"
8#include "block.h"
9
10extern Monitor *cur_mon;
11extern Monitor *default_mon;
12
13/* flags for monitor_init */
14#define MONITOR_IS_DEFAULT    0x01
15#define MONITOR_USE_READLINE  0x02
16#define MONITOR_USE_CONTROL   0x04
17#define MONITOR_USE_PRETTY    0x08
18#define MONITOR_QUIT_DOESNT_EXIT  0x80  /* prevent 'quit' from exiting the emulator */
19
20/* flags for monitor commands */
21#define MONITOR_CMD_ASYNC       0x0001
22#define MONITOR_CMD_USER_ONLY   0x0002
23
24/* QMP events */
25typedef enum MonitorEvent {
26    QEVENT_SHUTDOWN,
27    QEVENT_RESET,
28    QEVENT_POWERDOWN,
29    QEVENT_STOP,
30    QEVENT_RESUME,
31    QEVENT_VNC_CONNECTED,
32    QEVENT_VNC_INITIALIZED,
33    QEVENT_VNC_DISCONNECTED,
34    QEVENT_BLOCK_IO_ERROR,
35    QEVENT_RTC_CHANGE,
36    QEVENT_WATCHDOG,
37    QEVENT_SPICE_CONNECTED,
38    QEVENT_SPICE_INITIALIZED,
39    QEVENT_SPICE_DISCONNECTED,
40    QEVENT_MAX,
41} MonitorEvent;
42
43int monitor_cur_is_qmp(void);
44
45void monitor_protocol_event(MonitorEvent event, QObject *data);
46void monitor_init(CharDriverState *chr, int flags);
47
48int monitor_suspend(Monitor *mon);
49void monitor_resume(Monitor *mon);
50
51int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
52                                BlockDriverCompletionFunc *completion_cb,
53                                void *opaque);
54
55int monitor_get_fd(Monitor *mon, const char *fdname);
56
57void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
58    GCC_FMT_ATTR(2, 0);
59void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
60void monitor_print_filename(Monitor *mon, const char *filename);
61void monitor_flush(Monitor *mon);
62
63typedef void (MonitorCompletion)(void *opaque, QObject *ret_data);
64
65void monitor_set_error(Monitor *mon, QError *qerror);
66
67#ifdef CONFIG_ANDROID
68typedef int (*MonitorFakeFunc)(void* opaque, const char* str, int strsize);
69
70/* Create a new fake Monitor object to send all output to an internal
71 * buffer. This is used to send snapshot save/load errors (produced in
72 * savevm.c) to the Android console when 'avd snapshot save' or
73 * 'avd snapshot load' are used.
74 */
75Monitor* monitor_fake_new(void* opaque, MonitorFakeFunc cb);
76int      monitor_fake_get_bytes(Monitor* mon);
77void     monitor_fake_free(Monitor* mon);
78#endif
79
80#endif /* !MONITOR_H */
81