yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
958e1b
From b1e9937d355d28809635967f3ada98c2ecf8ae7f Mon Sep 17 00:00:00 2001
958e1b
From: Kevin Wolf <kwolf@redhat.com>
958e1b
Date: Thu, 23 Oct 2014 10:10:08 +0200
958e1b
Subject: [PATCH 03/19] blockdev: Fail blockdev-add with encrypted images
958e1b
958e1b
Message-id: <1414059011-15516-6-git-send-email-kwolf@redhat.com>
958e1b
Patchwork-id: 61839
958e1b
O-Subject: [RHEL-7.1 qemu-kvm PATCH v2 5/8] blockdev: Fail blockdev-add with encrypted images
958e1b
Bugzilla: 1088176
958e1b
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
958e1b
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
958e1b
RH-Acked-by: Max Reitz <mreitz@redhat.com>
958e1b
958e1b
Encrypted images need a password before they can be used, and we don't
958e1b
want blockdev-add to create BDSes that aren't fully initialised. So for
958e1b
now simply forbid encrypted images; we can come back to it later if we
958e1b
need the functionality.
958e1b
958e1b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
958e1b
Reviewed-by: Eric Blake <eblake@redhat.com>
958e1b
(cherry picked from commit 8ae8e904fcba484ff7c3f8f31339b56ebd88fbad)
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
958e1b
Conflicts:
958e1b
	blockdev.c
958e1b
958e1b
Trivial bonus bugfix so that the backported test 087 won't fail.
958e1b
958e1b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
958e1b
---
958e1b
 blockdev.c | 9 ++++++++-
958e1b
 1 file changed, 8 insertions(+), 1 deletion(-)
958e1b
958e1b
diff --git a/blockdev.c b/blockdev.c
958e1b
index 7d4a53f..a2d5f02 100644
958e1b
--- a/blockdev.c
958e1b
+++ b/blockdev.c
958e1b
@@ -1793,6 +1793,7 @@ void qmp___com_redhat_change_backing_file(const char *device,
958e1b
 void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
958e1b
 {
958e1b
     QmpOutputVisitor *ov = qmp_output_visitor_new();
958e1b
+    DriveInfo *dinfo;
958e1b
     QObject *obj;
958e1b
     QDict *qdict;
958e1b
     Error *local_err = NULL;
958e1b
@@ -1828,12 +1829,18 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
958e1b
 
958e1b
     qdict_flatten(qdict);
958e1b
 
958e1b
-    blockdev_init(qdict, IF_NONE, &local_err);
958e1b
+    dinfo = blockdev_init(qdict, IF_NONE, &local_err);
958e1b
     if (error_is_set(&local_err)) {
958e1b
         error_propagate(errp, local_err);
958e1b
         goto fail;
958e1b
     }
958e1b
 
958e1b
+    if (bdrv_key_required(dinfo->bdrv)) {
958e1b
+        drive_uninit(dinfo);
958e1b
+        error_setg(errp, "blockdev-add doesn't support encrypted devices");
958e1b
+        goto fail;
958e1b
+    }
958e1b
+
958e1b
 fail:
958e1b
     qmp_output_visitor_cleanup(ov);
958e1b
 }
958e1b
-- 
958e1b
1.8.3.1
958e1b