render / rpms / libvirt

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