summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2009-12-04 15:24:09 -0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-12-07 16:36:49 -0600
commitb3dfdb5a3bae5fb3170397440dfebd579a3fcb04 (patch)
tree2021f19826758cb1c5e3b55275b4ac89565c1179 /monitor.c
parentQError: Add class for invalid passwords (diff)
downloadqemu-kvm-b3dfdb5a3bae5fb3170397440dfebd579a3fcb04.tar.gz
qemu-kvm-b3dfdb5a3bae5fb3170397440dfebd579a3fcb04.tar.bz2
qemu-kvm-b3dfdb5a3bae5fb3170397440dfebd579a3fcb04.zip
monitor: Introduce 'block_passwd' command
When using encrypted disk images, QEMU will prompt the user for passwords when started. This makes sense for the user protocol, but doesn't for QMP. The solution is to have Monitor command which allows the user or a Client to set passwords in advance, so that we avoid the prompt completely. This is what block_passwd does, for example: (QEMU) block_passwd ide0-hd0 foobar Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> (cherry picked from commit a3a55a2edb7c0fd72bc62a8a4c719a1e1983e6ac)
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/monitor.c b/monitor.c
index ba76f3416..27c696b2d 100644
--- a/monitor.c
+++ b/monitor.c
@@ -772,6 +772,22 @@ static void do_eject(Monitor *mon, const QDict *qdict, QObject **ret_data)
eject_device(mon, bs, force);
}
+static void do_block_set_passwd(Monitor *mon, const QDict *qdict,
+ QObject **ret_data)
+{
+ BlockDriverState *bs;
+
+ bs = bdrv_find(qdict_get_str(qdict, "device"));
+ if (!bs) {
+ qemu_error_new(QERR_DEVICE_NOT_FOUND, qdict_get_str(qdict, "device"));
+ return;
+ }
+
+ if (bdrv_set_key(bs, qdict_get_str(qdict, "password")) < 0) {
+ qemu_error_new(QERR_INVALID_PASSWORD);
+ }
+}
+
static void do_change_block(Monitor *mon, const char *device,
const char *filename, const char *fmt)
{