From: Luiz Capitulino <lcapitulino@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com
Subject: [Qemu-devel] [PATCH 2/2] monitor: Introduce 'block_passwd' command
Date: Fri, 4 Dec 2009 15:24:09 -0200 [thread overview]
Message-ID: <1259947449-17576-3-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1259947449-17576-1-git-send-email-lcapitulino@redhat.com>
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>
---
monitor.c | 16 ++++++++++++++++
qemu-monitor.hx | 14 ++++++++++++++
2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/monitor.c b/monitor.c
index 47b11f8..a3ae488 100644
--- a/monitor.c
+++ b/monitor.c
@@ -807,6 +807,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)
{
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 93cbb62..d7c6522 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -1048,6 +1048,20 @@ Close the file descriptor previously assigned to @var{fdname} using the
used by another monitor command.
ETEXI
+ {
+ .name = "block_passwd",
+ .args_type = "device:B,password:s",
+ .params = "block_passwd device password",
+ .help = "set the password of encrypted block devices",
+ .user_print = monitor_user_noop,
+ .mhandler.cmd_new = do_block_set_passwd,
+ },
+
+STEXI
+@item block_passwd @var{device} @var{password}
+Set the encrypted device @var{device} password to @var{password}
+ETEXI
+
STEXI
@end table
ETEXI
--
1.6.6.rc1.5.ge21a85
prev parent reply other threads:[~2009-12-04 17:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-04 17:24 [Qemu-devel] [FOR 0.12] 'block_passwd' monitor command Luiz Capitulino
2009-12-04 17:24 ` [Qemu-devel] [PATCH 1/2] QError: Add class for invalid passwords Luiz Capitulino
2009-12-04 17:24 ` Luiz Capitulino [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1259947449-17576-3-git-send-email-lcapitulino@redhat.com \
--to=lcapitulino@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).