c1c534
From 6f750627ca303b962cf2c610b9cd27bae0fc1439 Mon Sep 17 00:00:00 2001
c1c534
Message-Id: <6f750627ca303b962cf2c610b9cd27bae0fc1439@dist-git>
c1c534
From: Peter Krempa <pkrempa@redhat.com>
c1c534
Date: Thu, 23 Nov 2017 19:02:20 +0100
c1c534
Subject: [PATCH] qemu: snapshot: Disallow snapshot of unsupported shared disks
c1c534
c1c534
Creating a snapshot would introduce a possibly unsupported member for
c1c534
sharing into the backing chain. Add a check to prevent that from
c1c534
happening.
c1c534
c1c534
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1511480
c1c534
(cherry picked from commit 9b2fbfa6f6b535b9f41a7503531d43d86d7a8868)
c1c534
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c1c534
---
c1c534
 src/qemu/qemu_driver.c | 24 ++++++++++++++++++++++++
c1c534
 1 file changed, 24 insertions(+)
c1c534
c1c534
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
c1c534
index aa6a326bb4..620028fe07 100644
c1c534
--- a/src/qemu/qemu_driver.c
c1c534
+++ b/src/qemu/qemu_driver.c
c1c534
@@ -13952,6 +13952,24 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn,
c1c534
 }
c1c534
 
c1c534
 
c1c534
+static int
c1c534
+qemuDomainSnapshotPrepareDiskShared(virDomainSnapshotDiskDefPtr snapdisk,
c1c534
+                                    virDomainDiskDefPtr domdisk)
c1c534
+{
c1c534
+    if (!domdisk->src->shared || domdisk->src->readonly)
c1c534
+        return 0;
c1c534
+
c1c534
+    if (!qemuBlockStorageSourceSupportsConcurrentAccess(snapdisk->src)) {
c1c534
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
c1c534
+                       _("shared access for disk '%s' requires use of "
c1c534
+                         "supported storage format"), domdisk->dst);
c1c534
+        return -1;
c1c534
+    }
c1c534
+
c1c534
+    return 0;
c1c534
+}
c1c534
+
c1c534
+
c1c534
 static int
c1c534
 qemuDomainSnapshotPrepareDiskExternalInactive(virDomainSnapshotDiskDefPtr snapdisk,
c1c534
                                               virDomainDiskDefPtr domdisk)
c1c534
@@ -14014,6 +14032,9 @@ qemuDomainSnapshotPrepareDiskExternalInactive(virDomainSnapshotDiskDefPtr snapdi
c1c534
         return -1;
c1c534
     }
c1c534
 
c1c534
+    if (qemuDomainSnapshotPrepareDiskShared(snapdisk, domdisk) < 0)
c1c534
+        return -1;
c1c534
+
c1c534
     return 0;
c1c534
 }
c1c534
 
c1c534
@@ -14073,6 +14094,9 @@ qemuDomainSnapshotPrepareDiskExternalActive(virDomainSnapshotDiskDefPtr snapdisk
c1c534
         return -1;
c1c534
     }
c1c534
 
c1c534
+    if (qemuDomainSnapshotPrepareDiskShared(snapdisk, domdisk) < 0)
c1c534
+        return -1;
c1c534
+
c1c534
     return 0;
c1c534
 }
c1c534
 
c1c534
-- 
c1c534
2.15.0
c1c534