summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-03-05 23:01:15 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2009-03-05 23:01:15 +0000
commitbb5fc20f7c1c65e95030da3629dd0d7a0cce38cd (patch)
tree2cb53fa2bf9b5165b338e1cc85c8dedc5bf25879 /block.c
parent9dd442b1234a27375c956e650e49a32c61ff6167 (diff)
downloadqemu-bb5fc20f7c1c65e95030da3629dd0d7a0cce38cd.tar.gz
monitor: Rework modal password input (Jan Kiszka)
Currently, waiting for the user to type in some password blocks the whole VM because monitor_readline starts its own I/O loop. And this loop also screws up reading passwords from virtual console. Patch below fixes the shortcomings by using normal I/O processing also for waiting on a password. To keep to modal property for the monitor terminal, the command handler is temporarily replaced by a password handler and a callback infrastructure is established to process the result before switching back to command mode. 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/trunk@6710 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'block.c')
-rw-r--r--block.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/block.c b/block.c
index 78ab2d0462..040bbaea76 100644
--- a/block.c
+++ b/block.c
@@ -430,11 +430,12 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
}
}
- /* call the change callback */
- bs->media_changed = 1;
- if (bs->change_cb)
- bs->change_cb(bs->change_opaque);
-
+ if (!bdrv_key_required(bs)) {
+ /* call the change callback */
+ bs->media_changed = 1;
+ if (bs->change_cb)
+ bs->change_cb(bs->change_opaque);
+ }
return 0;
}
@@ -989,7 +990,15 @@ int bdrv_set_key(BlockDriverState *bs, const char *key)
if (!bs->encrypted || !bs->drv || !bs->drv->bdrv_set_key)
return -1;
ret = bs->drv->bdrv_set_key(bs, key);
- bs->valid_key = (ret == 0);
+ if (ret < 0) {
+ bs->valid_key = 0;
+ } else if (!bs->valid_key) {
+ bs->valid_key = 1;
+ /* call the change callback now, we skipped it on open */
+ bs->media_changed = 1;
+ if (bs->change_cb)
+ bs->change_cb(bs->change_opaque);
+ }
return ret;
}