|
|
c1c534 |
From 53d9458b2d6095e376f2b5cacf30da7b2227f69d Mon Sep 17 00:00:00 2001
|
|
|
c1c534 |
Message-Id: <53d9458b2d6095e376f2b5cacf30da7b2227f69d@dist-git>
|
|
|
c1c534 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
c1c534 |
Date: Thu, 23 Nov 2017 19:02:13 +0100
|
|
|
c1c534 |
Subject: [PATCH] qemu: Move snapshot disk validation functions into one
|
|
|
c1c534 |
|
|
|
c1c534 |
Move the code so that both the new image and old image can be verified
|
|
|
c1c534 |
in the same function.
|
|
|
c1c534 |
|
|
|
c1c534 |
(cherry picked from commit 8ffdeed455650557df531aafc66c20b31bd4e0c4)
|
|
|
c1c534 |
|
|
|
c1c534 |
https://bugzilla.redhat.com/show_bug.cgi?id=1511480
|
|
|
c1c534 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c1c534 |
---
|
|
|
c1c534 |
src/qemu/qemu_driver.c | 91 ++++++++++++++++++++------------------------------
|
|
|
c1c534 |
1 file changed, 36 insertions(+), 55 deletions(-)
|
|
|
c1c534 |
|
|
|
c1c534 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
c1c534 |
index b35ab6d30e..aa6a326bb4 100644
|
|
|
c1c534 |
--- a/src/qemu/qemu_driver.c
|
|
|
c1c534 |
+++ b/src/qemu/qemu_driver.c
|
|
|
c1c534 |
@@ -13953,17 +13953,19 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn,
|
|
|
c1c534 |
|
|
|
c1c534 |
|
|
|
c1c534 |
static int
|
|
|
c1c534 |
-qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
|
|
|
c1c534 |
+qemuDomainSnapshotPrepareDiskExternalInactive(virDomainSnapshotDiskDefPtr snapdisk,
|
|
|
c1c534 |
+ virDomainDiskDefPtr domdisk)
|
|
|
c1c534 |
{
|
|
|
c1c534 |
- int actualType = virStorageSourceGetActualType(disk->src);
|
|
|
c1c534 |
+ int domDiskType = virStorageSourceGetActualType(domdisk->src);
|
|
|
c1c534 |
+ int snapDiskType = virStorageSourceGetActualType(snapdisk->src);
|
|
|
c1c534 |
|
|
|
c1c534 |
- switch ((virStorageType) actualType) {
|
|
|
c1c534 |
+ switch ((virStorageType) domDiskType) {
|
|
|
c1c534 |
case VIR_STORAGE_TYPE_BLOCK:
|
|
|
c1c534 |
case VIR_STORAGE_TYPE_FILE:
|
|
|
c1c534 |
- return 0;
|
|
|
c1c534 |
+ break;
|
|
|
c1c534 |
|
|
|
c1c534 |
case VIR_STORAGE_TYPE_NETWORK:
|
|
|
c1c534 |
- switch ((virStorageNetProtocol) disk->src->protocol) {
|
|
|
c1c534 |
+ switch ((virStorageNetProtocol) domdisk->src->protocol) {
|
|
|
c1c534 |
case VIR_STORAGE_NET_PROTOCOL_NONE:
|
|
|
c1c534 |
case VIR_STORAGE_NET_PROTOCOL_NBD:
|
|
|
c1c534 |
case VIR_STORAGE_NET_PROTOCOL_RBD:
|
|
|
c1c534 |
@@ -13981,7 +13983,7 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
|
|
|
c1c534 |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c1c534 |
_("external inactive snapshots are not supported on "
|
|
|
c1c534 |
"'network' disks using '%s' protocol"),
|
|
|
c1c534 |
- virStorageNetProtocolTypeToString(disk->src->protocol));
|
|
|
c1c534 |
+ virStorageNetProtocolTypeToString(domdisk->src->protocol));
|
|
|
c1c534 |
return -1;
|
|
|
c1c534 |
}
|
|
|
c1c534 |
break;
|
|
|
c1c534 |
@@ -13992,7 +13994,23 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
|
|
|
c1c534 |
case VIR_STORAGE_TYPE_LAST:
|
|
|
c1c534 |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c1c534 |
_("external inactive snapshots are not supported on "
|
|
|
c1c534 |
- "'%s' disks"), virStorageTypeToString(actualType));
|
|
|
c1c534 |
+ "'%s' disks"), virStorageTypeToString(domDiskType));
|
|
|
c1c534 |
+ return -1;
|
|
|
c1c534 |
+ }
|
|
|
c1c534 |
+
|
|
|
c1c534 |
+ switch ((virStorageType) snapDiskType) {
|
|
|
c1c534 |
+ case VIR_STORAGE_TYPE_BLOCK:
|
|
|
c1c534 |
+ case VIR_STORAGE_TYPE_FILE:
|
|
|
c1c534 |
+ break;
|
|
|
c1c534 |
+
|
|
|
c1c534 |
+ case VIR_STORAGE_TYPE_NETWORK:
|
|
|
c1c534 |
+ case VIR_STORAGE_TYPE_DIR:
|
|
|
c1c534 |
+ case VIR_STORAGE_TYPE_VOLUME:
|
|
|
c1c534 |
+ case VIR_STORAGE_TYPE_NONE:
|
|
|
c1c534 |
+ case VIR_STORAGE_TYPE_LAST:
|
|
|
c1c534 |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c1c534 |
+ _("external inactive snapshots are not supported on "
|
|
|
c1c534 |
+ "'%s' disks"), virStorageTypeToString(snapDiskType));
|
|
|
c1c534 |
return -1;
|
|
|
c1c534 |
}
|
|
|
c1c534 |
|
|
|
c1c534 |
@@ -14001,33 +14019,27 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
|
|
|
c1c534 |
|
|
|
c1c534 |
|
|
|
c1c534 |
static int
|
|
|
c1c534 |
-qemuDomainSnapshotPrepareDiskExternalBackingActive(virDomainDiskDefPtr disk)
|
|
|
c1c534 |
+qemuDomainSnapshotPrepareDiskExternalActive(virDomainSnapshotDiskDefPtr snapdisk,
|
|
|
c1c534 |
+ virDomainDiskDefPtr domdisk)
|
|
|
c1c534 |
{
|
|
|
c1c534 |
- if (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
|
|
|
c1c534 |
+ int actualType = virStorageSourceGetActualType(snapdisk->src);
|
|
|
c1c534 |
+
|
|
|
c1c534 |
+ if (domdisk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
|
|
|
c1c534 |
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
c1c534 |
_("external active snapshots are not supported on scsi "
|
|
|
c1c534 |
"passthrough devices"));
|
|
|
c1c534 |
return -1;
|
|
|
c1c534 |
}
|
|
|
c1c534 |
|
|
|
c1c534 |
- return 0;
|
|
|
c1c534 |
-}
|
|
|
c1c534 |
-
|
|
|
c1c534 |
-
|
|
|
c1c534 |
-static int
|
|
|
c1c534 |
-qemuDomainSnapshotPrepareDiskExternalOverlayActive(virDomainSnapshotDiskDefPtr disk)
|
|
|
c1c534 |
-{
|
|
|
c1c534 |
- int actualType = virStorageSourceGetActualType(disk->src);
|
|
|
c1c534 |
-
|
|
|
c1c534 |
switch ((virStorageType) actualType) {
|
|
|
c1c534 |
case VIR_STORAGE_TYPE_BLOCK:
|
|
|
c1c534 |
case VIR_STORAGE_TYPE_FILE:
|
|
|
c1c534 |
- return 0;
|
|
|
c1c534 |
+ break;
|
|
|
c1c534 |
|
|
|
c1c534 |
case VIR_STORAGE_TYPE_NETWORK:
|
|
|
c1c534 |
- switch ((virStorageNetProtocol) disk->src->protocol) {
|
|
|
c1c534 |
+ switch ((virStorageNetProtocol) snapdisk->src->protocol) {
|
|
|
c1c534 |
case VIR_STORAGE_NET_PROTOCOL_GLUSTER:
|
|
|
c1c534 |
- return 0;
|
|
|
c1c534 |
+ break;
|
|
|
c1c534 |
|
|
|
c1c534 |
case VIR_STORAGE_NET_PROTOCOL_NONE:
|
|
|
c1c534 |
case VIR_STORAGE_NET_PROTOCOL_NBD:
|
|
|
c1c534 |
@@ -14045,7 +14057,7 @@ qemuDomainSnapshotPrepareDiskExternalOverlayActive(virDomainSnapshotDiskDefPtr d
|
|
|
c1c534 |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c1c534 |
_("external active snapshots are not supported on "
|
|
|
c1c534 |
"'network' disks using '%s' protocol"),
|
|
|
c1c534 |
- virStorageNetProtocolTypeToString(disk->src->protocol));
|
|
|
c1c534 |
+ virStorageNetProtocolTypeToString(snapdisk->src->protocol));
|
|
|
c1c534 |
return -1;
|
|
|
c1c534 |
|
|
|
c1c534 |
}
|
|
|
c1c534 |
@@ -14065,31 +14077,6 @@ qemuDomainSnapshotPrepareDiskExternalOverlayActive(virDomainSnapshotDiskDefPtr d
|
|
|
c1c534 |
}
|
|
|
c1c534 |
|
|
|
c1c534 |
|
|
|
c1c534 |
-static int
|
|
|
c1c534 |
-qemuDomainSnapshotPrepareDiskExternalOverlayInactive(virDomainSnapshotDiskDefPtr disk)
|
|
|
c1c534 |
-{
|
|
|
c1c534 |
- int actualType = virStorageSourceGetActualType(disk->src);
|
|
|
c1c534 |
-
|
|
|
c1c534 |
- switch ((virStorageType) actualType) {
|
|
|
c1c534 |
- case VIR_STORAGE_TYPE_BLOCK:
|
|
|
c1c534 |
- case VIR_STORAGE_TYPE_FILE:
|
|
|
c1c534 |
- return 0;
|
|
|
c1c534 |
-
|
|
|
c1c534 |
- case VIR_STORAGE_TYPE_NETWORK:
|
|
|
c1c534 |
- case VIR_STORAGE_TYPE_DIR:
|
|
|
c1c534 |
- case VIR_STORAGE_TYPE_VOLUME:
|
|
|
c1c534 |
- case VIR_STORAGE_TYPE_NONE:
|
|
|
c1c534 |
- case VIR_STORAGE_TYPE_LAST:
|
|
|
c1c534 |
- virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c1c534 |
- _("external inactive snapshots are not supported on "
|
|
|
c1c534 |
- "'%s' disks"), virStorageTypeToString(actualType));
|
|
|
c1c534 |
- return -1;
|
|
|
c1c534 |
- }
|
|
|
c1c534 |
-
|
|
|
c1c534 |
- return 0;
|
|
|
c1c534 |
-}
|
|
|
c1c534 |
-
|
|
|
c1c534 |
-
|
|
|
c1c534 |
static int
|
|
|
c1c534 |
qemuDomainSnapshotPrepareDiskExternal(virConnectPtr conn,
|
|
|
c1c534 |
virDomainDiskDefPtr disk,
|
|
|
c1c534 |
@@ -14107,16 +14094,10 @@ qemuDomainSnapshotPrepareDiskExternal(virConnectPtr conn,
|
|
|
c1c534 |
if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
|
|
|
c1c534 |
return -1;
|
|
|
c1c534 |
|
|
|
c1c534 |
- if (qemuDomainSnapshotPrepareDiskExternalBackingInactive(disk) < 0)
|
|
|
c1c534 |
- return -1;
|
|
|
c1c534 |
-
|
|
|
c1c534 |
- if (qemuDomainSnapshotPrepareDiskExternalOverlayInactive(snapdisk) < 0)
|
|
|
c1c534 |
+ if (qemuDomainSnapshotPrepareDiskExternalInactive(snapdisk, disk) < 0)
|
|
|
c1c534 |
return -1;
|
|
|
c1c534 |
} else {
|
|
|
c1c534 |
- if (qemuDomainSnapshotPrepareDiskExternalBackingActive(disk) < 0)
|
|
|
c1c534 |
- return -1;
|
|
|
c1c534 |
-
|
|
|
c1c534 |
- if (qemuDomainSnapshotPrepareDiskExternalOverlayActive(snapdisk) < 0)
|
|
|
c1c534 |
+ if (qemuDomainSnapshotPrepareDiskExternalActive(snapdisk, disk) < 0)
|
|
|
c1c534 |
return -1;
|
|
|
c1c534 |
}
|
|
|
c1c534 |
|
|
|
c1c534 |
--
|
|
|
c1c534 |
2.15.0
|
|
|
c1c534 |
|