aboutsummaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-03-21 23:04:14 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-03-21 23:04:14 +0000
commitd35381c87483d49a56e0065dd95d49c79e146809 (patch)
treeec1f3981253016ead4bc47bac04bd3268e5da2f6 /monitor.c
parent7712c5850ef9b95e2f1aea467bf74f84a91ccdcf (diff)
parent7648bb760d768bb88b240e534fdb974f1adf577f (diff)
Add release tag for 0.10.1 releasev0.10.1release_0_10_1
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/tags/release_0_10_1@6881 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c47
1 files changed, 42 insertions, 5 deletions
diff --git a/monitor.c b/monitor.c
index 513eca9daa..914938c7f6 100644
--- a/monitor.c
+++ b/monitor.c
@@ -76,6 +76,8 @@ static uint8_t term_outbuf[1024];
static int term_outbuf_index;
static void monitor_start_input(void);
+static void monitor_readline(const char *prompt, int is_password,
+ char *buf, int buf_size);
static CPUState *mon_cpu = NULL;
@@ -433,7 +435,7 @@ static void do_change_block(const char *device, const char *filename, const char
if (eject_device(bs, 0) < 0)
return;
bdrv_open2(bs, filename, 0, drv);
- qemu_key_check(bs, filename);
+ monitor_read_bdrv_key(bs);
}
static void do_change_vnc(const char *target, const char *arg)
@@ -494,9 +496,24 @@ static void do_stop(void)
vm_stop(EXCP_INTERRUPT);
}
+static void encrypted_bdrv_it(void *opaque, BlockDriverState *bs)
+{
+ int *err = opaque;
+
+ if (bdrv_key_required(bs))
+ *err = monitor_read_bdrv_key(bs);
+ else
+ *err = 0;
+}
+
static void do_cont(void)
{
- vm_start();
+ int err = 0;
+
+ bdrv_iterate(encrypted_bdrv_it, &err);
+ /* only resume the vm if all keys are set and valid */
+ if (!err)
+ vm_start();
}
#ifdef CONFIG_GDBSTUB
@@ -2679,8 +2696,9 @@ static void file_completion(const char *input)
closedir(ffs);
}
-static void block_completion_it(void *opaque, const char *name)
+static void block_completion_it(void *opaque, BlockDriverState *bs)
{
+ const char *name = bdrv_get_device_name(bs);
const char *input = opaque;
if (input[0] == '\0' ||
@@ -2891,8 +2909,8 @@ static void monitor_readline_cb(void *opaque, const char *input)
monitor_readline_started = 0;
}
-void monitor_readline(const char *prompt, int is_password,
- char *buf, int buf_size)
+static void monitor_readline(const char *prompt, int is_password,
+ char *buf, int buf_size)
{
int i;
int old_focus[MAX_MON];
@@ -2922,3 +2940,22 @@ void monitor_readline(const char *prompt, int is_password,
monitor_hd[i]->focus = old_focus[i];
}
}
+
+int monitor_read_bdrv_key(BlockDriverState *bs)
+{
+ char password[256];
+ int i;
+
+ if (!bdrv_is_encrypted(bs))
+ return 0;
+
+ term_printf("%s (%s) is encrypted.\n", bdrv_get_device_name(bs),
+ bdrv_get_encrypted_filename(bs));
+ for(i = 0; i < 3; i++) {
+ monitor_readline("Password: ", 1, password, sizeof(password));
+ if (bdrv_set_key(bs, password) == 0)
+ return 0;
+ term_printf("invalid password\n");
+ }
+ return -EPERM;
+}