aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-06-16 18:58:02 +0100
committerPeter Maydell <peter.maydell@linaro.org>2014-06-23 16:20:42 +0100
commit4e9cc7dda298b9292b722d7a42900825e1307b8a (patch)
tree8b5080b7964e7b304409cffe61e29ac9784a1b1b
parenta237a3365efb3c319d37040e42b8a43a854be7f9 (diff)
downloadqemu-arm-4e9cc7dda298b9292b722d7a42900825e1307b8a.tar.gz
android-console: Implement quit
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--android-commands.h7
-rw-r--r--android-console.c8
-rw-r--r--android-console.h1
-rw-r--r--include/monitor/monitor.h2
-rw-r--r--monitor.c14
5 files changed, 32 insertions, 0 deletions
diff --git a/android-commands.h b/android-commands.h
index 45b6c1d447..34a4fb34e3 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 42ada96730..50f8b2cebd 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 26c82505c5..2ad08793c5 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 43ca2fded3..dce5432723 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -67,6 +67,8 @@ void monitor_init(CharDriverState *chr, int flags);
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,
BlockDriverCompletionFunc *completion_cb,
void *opaque);
diff --git a/monitor.c b/monitor.c
index c9f4a245c7..3b9dbfbe6a 100644
--- a/monitor.c
+++ b/monitor.c
@@ -5048,6 +5048,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;