aboutsummaryrefslogtreecommitdiff
path: root/blockdev.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2015-01-29 10:37:00 +0100
committerMax Reitz <mreitz@redhat.com>2015-02-06 11:46:32 -0500
commit4d2855a348c5e90f56584ab9777fc877965ca2e0 (patch)
treea18099246734fba4be68e2843ea917caf6701ace /blockdev.c
parent2e3a0266bd84a9be9f5e23c1568db6eb7f3e9e94 (diff)
downloadqemu-4d2855a348c5e90f56584ab9777fc877965ca2e0.zip
qemu-4d2855a348c5e90f56584ab9777fc877965ca2e0.tar.gz
qemu-4d2855a348c5e90f56584ab9777fc877965ca2e0.tar.bz2
block: New bdrv_add_key(), convert monitor to use it
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 1422524221-8566-4-git-send-email-armbru@redhat.com Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r--blockdev.c24
1 files changed, 2 insertions, 22 deletions
diff --git a/blockdev.c b/blockdev.c
index 287d7af..7d34960 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1793,7 +1793,6 @@ void qmp_block_passwd(bool has_device, const char *device,
Error *local_err = NULL;
BlockDriverState *bs;
AioContext *aio_context;
- int err;
bs = bdrv_lookup_bs(has_device ? device : NULL,
has_node_name ? node_name : NULL,
@@ -1806,16 +1805,8 @@ void qmp_block_passwd(bool has_device, const char *device,
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
- err = bdrv_set_key(bs, password);
- if (err == -EINVAL) {
- error_set(errp, QERR_DEVICE_NOT_ENCRYPTED, bdrv_get_device_name(bs));
- goto out;
- } else if (err < 0) {
- error_set(errp, QERR_INVALID_PASSWORD);
- goto out;
- }
+ bdrv_add_key(bs, password, errp);
-out:
aio_context_release(aio_context);
}
@@ -1833,18 +1824,7 @@ static void qmp_bdrv_open_encrypted(BlockDriverState *bs, const char *filename,
return;
}
- if (bdrv_key_required(bs)) {
- if (password) {
- if (bdrv_set_key(bs, password) < 0) {
- error_set(errp, QERR_INVALID_PASSWORD);
- }
- } else {
- error_set(errp, QERR_DEVICE_ENCRYPTED, bdrv_get_device_name(bs),
- bdrv_get_encrypted_filename(bs));
- }
- } else if (password) {
- error_set(errp, QERR_DEVICE_NOT_ENCRYPTED, bdrv_get_device_name(bs));
- }
+ bdrv_add_key(bs, password, errp);
}
void qmp_change_blockdev(const char *device, const char *filename,