summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-03-05 19:42:40 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-03-05 19:42:40 +0000
commitb786b7ccbd375c052ffa9d3a818b88ee4870849c (patch)
tree6a72e9f9853916adad4f98493e01392d8d8d6aa9 /block.c
parentd3be2b2f71e616f18dc20af570c84ebdf091b4e7 (diff)
downloadqemu-b786b7ccbd375c052ffa9d3a818b88ee4870849c.tar.gz
monitor: Rework early disk password inquiry (Jan Kiszka)
Reading the passwords for encrypted hard disks during early startup is broken (I guess for quiet a while now): - No monitor terminal is ready for input at this point - Forcing all mux'ed terminals into monitor mode can confuse other users of that channels To overcome these issues and to lay the ground for a clean decoupling of monitor terminals, this patch changes the initial password inquiry as follows: - Prevent autostart if there is some encrypted disk - Once the user tries to resume the VM, prompt for all missing passwords - Only resume if all passwords were accepted Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/branches/stable_0_10_0@6699 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'block.c')
-rw-r--r--block.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/block.c b/block.c
index 5f3f780fbe..78ab2d0462 100644
--- a/block.c
+++ b/block.c
@@ -336,6 +336,7 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
bs->read_only = 0;
bs->is_temporary = 0;
bs->encrypted = 0;
+ bs->valid_key = 0;
if (flags & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
@@ -966,6 +967,15 @@ int bdrv_is_encrypted(BlockDriverState *bs)
return bs->encrypted;
}
+int bdrv_key_required(BlockDriverState *bs)
+{
+ BlockDriverState *backing_hd = bs->backing_hd;
+
+ if (backing_hd && backing_hd->encrypted && !backing_hd->valid_key)
+ return 1;
+ return (bs->encrypted && !bs->valid_key);
+}
+
int bdrv_set_key(BlockDriverState *bs, const char *key)
{
int ret;
@@ -978,7 +988,9 @@ int bdrv_set_key(BlockDriverState *bs, const char *key)
}
if (!bs->encrypted || !bs->drv || !bs->drv->bdrv_set_key)
return -1;
- return bs->drv->bdrv_set_key(bs, key);
+ ret = bs->drv->bdrv_set_key(bs, key);
+ bs->valid_key = (ret == 0);
+ return ret;
}
void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size)