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>
This commit is contained in:
parent
d5546c5e77
commit
8ae8e904fc
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user