diff options
author | Kevin Wolf <kwolf@redhat.com> | 2014-03-06 15:43:42 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-03-06 17:27:23 +0100 |
commit | 8ae8e904fcba484ff7c3f8f31339b56ebd88fbad (patch) | |
tree | 02f21e22619345aed4194734d2489b829e4db052 /blockdev.c | |
parent | d5546c5e776ac8f6277ddfdd59df9888e7919c2f (diff) |
blockdev: Fail blockdev-add with encrypted images
Encrypted images need a password before they can be used, and we don't
want blockdev-add to create BDSes that aren't fully initialised. So for
now simply forbid encrypted images; we can come back to it later if we
need the functionality.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r-- | blockdev.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/blockdev.c b/blockdev.c index 357f7607ff..561cb816e4 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2266,6 +2266,7 @@ void qmp_block_job_complete(const char *device, Error **errp) void qmp_blockdev_add(BlockdevOptions *options, Error **errp) { QmpOutputVisitor *ov = qmp_output_visitor_new(); + DriveInfo *dinfo; QObject *obj; QDict *qdict; Error *local_err = NULL; @@ -2301,12 +2302,18 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp) qdict_flatten(qdict); - blockdev_init(NULL, qdict, &local_err); + dinfo = blockdev_init(NULL, qdict, &local_err); if (local_err) { error_propagate(errp, local_err); goto fail; } + if (bdrv_key_required(dinfo->bdrv)) { + drive_uninit(dinfo); + error_setg(errp, "blockdev-add doesn't support encrypted devices"); + goto fail; + } + fail: qmp_output_visitor_cleanup(ov); } |