diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2014-06-16 18:58:02 +0100 |
---|---|---|
committer | Alex Bennée <alex.bennee@linaro.org> | 2014-12-19 12:29:35 +0000 |
commit | b22a947b8684f4bc19a451c80e4234c9b4e3cf39 (patch) | |
tree | 4b05e1f2cc31c4fec25e89d8005d94ea293da433 | |
parent | cfbcc8634c897a039fc1b6c949e24a25af6b60c5 (diff) |
android-console: Implement quit
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r-- | android-commands.h | 7 | ||||
-rw-r--r-- | android-console.c | 8 | ||||
-rw-r--r-- | android-console.h | 1 | ||||
-rw-r--r-- | include/monitor/monitor.h | 2 | ||||
-rw-r--r-- | monitor.c | 14 |
5 files changed, 32 insertions, 0 deletions
diff --git a/android-commands.h b/android-commands.h index 45b6c1d44..34a4fb34e 100644 --- a/android-commands.h +++ b/android-commands.h @@ -41,6 +41,13 @@ static mon_cmd_t android_cmds[] = { .mhandler.cmd = android_console_kill, }, { + .name = "quit|exit", + .args_type = "", + .params = "", + .help = "quit control session", + .mhandler.cmd = android_console_quit, + }, + { .name = "redir", .args_type = "item:s?", .params = "", diff --git a/android-console.c b/android-console.c index 42ada9673..50f8b2ceb 100644 --- a/android-console.c +++ b/android-console.c @@ -37,6 +37,14 @@ void android_console_kill(Monitor *mon, const QDict *qdict) qmp_quit(NULL); } +void android_console_quit(Monitor *mon, const QDict *qdict) +{ + /* Don't print an OK response for success, just close the connection */ + if (monitor_disconnect(mon)) { + monitor_printf(mon, "KO: this connection doesn't support quitting\n"); + } +} + #ifdef CONFIG_SLIRP void android_console_redir_list(Monitor *mon, const QDict *qdict) { diff --git a/android-console.h b/android-console.h index 26c82505c..2ad08793c 100644 --- a/android-console.h +++ b/android-console.h @@ -22,6 +22,7 @@ #include "qemu-common.h" void android_console_kill(Monitor *mon, const QDict *qdict); +void android_console_quit(Monitor *mon, const QDict *qdict); void android_console_redir(Monitor *mon, const QDict *qdict); void android_console_redir_list(Monitor *mon, const QDict *qdict); void android_console_redir_add(Monitor *mon, const QDict *qdict); diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index 890d4503f..6be1ba3a7 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -61,6 +61,8 @@ void monitor_add_command(Monitor *mon, mon_cmd_t *cmd); int monitor_suspend(Monitor *mon); void monitor_resume(Monitor *mon); +int monitor_disconnect(Monitor *mon); + int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs, BlockCompletionFunc *completion_cb, void *opaque); @@ -5212,6 +5212,20 @@ void monitor_resume(Monitor *mon) readline_show_prompt(mon->rs); } +/** + * monitor_disconnect() : Disconnect the monitor connection + * + * Close this monitor connection, if we can, with the same behaviour + * as if the other end itself had closed it (eg, we will go back + * to listening on the TCP socket). + * File descriptor cleanup happens when the char backend sends us + * the CHR_EVENT_CLOSED event. + */ +int monitor_disconnect(Monitor *mon) +{ + return qemu_chr_del_client(mon->chr); +} + static QObject *get_qmp_greeting(void) { QObject *ver = NULL; |