render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
6ae9ed
From b3b0863f3274d3de217d006cf03a442a63606271 Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <b3b0863f3274d3de217d006cf03a442a63606271@dist-git>
6ae9ed
From: John Ferlan <jferlan@redhat.com>
6ae9ed
Date: Mon, 25 Jul 2016 12:43:04 -0400
6ae9ed
Subject: [PATCH] qemu: Disallow usage of luks encryption if aes secret not
6ae9ed
 possible
6ae9ed
6ae9ed
https://bugzilla.redhat.com/show_bug.cgi?id=1301021
6ae9ed
6ae9ed
Resolves a CI test integration failure with a RHEL6/Centos6 environment.
6ae9ed
6ae9ed
In order to use a LUKS encrypted device, the design decision was to
6ae9ed
generate an encrypted secret based on the master key. However, commit
6ae9ed
id 'da86c6c' missed checking for that specifically.
6ae9ed
6ae9ed
When qemuDomainSecretSetup was implemented, a design decision was made
6ae9ed
to "fall back" to a plain text secret setup if the specific cipher was
6ae9ed
not available (e.g. virCryptoHaveCipher(VIR_CRYPTO_CIPHER_AES256CBC))
6ae9ed
as well as the QEMU_CAPS_OBJECT_SECRET. For the luks encryption setup
6ae9ed
there is no fall back to the plaintext secret, thus if that gets set
6ae9ed
up by qemuDomainSecretSetup, then we need to fail.
6ae9ed
6ae9ed
Also, while the qemuxml2argvtest has set the QEMU_CAPS_OBJECT_SECRET
6ae9ed
bit, it didn't take into account the second requirement that the
6ae9ed
ability to generate the encrypted secret is possible. So modify the
6ae9ed
test to not attempt to run the luks-disk if we know we don't have
6ae9ed
the encryption algorithm.
6ae9ed
6ae9ed
(cherry picked from commit a53349e6c6d3ff051e48b40c94a672168bbc3aac)
6ae9ed
Signed-off-by: John Ferlan <jferlan@redhat.com>
6ae9ed
---
6ae9ed
 src/qemu/qemu_domain.c   | 7 +++++++
6ae9ed
 tests/qemuxml2argvtest.c | 4 ++++
6ae9ed
 2 files changed, 11 insertions(+)
6ae9ed
6ae9ed
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
6ae9ed
index 26d0d12..158f3ef 100644
6ae9ed
--- a/src/qemu/qemu_domain.c
6ae9ed
+++ b/src/qemu/qemu_domain.c
6ae9ed
@@ -1042,6 +1042,13 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
6ae9ed
                                   true) < 0)
6ae9ed
             goto error;
6ae9ed
 
6ae9ed
+        if (secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_PLAIN) {
6ae9ed
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
6ae9ed
+                           _("luks encryption requires encrypted secrets "
6ae9ed
+                             "to be supported"));
6ae9ed
+            goto error;
6ae9ed
+        }
6ae9ed
+
6ae9ed
         diskPriv->encinfo = secinfo;
6ae9ed
     }
6ae9ed
 
6ae9ed
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
6ae9ed
index eddacf8..f49f9b9 100644
6ae9ed
--- a/tests/qemuxml2argvtest.c
6ae9ed
+++ b/tests/qemuxml2argvtest.c
6ae9ed
@@ -1379,7 +1379,11 @@ mymain(void)
6ae9ed
 
6ae9ed
     DO_TEST("encrypted-disk", NONE);
6ae9ed
     DO_TEST("encrypted-disk-usage", NONE);
6ae9ed
+# ifdef HAVE_GNUTLS_CIPHER_ENCRYPT
6ae9ed
     DO_TEST("luks-disks", QEMU_CAPS_OBJECT_SECRET);
6ae9ed
+# else
6ae9ed
+    DO_TEST_FAILURE("luks-disks", QEMU_CAPS_OBJECT_SECRET);
6ae9ed
+# endif
6ae9ed
 
6ae9ed
     DO_TEST("memtune", NONE);
6ae9ed
     DO_TEST("memtune-unlimited", NONE);
6ae9ed
-- 
6ae9ed
2.9.2
6ae9ed