From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KOAaD-0001zf-9M for qemu-devel@nongnu.org; Wed, 30 Jul 2008 08:15:09 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KOAaB-0001zL-LK for qemu-devel@nongnu.org; Wed, 30 Jul 2008 08:15:08 -0400 Received: from [199.232.76.173] (port=56455 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KOAaB-0001zI-Hg for qemu-devel@nongnu.org; Wed, 30 Jul 2008 08:15:07 -0400 Received: from ecfrec.frec.bull.fr ([129.183.4.8]:57458) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KOAaA-0000fl-Tf for qemu-devel@nongnu.org; Wed, 30 Jul 2008 08:15:07 -0400 Received: from localhost (localhost [127.0.0.1]) by ecfrec.frec.bull.fr (Postfix) with ESMTP id 6BB511A192E for ; Wed, 30 Jul 2008 14:15:43 +0200 (CEST) Received: from ecfrec.frec.bull.fr ([127.0.0.1]) by localhost (ecfrec.frec.bull.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 12427-10 for ; Wed, 30 Jul 2008 14:15:39 +0200 (CEST) Received: from cyclope.frec.bull.fr (cyclope.frec.bull.fr [129.183.4.9]) by ecfrec.frec.bull.fr (Postfix) with ESMTP id 4E5161A18FE for ; Wed, 30 Jul 2008 14:15:39 +0200 (CEST) Received: from [129.183.101.63] (frecb007144.frec.bull.fr [129.183.101.63]) by cyclope.frec.bull.fr (Postfix) with ESMTP id 251A02728D for ; Wed, 30 Jul 2008 14:15:36 +0200 (CEST) From: Laurent Vivier Content-Type: multipart/mixed; boundary="=-Ouf3Jh826mgNIZ06NHkf" Date: Wed, 30 Jul 2008 14:15:02 +0200 Message-Id: <1217420102.3883.23.camel@frecb07144> Mime-Version: 1.0 Subject: [Qemu-devel] [PATCH] qemu: ask password when encrypted disk image is used 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" --=-Ouf3Jh826mgNIZ06NHkf Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable This patch repairs the management of encrypted disk images and allows to enter the password. 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 --=-Ouf3Jh826mgNIZ06NHkf Content-Disposition: attachment; filename=qemu-encrypted.patch Content-Type: text/x-patch; name=qemu-encrypted.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit Signed-off-by: Laurent Vivier --- console.h | 1 + monitor.c | 8 +------- vl.c | 19 +++++++------------ 3 files changed, 9 insertions(+), 19 deletions(-) Index: qemu/console.h =================================================================== --- qemu.orig/console.h 2008-07-30 14:06:23.000000000 +0200 +++ qemu/console.h 2008-07-30 14:08:34.000000000 +0200 @@ -160,6 +160,7 @@ extern uint8_t _translate_keycode(const does not need to include console.h */ /* monitor.c */ void monitor_init(CharDriverState *hd, int show_banner); +void monitor_start_input(void); void term_puts(const char *str); void term_vprintf(const char *fmt, va_list ap); void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2))); Index: qemu/monitor.c =================================================================== --- qemu.orig/monitor.c 2008-07-30 14:06:23.000000000 +0200 +++ qemu/monitor.c 2008-07-30 14:08:34.000000000 +0200 @@ -76,8 +76,6 @@ static term_cmd_t info_cmds[]; static uint8_t term_outbuf[1024]; static int term_outbuf_index; -static void monitor_start_input(void); - CPUState *mon_cpu = NULL; void term_flush(void) @@ -2659,15 +2657,13 @@ static void term_read(void *opaque, cons readline_handle_byte(buf[i]); } -static void monitor_start_input(void); - static void monitor_handle_command1(void *opaque, const char *cmdline) { monitor_handle_command(cmdline); monitor_start_input(); } -static void monitor_start_input(void) +void monitor_start_input(void) { readline_start("(qemu) ", 0, monitor_handle_command1, NULL); } @@ -2708,8 +2704,6 @@ void monitor_init(CharDriverState *hd, i hide_banner = !show_banner; qemu_chr_add_handlers(hd, term_can_read, term_read, term_event, NULL); - - readline_start("", 0, monitor_handle_command1, NULL); } /* XXX: use threads ? */ Index: qemu/vl.c =================================================================== --- qemu.orig/vl.c 2008-07-30 14:06:23.000000000 +0200 +++ qemu/vl.c 2008-07-30 14:14:23.000000000 +0200 @@ -5687,7 +5687,7 @@ static int drive_init(struct drive_opt * bdrv_flags |= BDRV_O_SNAPSHOT; if (!cache) bdrv_flags |= BDRV_O_DIRECT; - if (bdrv_open2(bdrv, file, bdrv_flags, drv) < 0 || qemu_key_check(bdrv, file)) { + if (bdrv_open2(bdrv, file, bdrv_flags, drv) < 0) { fprintf(stderr, "qemu: could not open disk image %s\n", file); return -1; @@ -7975,22 +7975,14 @@ int qemu_key_check(BlockDriverState *bs, return -EPERM; } -static BlockDriverState *get_bdrv(int index) -{ - if (index > nb_drives) - return NULL; - return drives_table[index].bdrv; -} - static void read_passwords(void) { BlockDriverState *bs; int i; - for(i = 0; i < 6; i++) { - bs = get_bdrv(i); - if (bs) - qemu_key_check(bs, bdrv_get_device_name(bs)); + for(i = 0; i < nb_drives; i++) { + bs = drives_table[i].bdrv; + qemu_key_check(bs, bdrv_get_device_name(bs)); } } @@ -9114,6 +9106,9 @@ int main(int argc, char **argv) } } + if (monitor_device) + monitor_start_input(); + if (daemonize) { uint8_t status = 0; ssize_t len; --=-Ouf3Jh826mgNIZ06NHkf--