Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KOWOz-0002Hz-DV for qemu-devel@nongnu.org; Thu, 31 Jul 2008 07:33:01 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KOWOy-0002Hn-AO for qemu-devel@nongnu.org; Thu, 31 Jul 2008 07:33:00 -0400 Received: from [199.232.76.173] (port=50504 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KOWOy-0002Hk-25 for qemu-devel@nongnu.org; Thu, 31 Jul 2008 07:33:00 -0400 Received: from ecfrec.frec.bull.fr ([129.183.4.8]:35452) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KOWOx-0005vC-Iz for qemu-devel@nongnu.org; Thu, 31 Jul 2008 07:32:59 -0400 From: Laurent Vivier Content-Type: multipart/mixed; boundary="=-WSJTxUEptnqLAKWHgOEr" Date: Thu, 31 Jul 2008 13:32:17 +0200 Message-Id: <1217503937.3879.25.camel@frecb07144> Mime-Version: 1.0 Subject: [Qemu-devel] [PATCH] qemu: set focus to monitor to ask password if line is multiplexed Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "qemu-devel@nongnu.org" --=-WSJTxUEptnqLAKWHgOEr Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable This patch allows to display the "Password:" prompt if we use encrypted disk with "-nographic" option. It also modifies management of "-nographic" to not override user's choices for "-serial", "-parallel" and "-monitor". When qemu has to ask a password with "-nographic" with a multiplexed serial interface, it forces the focus to the monitor and restore original focus after. Regards, Laurent --=20 ----------------- Laurent.Vivier@bull.net ------------------ "La perfection est atteinte non quand il ne reste rien =C3=A0 ajouter mais quand il ne reste rien =C3=A0 enlever." Saint Exup=C3=A9ry --=-WSJTxUEptnqLAKWHgOEr Content-Disposition: attachment; filename=nographic.patch Content-Type: text/x-vhdl; name=nographic.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit --- monitor.c | 17 +++++++++++++++-- vl.c | 12 +++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) Index: qemu/vl.c =================================================================== --- qemu.orig/vl.c 2008-07-31 12:52:26.000000000 +0200 +++ qemu/vl.c 2008-07-31 12:53:04.000000000 +0200 @@ -8381,9 +8381,6 @@ int main(int argc, char **argv) } break; case QEMU_OPTION_nographic: - serial_devices[0] = "stdio"; - parallel_devices[0] = "null"; - monitor_device = "stdio"; nographic = 1; break; #ifdef CONFIG_CURSES @@ -8781,6 +8778,15 @@ int main(int argc, char **argv) } } + if (nographic) { + if (serial_device_index == 0) + serial_devices[0] = "stdio"; + if (parallel_device_index == 0) + parallel_devices[0] = "null"; + if (strncmp(monitor_device, "vc", 2) == 0) + monitor_device = "stdio"; + } + #ifndef _WIN32 if (daemonize) { pid_t pid; Index: qemu/monitor.c =================================================================== --- qemu.orig/monitor.c 2008-07-31 12:52:26.000000000 +0200 +++ qemu/monitor.c 2008-07-31 12:57:44.000000000 +0200 @@ -2722,12 +2722,19 @@ void monitor_readline(const char *prompt char *buf, int buf_size) { int i; + int old_focus[MAX_MON]; if (is_password) { - for (i = 0; i < MAX_MON; i++) - if (monitor_hd[i] && monitor_hd[i]->focus == 0) + for (i = 0; i < MAX_MON; i++) { + old_focus[i] = 0; + if (monitor_hd[i]) { + old_focus[i] = monitor_hd[i]->focus; + monitor_hd[i]->focus = 0; qemu_chr_send_event(monitor_hd[i], CHR_EVENT_FOCUS); + } + } } + readline_start(prompt, is_password, monitor_readline_cb, NULL); monitor_readline_buf = buf; monitor_readline_buf_size = buf_size; @@ -2735,4 +2742,10 @@ void monitor_readline(const char *prompt while (monitor_readline_started) { main_loop_wait(10); } + /* restore original focus */ + if (is_password) { + for (i = 0; i < MAX_MON; i++) + if (old_focus[i]) + monitor_hd[i]->focus = old_focus[i]; + } } --=-WSJTxUEptnqLAKWHgOEr--