blob: b4ef9559dc16248a80c312ee03c6fd21cb2375a4 [file] [log] [blame]
aliguori376253e2009-03-05 23:01:23 +00001#ifndef MONITOR_H
2#define MONITOR_H
3
4#include "qemu-common.h"
5#include "qemu-char.h"
Markus Armbrusterd6f46832010-02-17 10:52:26 +01006#include "qerror.h"
Luiz Capitulinocdb0def2009-08-28 15:27:11 -03007#include "qdict.h"
aliguori376253e2009-03-05 23:01:23 +00008#include "block.h"
Anthony Liguori7060b472011-09-02 12:34:50 -05009#include "readline.h"
aliguori376253e2009-03-05 23:01:23 +000010
11extern Monitor *cur_mon;
Markus Armbruster8631b602010-02-18 11:41:55 +010012extern Monitor *default_mon;
aliguori376253e2009-03-05 23:01:23 +000013
aliguori731b0362009-03-05 23:01:42 +000014/* flags for monitor_init */
15#define MONITOR_IS_DEFAULT 0x01
aliguoricde76ee2009-03-05 23:01:51 +000016#define MONITOR_USE_READLINE 0x02
Luiz Capitulino418173c2009-11-26 22:58:51 -020017#define MONITOR_USE_CONTROL 0x04
Daniel P. Berrange39eaab92010-06-07 15:42:31 +010018#define MONITOR_USE_PRETTY 0x08
aliguori731b0362009-03-05 23:01:42 +000019
Jan Kiszka8ac470c2010-06-16 00:38:39 +020020/* flags for monitor commands */
21#define MONITOR_CMD_ASYNC 0x0001
22
Luiz Capitulino0d1ea872009-11-26 22:59:03 -020023/* QMP events */
24typedef enum MonitorEvent {
Blue Swirl242cd002009-12-04 18:05:45 +000025 QEVENT_SHUTDOWN,
26 QEVENT_RESET,
27 QEVENT_POWERDOWN,
28 QEVENT_STOP,
Luiz Capitulino6ed2c482010-04-27 20:35:59 -030029 QEVENT_RESUME,
Luiz Capitulino586153d2010-01-14 14:50:57 -020030 QEVENT_VNC_CONNECTED,
Luiz Capitulino0d2ed462010-01-14 14:50:59 -020031 QEVENT_VNC_INITIALIZED,
Luiz Capitulino0d72f3d2010-01-14 14:50:58 -020032 QEVENT_VNC_DISCONNECTED,
Luiz Capitulinoaa1db6e2010-02-03 12:41:00 -020033 QEVENT_BLOCK_IO_ERROR,
Luiz Capitulino80cd3472010-02-25 12:11:44 -030034 QEVENT_RTC_CHANGE,
Luiz Capitulino9eedeb32010-02-25 12:13:04 -030035 QEVENT_WATCHDOG,
Gerd Hoffmann6f8c63f2010-10-11 18:03:51 +020036 QEVENT_SPICE_CONNECTED,
37 QEVENT_SPICE_INITIALIZED,
38 QEVENT_SPICE_DISCONNECTED,
Stefan Hajnoczi12bd4512012-01-18 14:40:46 +000039 QEVENT_BLOCK_JOB_COMPLETED,
Stefan Hajnoczi370521a2012-01-18 14:40:48 +000040 QEVENT_BLOCK_JOB_CANCELLED,
Paolo Bonzini32c81a42012-09-28 17:22:58 +020041 QEVENT_BLOCK_JOB_ERROR,
Paolo Bonzinia66a2a32012-07-23 15:15:47 +020042 QEVENT_BLOCK_JOB_READY,
Luiz Capitulino6f382ed2012-02-14 13:41:13 -020043 QEVENT_DEVICE_TRAY_MOVED,
Gerd Hoffmann53370b72012-02-23 13:45:26 +010044 QEVENT_SUSPEND,
Luiz Capitulino25df49f2012-08-08 17:03:01 -030045 QEVENT_SUSPEND_DISK,
Gerd Hoffmann53370b72012-02-23 13:45:26 +010046 QEVENT_WAKEUP,
Daniel P. Berrange973603a2012-06-14 18:12:56 +010047 QEVENT_BALLOON_CHANGE,
Yonit Halperin2fdd16e2012-08-21 11:51:57 +030048 QEVENT_SPICE_MIGRATE_COMPLETED,
Daniel P. Berrange48608532012-05-21 17:59:51 +010049
50 /* Add to 'monitor_event_names' array in monitor.c when
51 * defining new events here */
52
Blue Swirl242cd002009-12-04 18:05:45 +000053 QEVENT_MAX,
Luiz Capitulino0d1ea872009-11-26 22:59:03 -020054} MonitorEvent;
55
Markus Armbruster6620d3c2010-02-11 17:05:43 +010056int monitor_cur_is_qmp(void);
57
Luiz Capitulino0d1ea872009-11-26 22:59:03 -020058void monitor_protocol_event(MonitorEvent event, QObject *data);
aliguori731b0362009-03-05 23:01:42 +000059void monitor_init(CharDriverState *chr, int flags);
aliguori376253e2009-03-05 23:01:23 +000060
aliguoricde76ee2009-03-05 23:01:51 +000061int monitor_suspend(Monitor *mon);
aliguori376253e2009-03-05 23:01:23 +000062void monitor_resume(Monitor *mon);
63
Luiz Capitulino0bbc47b2010-02-10 23:50:01 -020064int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
65 BlockDriverCompletionFunc *completion_cb,
66 void *opaque);
Luiz Capitulinoe42e8182011-11-22 17:58:31 -020067int monitor_read_block_device_key(Monitor *mon, const char *device,
68 BlockDriverCompletionFunc *completion_cb,
69 void *opaque);
aliguori376253e2009-03-05 23:01:23 +000070
Paolo Bonzinia9940fc2012-09-20 16:50:32 +020071int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp);
Nicholas Bellingera96ed022012-08-21 20:52:07 +000072int monitor_handle_fd_param(Monitor *mon, const char *fdname);
Mark McLoughlin7768e042009-07-22 09:11:41 +010073
Stefan Weil8b7968f2010-09-23 21:28:05 +020074void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
75 GCC_FMT_ATTR(2, 0);
Stefan Weile5924d82010-09-23 21:28:03 +020076void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
aliguori376253e2009-03-05 23:01:23 +000077void monitor_print_filename(Monitor *mon, const char *filename);
78void monitor_flush(Monitor *mon);
Luiz Capitulinob025c8b2011-10-06 14:02:57 -030079int monitor_set_cpu(int cpu_index);
Luiz Capitulino99b77962011-10-24 10:53:44 -020080int monitor_get_cpu_index(void);
aliguori376253e2009-03-05 23:01:23 +000081
Adam Litke940cc302010-01-25 12:18:44 -060082typedef void (MonitorCompletion)(void *opaque, QObject *ret_data);
83
Markus Armbrusterd6f46832010-02-17 10:52:26 +010084void monitor_set_error(Monitor *mon, QError *qerror);
Anthony Liguori7060b472011-09-02 12:34:50 -050085void monitor_read_command(Monitor *mon, int show_prompt);
86ReadLineState *monitor_get_rs(Monitor *mon);
87int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func,
88 void *opaque);
Markus Armbrusterd6f46832010-02-17 10:52:26 +010089
Anthony Liguorieb6e8ea2011-12-12 14:29:35 -060090int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret);
91
92int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret);
93
Corey Bryante446f702012-10-18 15:19:32 -040094AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id,
95 bool has_opaque, const char *opaque,
96 Error **errp);
Corey Bryantadb696f2012-08-14 16:43:47 -040097int monitor_fdset_get_fd(int64_t fdset_id, int flags);
98int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd);
99int monitor_fdset_dup_fd_remove(int dup_fd);
100int monitor_fdset_dup_fd_find(int dup_fd);
101
aliguori376253e2009-03-05 23:01:23 +0000102#endif /* !MONITOR_H */