qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, armbru@redhat.com, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH 1/3] blockdev: Fail blockdev-add with encrypted images
Date: Thu,  6 Mar 2014 16:44:27 +0100	[thread overview]
Message-ID: <1394120669-4675-2-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1394120669-4675-1-git-send-email-kwolf@redhat.com>

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>
---
 blockdev.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/blockdev.c b/blockdev.c
index 357f760..561cb81 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);
 }
-- 
1.8.1.4

  reply	other threads:[~2014-03-06 15:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-06 15:44 [Qemu-devel] [PATCH 0/3] blockdev: blockdev-add error path fixes and tests Kevin Wolf
2014-03-06 15:44 ` Kevin Wolf [this message]
2014-03-06 16:02   ` [Qemu-devel] [PATCH 1/3] blockdev: Fail blockdev-add with encrypted images Benoît Canet
2014-03-06 16:21     ` Eric Blake
2014-03-06 15:44 ` [Qemu-devel] [PATCH 2/3] blockdev: Fix NULL pointer dereference in blockdev-add Kevin Wolf
2014-03-06 16:06   ` Benoît Canet
2014-03-06 16:22   ` Eric Blake
2014-03-06 15:44 ` [Qemu-devel] [PATCH 3/3] qemu-iotests: Test a few blockdev-add error cases Kevin Wolf
2014-03-06 16:13   ` Benoît Canet

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=1394120669-4675-2-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).