mirror of https://github.com/xemu-project/xemu.git
Ask password when encrypted disk image is used (Laurent Vivier)
This patch repairs the management of encrypted disk images and allows to enter the password. Changelog: v2: - move read_password() before do_loadvm() - really start monitor if output is stdio. Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4976 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
ccf21c31fa
commit
396f929762
|
@ -160,6 +160,7 @@ extern uint8_t _translate_keycode(const int key);
|
||||||
does not need to include console.h */
|
does not need to include console.h */
|
||||||
/* monitor.c */
|
/* monitor.c */
|
||||||
void monitor_init(CharDriverState *hd, int show_banner);
|
void monitor_init(CharDriverState *hd, int show_banner);
|
||||||
|
void monitor_start_input(void);
|
||||||
void term_puts(const char *str);
|
void term_puts(const char *str);
|
||||||
void term_vprintf(const char *fmt, va_list ap);
|
void term_vprintf(const char *fmt, va_list ap);
|
||||||
void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
||||||
|
|
|
@ -76,8 +76,6 @@ static term_cmd_t info_cmds[];
|
||||||
static uint8_t term_outbuf[1024];
|
static uint8_t term_outbuf[1024];
|
||||||
static int term_outbuf_index;
|
static int term_outbuf_index;
|
||||||
|
|
||||||
static void monitor_start_input(void);
|
|
||||||
|
|
||||||
CPUState *mon_cpu = NULL;
|
CPUState *mon_cpu = NULL;
|
||||||
|
|
||||||
void term_flush(void)
|
void term_flush(void)
|
||||||
|
@ -2659,15 +2657,13 @@ static void term_read(void *opaque, const uint8_t *buf, int size)
|
||||||
readline_handle_byte(buf[i]);
|
readline_handle_byte(buf[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void monitor_start_input(void);
|
|
||||||
|
|
||||||
static void monitor_handle_command1(void *opaque, const char *cmdline)
|
static void monitor_handle_command1(void *opaque, const char *cmdline)
|
||||||
{
|
{
|
||||||
monitor_handle_command(cmdline);
|
monitor_handle_command(cmdline);
|
||||||
monitor_start_input();
|
monitor_start_input();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void monitor_start_input(void)
|
void monitor_start_input(void)
|
||||||
{
|
{
|
||||||
readline_start("(qemu) ", 0, monitor_handle_command1, NULL);
|
readline_start("(qemu) ", 0, monitor_handle_command1, NULL);
|
||||||
}
|
}
|
||||||
|
@ -2708,8 +2704,6 @@ void monitor_init(CharDriverState *hd, int show_banner)
|
||||||
hide_banner = !show_banner;
|
hide_banner = !show_banner;
|
||||||
|
|
||||||
qemu_chr_add_handlers(hd, term_can_read, term_read, term_event, NULL);
|
qemu_chr_add_handlers(hd, term_can_read, term_read, term_event, NULL);
|
||||||
|
|
||||||
readline_start("", 0, monitor_handle_command1, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX: use threads ? */
|
/* XXX: use threads ? */
|
||||||
|
|
27
vl.c
27
vl.c
|
@ -5687,7 +5687,7 @@ static int drive_init(struct drive_opt *arg, int snapshot,
|
||||||
bdrv_flags |= BDRV_O_SNAPSHOT;
|
bdrv_flags |= BDRV_O_SNAPSHOT;
|
||||||
if (!cache)
|
if (!cache)
|
||||||
bdrv_flags |= BDRV_O_DIRECT;
|
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",
|
fprintf(stderr, "qemu: could not open disk image %s\n",
|
||||||
file);
|
file);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -7975,22 +7975,14 @@ int qemu_key_check(BlockDriverState *bs, const char *name)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BlockDriverState *get_bdrv(int index)
|
|
||||||
{
|
|
||||||
if (index > nb_drives)
|
|
||||||
return NULL;
|
|
||||||
return drives_table[index].bdrv;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void read_passwords(void)
|
static void read_passwords(void)
|
||||||
{
|
{
|
||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < 6; i++) {
|
for(i = 0; i < nb_drives; i++) {
|
||||||
bs = get_bdrv(i);
|
bs = drives_table[i].bdrv;
|
||||||
if (bs)
|
qemu_key_check(bs, bdrv_get_device_name(bs));
|
||||||
qemu_key_check(bs, bdrv_get_device_name(bs));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8159,6 +8151,7 @@ int main(int argc, char **argv)
|
||||||
int optind;
|
int optind;
|
||||||
const char *r, *optarg;
|
const char *r, *optarg;
|
||||||
CharDriverState *monitor_hd;
|
CharDriverState *monitor_hd;
|
||||||
|
int has_monitor;
|
||||||
const char *monitor_device;
|
const char *monitor_device;
|
||||||
const char *serial_devices[MAX_SERIAL_PORTS];
|
const char *serial_devices[MAX_SERIAL_PORTS];
|
||||||
int serial_device_index;
|
int serial_device_index;
|
||||||
|
@ -9023,6 +9016,8 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Maintain compatibility with multiple stdio monitors */
|
/* Maintain compatibility with multiple stdio monitors */
|
||||||
|
|
||||||
|
has_monitor = 0;
|
||||||
if (!strcmp(monitor_device,"stdio")) {
|
if (!strcmp(monitor_device,"stdio")) {
|
||||||
for (i = 0; i < MAX_SERIAL_PORTS; i++) {
|
for (i = 0; i < MAX_SERIAL_PORTS; i++) {
|
||||||
const char *devname = serial_devices[i];
|
const char *devname = serial_devices[i];
|
||||||
|
@ -9035,6 +9030,7 @@ int main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
has_monitor = 1;
|
||||||
}
|
}
|
||||||
if (monitor_device) {
|
if (monitor_device) {
|
||||||
monitor_hd = qemu_chr_open(monitor_device);
|
monitor_hd = qemu_chr_open(monitor_device);
|
||||||
|
@ -9043,6 +9039,7 @@ int main(int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
monitor_init(monitor_hd, !nographic);
|
monitor_init(monitor_hd, !nographic);
|
||||||
|
has_monitor = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
|
for(i = 0; i < MAX_SERIAL_PORTS; i++) {
|
||||||
|
@ -9103,12 +9100,16 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
read_passwords();
|
||||||
|
|
||||||
|
if (has_monitor)
|
||||||
|
monitor_start_input();
|
||||||
|
|
||||||
if (loadvm)
|
if (loadvm)
|
||||||
do_loadvm(loadvm);
|
do_loadvm(loadvm);
|
||||||
|
|
||||||
{
|
{
|
||||||
/* XXX: simplify init */
|
/* XXX: simplify init */
|
||||||
read_passwords();
|
|
||||||
if (autostart) {
|
if (autostart) {
|
||||||
vm_start();
|
vm_start();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue