* [Qemu-devel] [PATCH] qemu: ask password when encrypted disk image is used
@ 2008-07-30 12:15 Laurent Vivier
2008-07-30 12:42 ` Laurent Vivier
0 siblings, 1 reply; 9+ messages in thread
From: Laurent Vivier @ 2008-07-30 12:15 UTC (permalink / raw)
To: qemu-devel@nongnu.org
[-- Attachment #1: Type: text/plain, Size: 300 bytes --]
This patch repairs the management of encrypted disk images and allows to
enter the password.
Laurent
--
----------------- Laurent.Vivier@bull.net ------------------
"La perfection est atteinte non quand il ne reste rien à
ajouter mais quand il ne reste rien à enlever." Saint Exupéry
[-- Attachment #2: qemu-encrypted.patch --]
[-- Type: text/x-patch, Size: 3291 bytes --]
Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
---
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;
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu: ask password when encrypted disk image is used
2008-07-30 12:15 [Qemu-devel] [PATCH] qemu: ask password when encrypted disk image is used Laurent Vivier
@ 2008-07-30 12:42 ` Laurent Vivier
2008-07-30 12:46 ` Laurent Vivier
0 siblings, 1 reply; 9+ messages in thread
From: Laurent Vivier @ 2008-07-30 12:42 UTC (permalink / raw)
To: qemu-devel
Le mercredi 30 juillet 2008 à 14:15 +0200, Laurent Vivier a écrit :
> This patch repairs the management of encrypted disk images and allows to
> enter the password.
Forgot it: this patch is stupid...
Laurent
--
----------------- Laurent.Vivier@bull.net ------------------
"La perfection est atteinte non quand il ne reste rien à
ajouter mais quand il ne reste rien à enlever." Saint Exupéry
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu: ask password when encrypted disk image is used
2008-07-30 12:42 ` Laurent Vivier
@ 2008-07-30 12:46 ` Laurent Vivier
2008-07-30 14:16 ` Anthony Liguori
0 siblings, 1 reply; 9+ messages in thread
From: Laurent Vivier @ 2008-07-30 12:46 UTC (permalink / raw)
To: qemu-devel
Le mercredi 30 juillet 2008 à 14:42 +0200, Laurent Vivier a écrit :
> Le mercredi 30 juillet 2008 à 14:15 +0200, Laurent Vivier a écrit :
> > This patch repairs the management of encrypted disk images and allows to
> > enter the password.
>
> Forgot it: this patch is stupid...
Sorry, this one is good, the other one is stupid...
Laurent
--
----------------- Laurent.Vivier@bull.net ------------------
"La perfection est atteinte non quand il ne reste rien à
ajouter mais quand il ne reste rien à enlever." Saint Exupéry
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu: ask password when encrypted disk image is used
2008-07-30 12:46 ` Laurent Vivier
@ 2008-07-30 14:16 ` Anthony Liguori
2008-07-30 14:29 ` Laurent Vivier
2008-07-30 15:35 ` Laurent Vivier
0 siblings, 2 replies; 9+ messages in thread
From: Anthony Liguori @ 2008-07-30 14:16 UTC (permalink / raw)
To: qemu-devel
Laurent Vivier wrote:
> Le mercredi 30 juillet 2008 à 14:42 +0200, Laurent Vivier a écrit :
>
>> Le mercredi 30 juillet 2008 à 14:15 +0200, Laurent Vivier a écrit :
>>
>>> This patch repairs the management of encrypted disk images and allows to
>>> enter the password.
>>>
>> Forgot it: this patch is stupid...
>>
>
> Sorry, this one is good, the other one is stupid...
>
Once you've straightened things out, can you resend one patch that isn't
stupid :-) Perhaps it's just too early for me, but I'm thoroughly
confused about what patch is the right one.
Regards,
Anthony Liguori
> Laurent
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu: ask password when encrypted disk image is used
2008-07-30 14:16 ` Anthony Liguori
@ 2008-07-30 14:29 ` Laurent Vivier
2008-07-30 14:52 ` nuitari-qemu
2008-07-30 15:35 ` Laurent Vivier
1 sibling, 1 reply; 9+ messages in thread
From: Laurent Vivier @ 2008-07-30 14:29 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 650 bytes --]
Le mercredi 30 juillet 2008 à 09:16 -0500, Anthony Liguori a écrit :
> Once you've straightened things out, can you resend one patch that isn't
> stupid :-) Perhaps it's just too early for me, but I'm thoroughly
> confused about what patch is the right one.
Yes, sorry for the mess.
The attached one is the one which should be not stupid... but I made
more tests and it doesn't work in some cases. So, you can forget it
too :-(
Laurent
--
----------------- Laurent.Vivier@bull.net ------------------
"La perfection est atteinte non quand il ne reste rien à
ajouter mais quand il ne reste rien à enlever." Saint Exupéry
[-- Attachment #2: qemu-encrypted.patch --]
[-- Type: text/x-patch, Size: 3291 bytes --]
Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
---
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;
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu: ask password when encrypted disk image is used
2008-07-30 14:29 ` Laurent Vivier
@ 2008-07-30 14:52 ` nuitari-qemu
2008-07-30 15:10 ` Laurent Vivier
0 siblings, 1 reply; 9+ messages in thread
From: nuitari-qemu @ 2008-07-30 14:52 UTC (permalink / raw)
To: qemu-devel
> The attached one is the one which should be not stupid... but I made
> more tests and it doesn't work in some cases. So, you can forget it
> too :-(
In which cases doesn't it work?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu: ask password when encrypted disk image is used
2008-07-30 14:52 ` nuitari-qemu
@ 2008-07-30 15:10 ` Laurent Vivier
0 siblings, 0 replies; 9+ messages in thread
From: Laurent Vivier @ 2008-07-30 15:10 UTC (permalink / raw)
To: qemu-devel; +Cc: nuitari-qemu
Le mercredi 30 juillet 2008 à 10:52 -0400, nuitari-qemu@nuitari.net a
écrit :
> > The attached one is the one which should be not stupid... but I made
> > more tests and it doesn't work in some cases. So, you can forget it
> > too :-(
>
> In which cases doesn't it work?
In fact it was working in my development test case:
"-hda boot.qcow2 -hdb encrypted.qcow2"
but when I use only encrypted disk or a raw boot file, it doesn't work:
"-hda boot.raw -hdb encrypted.qcow2"
"-hda encrypted.qcow2"
I'm seeking why...
Regards,
Laurent
--
----------------- Laurent.Vivier@bull.net ------------------
"La perfection est atteinte non quand il ne reste rien à
ajouter mais quand il ne reste rien à enlever." Saint Exupéry
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu: ask password when encrypted disk image is used
2008-07-30 14:16 ` Anthony Liguori
2008-07-30 14:29 ` Laurent Vivier
@ 2008-07-30 15:35 ` Laurent Vivier
2008-08-19 14:45 ` Anthony Liguori
1 sibling, 1 reply; 9+ messages in thread
From: Laurent Vivier @ 2008-07-30 15:35 UTC (permalink / raw)
To: qemu-devel; +Cc: nuitari-qemu
[-- Attachment #1: Type: text/plain, Size: 518 bytes --]
Le mercredi 30 juillet 2008 à 09:16 -0500, Anthony Liguori a écrit :
> Once you've straightened things out, can you resend one patch that isn't
> stupid :-) Perhaps it's just too early for me, but I'm thoroughly
> confused about what patch is the right one.
The attached one works well.
Regards,
Laurent
--
----------------- Laurent.Vivier@bull.net ------------------
"La perfection est atteinte non quand il ne reste rien à
ajouter mais quand il ne reste rien à enlever." Saint Exupéry
[-- Attachment #2: qemu-encrypted.patch --]
[-- Type: text/x-patch, Size: 3505 bytes --]
Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
---
console.h | 1 +
monitor.c | 8 +-------
vl.c | 22 +++++++++-------------
3 files changed, 11 insertions(+), 20 deletions(-)
Index: qemu/console.h
===================================================================
--- qemu.orig/console.h 2008-07-30 16:16:34.000000000 +0200
+++ qemu/console.h 2008-07-30 16:17:15.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 16:16:34.000000000 +0200
+++ qemu/monitor.c 2008-07-30 17:04:48.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 16:16:34.000000000 +0200
+++ qemu/vl.c 2008-07-30 17:24:02.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));
}
}
@@ -9103,17 +9095,21 @@ int main(int argc, char **argv)
}
#endif
+ read_passwords();
+
if (loadvm)
do_loadvm(loadvm);
{
/* XXX: simplify init */
- read_passwords();
if (autostart) {
vm_start();
}
}
+ if (monitor_device)
+ monitor_start_input();
+
if (daemonize) {
uint8_t status = 0;
ssize_t len;
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu: ask password when encrypted disk image is used
2008-07-30 15:35 ` Laurent Vivier
@ 2008-08-19 14:45 ` Anthony Liguori
0 siblings, 0 replies; 9+ messages in thread
From: Anthony Liguori @ 2008-08-19 14:45 UTC (permalink / raw)
To: Laurent Vivier; +Cc: nuitari-qemu, qemu-devel
Laurent Vivier wrote:
> Le mercredi 30 juillet 2008 à 09:16 -0500, Anthony Liguori a écrit :
>
>
>
>> Once you've straightened things out, can you resend one patch that isn't
>> stupid :-) Perhaps it's just too early for me, but I'm thoroughly
>> confused about what patch is the right one.
>>
>
> The attached one works well.
>
No, it's broken and I just reverted it. Depending on how you redirect
the monitor, you get either no banner and two (qemu) prompts, or a
banner and two (qemu) prompts.
Please fix this and resubmit.
Regards,
Anthony Liguori
> Regards,
> Laurent
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-08-19 14:46 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-30 12:15 [Qemu-devel] [PATCH] qemu: ask password when encrypted disk image is used Laurent Vivier
2008-07-30 12:42 ` Laurent Vivier
2008-07-30 12:46 ` Laurent Vivier
2008-07-30 14:16 ` Anthony Liguori
2008-07-30 14:29 ` Laurent Vivier
2008-07-30 14:52 ` nuitari-qemu
2008-07-30 15:10 ` Laurent Vivier
2008-07-30 15:35 ` Laurent Vivier
2008-08-19 14:45 ` Anthony Liguori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).