aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 1 | #ifndef MONITOR_H |
| 2 | #define MONITOR_H |
| 3 | |
| 4 | #include "qemu-common.h" |
| 5 | #include "qemu-char.h" |
Markus Armbruster | d6f4683 | 2010-02-17 10:52:26 +0100 | [diff] [blame] | 6 | #include "qerror.h" |
Luiz Capitulino | cdb0def | 2009-08-28 15:27:11 -0300 | [diff] [blame] | 7 | #include "qdict.h" |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 8 | #include "block.h" |
Anthony Liguori | 7060b47 | 2011-09-02 12:34:50 -0500 | [diff] [blame] | 9 | #include "readline.h" |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 10 | |
| 11 | extern Monitor *cur_mon; |
Markus Armbruster | 8631b60 | 2010-02-18 11:41:55 +0100 | [diff] [blame] | 12 | extern Monitor *default_mon; |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 13 | |
aliguori | 731b036 | 2009-03-05 23:01:42 +0000 | [diff] [blame] | 14 | /* flags for monitor_init */ |
| 15 | #define MONITOR_IS_DEFAULT 0x01 |
aliguori | cde76ee | 2009-03-05 23:01:51 +0000 | [diff] [blame] | 16 | #define MONITOR_USE_READLINE 0x02 |
Luiz Capitulino | 418173c | 2009-11-26 22:58:51 -0200 | [diff] [blame] | 17 | #define MONITOR_USE_CONTROL 0x04 |
Daniel P. Berrange | 39eaab9 | 2010-06-07 15:42:31 +0100 | [diff] [blame] | 18 | #define MONITOR_USE_PRETTY 0x08 |
aliguori | 731b036 | 2009-03-05 23:01:42 +0000 | [diff] [blame] | 19 | |
Jan Kiszka | 8ac470c | 2010-06-16 00:38:39 +0200 | [diff] [blame] | 20 | /* flags for monitor commands */ |
| 21 | #define MONITOR_CMD_ASYNC 0x0001 |
| 22 | |
Luiz Capitulino | 0d1ea87 | 2009-11-26 22:59:03 -0200 | [diff] [blame] | 23 | /* QMP events */ |
| 24 | typedef enum MonitorEvent { |
Blue Swirl | 242cd00 | 2009-12-04 18:05:45 +0000 | [diff] [blame] | 25 | QEVENT_SHUTDOWN, |
| 26 | QEVENT_RESET, |
| 27 | QEVENT_POWERDOWN, |
| 28 | QEVENT_STOP, |
Luiz Capitulino | 6ed2c48 | 2010-04-27 20:35:59 -0300 | [diff] [blame] | 29 | QEVENT_RESUME, |
Luiz Capitulino | 586153d | 2010-01-14 14:50:57 -0200 | [diff] [blame] | 30 | QEVENT_VNC_CONNECTED, |
Luiz Capitulino | 0d2ed46 | 2010-01-14 14:50:59 -0200 | [diff] [blame] | 31 | QEVENT_VNC_INITIALIZED, |
Luiz Capitulino | 0d72f3d | 2010-01-14 14:50:58 -0200 | [diff] [blame] | 32 | QEVENT_VNC_DISCONNECTED, |
Luiz Capitulino | aa1db6e | 2010-02-03 12:41:00 -0200 | [diff] [blame] | 33 | QEVENT_BLOCK_IO_ERROR, |
Luiz Capitulino | 80cd347 | 2010-02-25 12:11:44 -0300 | [diff] [blame] | 34 | QEVENT_RTC_CHANGE, |
Luiz Capitulino | 9eedeb3 | 2010-02-25 12:13:04 -0300 | [diff] [blame] | 35 | QEVENT_WATCHDOG, |
Gerd Hoffmann | 6f8c63f | 2010-10-11 18:03:51 +0200 | [diff] [blame] | 36 | QEVENT_SPICE_CONNECTED, |
| 37 | QEVENT_SPICE_INITIALIZED, |
| 38 | QEVENT_SPICE_DISCONNECTED, |
Stefan Hajnoczi | 12bd451 | 2012-01-18 14:40:46 +0000 | [diff] [blame] | 39 | QEVENT_BLOCK_JOB_COMPLETED, |
Stefan Hajnoczi | 370521a | 2012-01-18 14:40:48 +0000 | [diff] [blame] | 40 | QEVENT_BLOCK_JOB_CANCELLED, |
Paolo Bonzini | 32c81a4 | 2012-09-28 17:22:58 +0200 | [diff] [blame] | 41 | QEVENT_BLOCK_JOB_ERROR, |
Paolo Bonzini | a66a2a3 | 2012-07-23 15:15:47 +0200 | [diff] [blame] | 42 | QEVENT_BLOCK_JOB_READY, |
Luiz Capitulino | 6f382ed | 2012-02-14 13:41:13 -0200 | [diff] [blame] | 43 | QEVENT_DEVICE_TRAY_MOVED, |
Gerd Hoffmann | 53370b7 | 2012-02-23 13:45:26 +0100 | [diff] [blame] | 44 | QEVENT_SUSPEND, |
Luiz Capitulino | 25df49f | 2012-08-08 17:03:01 -0300 | [diff] [blame] | 45 | QEVENT_SUSPEND_DISK, |
Gerd Hoffmann | 53370b7 | 2012-02-23 13:45:26 +0100 | [diff] [blame] | 46 | QEVENT_WAKEUP, |
Daniel P. Berrange | 973603a | 2012-06-14 18:12:56 +0100 | [diff] [blame] | 47 | QEVENT_BALLOON_CHANGE, |
Yonit Halperin | 2fdd16e | 2012-08-21 11:51:57 +0300 | [diff] [blame] | 48 | QEVENT_SPICE_MIGRATE_COMPLETED, |
Daniel P. Berrange | 4860853 | 2012-05-21 17:59:51 +0100 | [diff] [blame] | 49 | |
| 50 | /* Add to 'monitor_event_names' array in monitor.c when |
| 51 | * defining new events here */ |
| 52 | |
Blue Swirl | 242cd00 | 2009-12-04 18:05:45 +0000 | [diff] [blame] | 53 | QEVENT_MAX, |
Luiz Capitulino | 0d1ea87 | 2009-11-26 22:59:03 -0200 | [diff] [blame] | 54 | } MonitorEvent; |
| 55 | |
Markus Armbruster | 6620d3c | 2010-02-11 17:05:43 +0100 | [diff] [blame] | 56 | int monitor_cur_is_qmp(void); |
| 57 | |
Luiz Capitulino | 0d1ea87 | 2009-11-26 22:59:03 -0200 | [diff] [blame] | 58 | void monitor_protocol_event(MonitorEvent event, QObject *data); |
aliguori | 731b036 | 2009-03-05 23:01:42 +0000 | [diff] [blame] | 59 | void monitor_init(CharDriverState *chr, int flags); |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 60 | |
aliguori | cde76ee | 2009-03-05 23:01:51 +0000 | [diff] [blame] | 61 | int monitor_suspend(Monitor *mon); |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 62 | void monitor_resume(Monitor *mon); |
| 63 | |
Luiz Capitulino | 0bbc47b | 2010-02-10 23:50:01 -0200 | [diff] [blame] | 64 | int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs, |
| 65 | BlockDriverCompletionFunc *completion_cb, |
| 66 | void *opaque); |
Luiz Capitulino | e42e818 | 2011-11-22 17:58:31 -0200 | [diff] [blame] | 67 | int monitor_read_block_device_key(Monitor *mon, const char *device, |
| 68 | BlockDriverCompletionFunc *completion_cb, |
| 69 | void *opaque); |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 70 | |
Paolo Bonzini | a9940fc | 2012-09-20 16:50:32 +0200 | [diff] [blame] | 71 | int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp); |
Nicholas Bellinger | a96ed02 | 2012-08-21 20:52:07 +0000 | [diff] [blame] | 72 | int monitor_handle_fd_param(Monitor *mon, const char *fdname); |
Mark McLoughlin | 7768e04 | 2009-07-22 09:11:41 +0100 | [diff] [blame] | 73 | |
Stefan Weil | 8b7968f | 2010-09-23 21:28:05 +0200 | [diff] [blame] | 74 | void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) |
| 75 | GCC_FMT_ATTR(2, 0); |
Stefan Weil | e5924d8 | 2010-09-23 21:28:03 +0200 | [diff] [blame] | 76 | void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 77 | void monitor_print_filename(Monitor *mon, const char *filename); |
| 78 | void monitor_flush(Monitor *mon); |
Luiz Capitulino | b025c8b | 2011-10-06 14:02:57 -0300 | [diff] [blame] | 79 | int monitor_set_cpu(int cpu_index); |
Luiz Capitulino | 99b7796 | 2011-10-24 10:53:44 -0200 | [diff] [blame] | 80 | int monitor_get_cpu_index(void); |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 81 | |
Adam Litke | 940cc30 | 2010-01-25 12:18:44 -0600 | [diff] [blame] | 82 | typedef void (MonitorCompletion)(void *opaque, QObject *ret_data); |
| 83 | |
Markus Armbruster | d6f4683 | 2010-02-17 10:52:26 +0100 | [diff] [blame] | 84 | void monitor_set_error(Monitor *mon, QError *qerror); |
Anthony Liguori | 7060b47 | 2011-09-02 12:34:50 -0500 | [diff] [blame] | 85 | void monitor_read_command(Monitor *mon, int show_prompt); |
| 86 | ReadLineState *monitor_get_rs(Monitor *mon); |
| 87 | int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, |
| 88 | void *opaque); |
Markus Armbruster | d6f4683 | 2010-02-17 10:52:26 +0100 | [diff] [blame] | 89 | |
Anthony Liguori | eb6e8ea | 2011-12-12 14:29:35 -0600 | [diff] [blame] | 90 | int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret); |
| 91 | |
| 92 | int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret); |
| 93 | |
Corey Bryant | e446f70 | 2012-10-18 15:19:32 -0400 | [diff] [blame] | 94 | AddfdInfo *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 Bryant | adb696f | 2012-08-14 16:43:47 -0400 | [diff] [blame] | 97 | int monitor_fdset_get_fd(int64_t fdset_id, int flags); |
| 98 | int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd); |
| 99 | int monitor_fdset_dup_fd_remove(int dup_fd); |
| 100 | int monitor_fdset_dup_fd_find(int dup_fd); |
| 101 | |
aliguori | 376253e | 2009-03-05 23:01:23 +0000 | [diff] [blame] | 102 | #endif /* !MONITOR_H */ |