a41c76
From b3285cc15d305161dd0f3730690d6a441c906456 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <b3285cc15d305161dd0f3730690d6a441c906456@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Tue, 4 Feb 2020 15:07:45 +0100
a41c76
Subject: [PATCH] qemu: block: Don't skip creation of 'luks' formatted images
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
libvirt treats 'luks' images as raw+encryption. The logic in
a41c76
qemuBlockStorageSourceCreateFormat skipped the creation if the requested
a41c76
image was raw but didn't take into account the encryption.
a41c76
a41c76
This manifested itself e.g. when attempting to do a virsh blockcopy with
a41c76
the following XML:
a41c76
a41c76
    <disk type='file' device='disk'>
a41c76
      <driver name='qemu' type='raw'/>
a41c76
      <source file='/tmp/enccpy'>
a41c76
        <encryption format='luks'>
a41c76
          <secret type='passphrase' uuid='0a81f5b2-8403-7b23-c8d6-21ccc2f80d6f'/>
a41c76
        </encryption>
a41c76
      </source>
a41c76
    </disk>
a41c76
a41c76
Where qemu would report the following error:
a41c76
a41c76
 unable to execute QEMU command 'blockdev-add': Volume is not in LUKS format
a41c76
a41c76
rather than actually formatting the image first.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Eric Blake <eblake@redhat.com>
a41c76
(cherry picked from commit f4e7c792d58cbd7318fc30519c551e4fe0cd98de)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1371022
a41c76
Message-Id: <1a89d76526af86e4d0437852802a5da0d2aed701.1580824112.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_block.c | 3 ++-
a41c76
 1 file changed, 2 insertions(+), 1 deletion(-)
a41c76
a41c76
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
a41c76
index eab21bc107..22f03da485 100644
a41c76
--- a/src/qemu/qemu_block.c
a41c76
+++ b/src/qemu/qemu_block.c
a41c76
@@ -2479,7 +2479,8 @@ qemuBlockStorageSourceCreateFormat(virDomainObjPtr vm,
a41c76
     g_autoptr(virJSONValue) createformatprops = NULL;
a41c76
     int ret;
a41c76
 
a41c76
-    if (src->format == VIR_STORAGE_FILE_RAW)
a41c76
+    if (src->format == VIR_STORAGE_FILE_RAW &&
a41c76
+        !src->encryption)
a41c76
         return 0;
a41c76
 
a41c76
     if (qemuBlockStorageSourceCreateGetFormatProps(src, backingStore,
a41c76
-- 
a41c76
2.25.0
a41c76