aboutsummaryrefslogtreecommitdiffstats
path: root/monitor.c
diff options
context:
space:
mode:
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/monitor.c b/monitor.c
index 3a4c20a..b4f9c66 100644
--- a/monitor.c
+++ b/monitor.c
@@ -20,6 +20,21 @@ static int monitor_parse(struct qemu_window *win, char *buf, int len)
char *reply, *prompt, *cmd;
int off;
+ if (win->vnc_send_password && win->mrun &&
+ !strcmp(win->mrun->cmd, "change vnc password") &&
+ strstr(buf, "Password: "))
+ {
+ char buf[64];
+ int len;
+
+ if (debug)
+ fprintf(stderr, "%s: password prompt\n", __FUNCTION__);
+ len = snprintf(buf, sizeof(buf), "%s\n", win->vnc_password);
+ write(win->monitor.handle, buf, len);
+ win->vnc_send_password = 0;
+ return 0;
+ }
+
prompt = strstr(buf, "(qemu) ");
if (NULL == prompt) {
return 0;
@@ -54,8 +69,22 @@ static int monitor_parse(struct qemu_window *win, char *buf, int len)
} else if (0 == strcmp(cmd, "info vnc")) {
if (1 == sscanf(reply, "VNC server active on: %127[^\r\n]",
win->vnc_display) &&
- strstr(reply, "No client connected"))
- vnc_connect(win);
+ strstr(reply, "No client connected")) {
+ if (strstr(win->vnc_display, ",password")) {
+ win->vnc_password = malloc(32);
+#if 1
+ /* FIXME: do something less predictable */
+ srand(time(NULL)+getpid());
+ snprintf(win->vnc_password, 32, "%x", rand() & 0xfffffff);
+#endif
+ win->vnc_send_password = 1;
+ monitor_append(win, "change vnc password");
+ } else {
+ vnc_connect(win);
+ }
+ }
+ } else if (0 == strcmp(cmd, "change vnc password")) {
+ vnc_connect(win);
}
out: