|
|
0310fa |
From 84664353b00622571f099cf3306b317b7a67072f Mon Sep 17 00:00:00 2001
|
|
|
0310fa |
Message-Id: <84664353b00622571f099cf3306b317b7a67072f@dist-git>
|
|
|
0310fa |
From: John Ferlan <jferlan@redhat.com>
|
|
|
0310fa |
Date: Tue, 3 Jan 2017 13:31:55 -0500
|
|
|
0310fa |
Subject: [PATCH] qemu: Don't assume secret provided for LUKS encryption
|
|
|
0310fa |
|
|
|
0310fa |
7.4: https://bugzilla.redhat.com/show_bug.cgi?id=1405269
|
|
|
0310fa |
|
|
|
0310fa |
If a secret was not provided for what was determined to be a LUKS
|
|
|
0310fa |
encrypted disk (during virStorageFileGetMetadata processing when
|
|
|
0310fa |
called from qemuDomainDetermineDiskChain as a result of hotplug
|
|
|
0310fa |
attach qemuDomainAttachDeviceDiskLive), then do not attempt to
|
|
|
0310fa |
look it up (avoiding a libvirtd crash) and do not alter the format
|
|
|
0310fa |
to "luks" when adding the disk; otherwise, the device_add would
|
|
|
0310fa |
fail with a message such as:
|
|
|
0310fa |
|
|
|
0310fa |
"unable to execute QEMU command 'device_add': Property 'scsi-hd.drive'
|
|
|
0310fa |
can't find value 'drive-scsi0-0-0-0'"
|
|
|
0310fa |
|
|
|
0310fa |
because of assumptions that when the format=luks that libvirt would have
|
|
|
0310fa |
provided the secret to decrypt the volume.
|
|
|
0310fa |
|
|
|
0310fa |
Access to unlock the volume will thus be left to the application.
|
|
|
0310fa |
|
|
|
0310fa |
(cherry picked from commit 7f7d99048350935a394d07b98a13d7da9c4b0502)
|
|
|
0310fa |
|
|
|
0310fa |
https://bugzilla.redhat.com/show_bug.cgi?id=1411394
|
|
|
0310fa |
|
|
|
0310fa |
Signed-off-by: John Ferlan <jferlan@redhat.com>
|
|
|
0310fa |
---
|
|
|
0310fa |
src/qemu/qemu_command.c | 3 +--
|
|
|
0310fa |
src/qemu/qemu_domain.c | 15 +++++++++++++--
|
|
|
0310fa |
src/qemu/qemu_domain.h | 3 +++
|
|
|
0310fa |
src/qemu/qemu_hotplug.c | 3 +--
|
|
|
0310fa |
4 files changed, 18 insertions(+), 6 deletions(-)
|
|
|
0310fa |
|
|
|
0310fa |
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
|
|
0310fa |
index ade9e2524..bd01a0f76 100644
|
|
|
0310fa |
--- a/src/qemu/qemu_command.c
|
|
|
0310fa |
+++ b/src/qemu/qemu_command.c
|
|
|
0310fa |
@@ -1312,8 +1312,7 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
|
|
|
0310fa |
if (disk->src->format > 0 &&
|
|
|
0310fa |
disk->src->type != VIR_STORAGE_TYPE_DIR) {
|
|
|
0310fa |
const char *qemuformat = virStorageFileFormatTypeToString(disk->src->format);
|
|
|
0310fa |
- if (disk->src->encryption &&
|
|
|
0310fa |
- disk->src->encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS)
|
|
|
0310fa |
+ if (qemuDomainDiskHasEncryptionSecret(disk->src))
|
|
|
0310fa |
qemuformat = "luks";
|
|
|
0310fa |
virBufferAsprintf(buf, "format=%s,", qemuformat);
|
|
|
0310fa |
}
|
|
|
0310fa |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
0310fa |
index 3d2650fd5..b91db229f 100644
|
|
|
0310fa |
--- a/src/qemu/qemu_domain.c
|
|
|
0310fa |
+++ b/src/qemu/qemu_domain.c
|
|
|
0310fa |
@@ -1037,6 +1037,18 @@ qemuDomainSecretDiskCapable(virStorageSourcePtr src)
|
|
|
0310fa |
}
|
|
|
0310fa |
|
|
|
0310fa |
|
|
|
0310fa |
+bool
|
|
|
0310fa |
+qemuDomainDiskHasEncryptionSecret(virStorageSourcePtr src)
|
|
|
0310fa |
+{
|
|
|
0310fa |
+ if (!virStorageSourceIsEmpty(src) && src->encryption &&
|
|
|
0310fa |
+ src->encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS &&
|
|
|
0310fa |
+ src->encryption->nsecrets > 0)
|
|
|
0310fa |
+ return true;
|
|
|
0310fa |
+
|
|
|
0310fa |
+ return false;
|
|
|
0310fa |
+}
|
|
|
0310fa |
+
|
|
|
0310fa |
+
|
|
|
0310fa |
/* qemuDomainSecretDiskPrepare:
|
|
|
0310fa |
* @conn: Pointer to connection
|
|
|
0310fa |
* @priv: pointer to domain private object
|
|
|
0310fa |
@@ -1075,8 +1087,7 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
|
|
|
0310fa |
diskPriv->secinfo = secinfo;
|
|
|
0310fa |
}
|
|
|
0310fa |
|
|
|
0310fa |
- if (!virStorageSourceIsEmpty(src) && src->encryption &&
|
|
|
0310fa |
- src->encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) {
|
|
|
0310fa |
+ if (qemuDomainDiskHasEncryptionSecret(src)) {
|
|
|
0310fa |
|
|
|
0310fa |
if (VIR_ALLOC(secinfo) < 0)
|
|
|
0310fa |
return -1;
|
|
|
0310fa |
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
|
|
|
0310fa |
index 66ffe5817..e6eda2388 100644
|
|
|
0310fa |
--- a/src/qemu/qemu_domain.h
|
|
|
0310fa |
+++ b/src/qemu/qemu_domain.h
|
|
|
0310fa |
@@ -698,6 +698,9 @@ void qemuDomainSecretDiskDestroy(virDomainDiskDefPtr disk)
|
|
|
0310fa |
bool qemuDomainSecretDiskCapable(virStorageSourcePtr src)
|
|
|
0310fa |
ATTRIBUTE_NONNULL(1);
|
|
|
0310fa |
|
|
|
0310fa |
+bool qemuDomainDiskHasEncryptionSecret(virStorageSourcePtr src)
|
|
|
0310fa |
+ ATTRIBUTE_NONNULL(1);
|
|
|
0310fa |
+
|
|
|
0310fa |
int qemuDomainSecretDiskPrepare(virConnectPtr conn,
|
|
|
0310fa |
qemuDomainObjPrivatePtr priv,
|
|
|
0310fa |
virDomainDiskDefPtr disk)
|
|
|
0310fa |
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
|
|
|
0310fa |
index 967c7c0b7..b7302a5f9 100644
|
|
|
0310fa |
--- a/src/qemu/qemu_hotplug.c
|
|
|
0310fa |
+++ b/src/qemu/qemu_hotplug.c
|
|
|
0310fa |
@@ -3148,8 +3148,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver,
|
|
|
0310fa |
/* Similarly, if this is possible a device using LUKS encryption, we
|
|
|
0310fa |
* can remove the luks object password too
|
|
|
0310fa |
*/
|
|
|
0310fa |
- if (!virStorageSourceIsEmpty(disk->src) && disk->src->encryption &&
|
|
|
0310fa |
- disk->src->encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) {
|
|
|
0310fa |
+ if (qemuDomainDiskHasEncryptionSecret(disk->src)) {
|
|
|
0310fa |
|
|
|
0310fa |
if (!(encAlias =
|
|
|
0310fa |
qemuDomainGetSecretAESAlias(disk->info.alias, true))) {
|
|
|
0310fa |
--
|
|
|
0310fa |
2.11.1
|
|
|
0310fa |
|