From bdc4fc23246048aa8c740db5b8b2e37521e1278b Mon Sep 17 00:00:00 2001 Message-Id: From: Peter Krempa Date: Wed, 26 Feb 2014 14:55:20 +0100 Subject: [PATCH] qemu: snapshot: Forbid snapshots when backing is a scsi passthrough disk https://bugzilla.redhat.com/show_bug.cgi?id=1034993 SCSI passthrough disks () can't be used as backing for snapshots. Currently with upstream qemu the vm crashes on such attempt. This patch adds a early check to catch an attempt to do such a snapshot and rejects it right away. qemu will fix the issue but this will let us control the error message. (cherry picked from commit 3d1e9e47794f95b9862a3f75d268380b7b700687) Signed-off-by: Jiri Denemark --- src/qemu/qemu_driver.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index fe55fed..1c9b190 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12141,7 +12141,7 @@ endjob: } static int -qemuDomainSnapshotPrepareDiskExternalBacking(virDomainDiskDefPtr disk) +qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk) { int actualType = qemuDiskGetActualType(disk); @@ -12180,6 +12180,23 @@ qemuDomainSnapshotPrepareDiskExternalBacking(virDomainDiskDefPtr disk) static int +qemuDomainSnapshotPrepareDiskExternalBackingActive(virDomainDiskDefPtr disk) +{ + int actualType = qemuDiskGetActualType(disk); + + if (actualType == VIR_DOMAIN_DISK_TYPE_BLOCK && + disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("external active snapshots are not supported on scsi " + "passthrough devices")); + return -1; + } + + return 0; +} + + +static int qemuDomainSnapshotPrepareDiskExternalOverlayActive(virDomainSnapshotDiskDefPtr disk) { int actualType = qemuSnapshotDiskGetActualType(disk); @@ -12245,12 +12262,15 @@ qemuDomainSnapshotPrepareDiskExternal(virConnectPtr conn, if (qemuTranslateDiskSourcePool(conn, disk) < 0) return -1; - if (qemuDomainSnapshotPrepareDiskExternalBacking(disk) < 0) + if (qemuDomainSnapshotPrepareDiskExternalBackingInactive(disk) < 0) return -1; if (qemuDomainSnapshotPrepareDiskExternalOverlayInactive(snapdisk) < 0) return -1; } else { + if (qemuDomainSnapshotPrepareDiskExternalBackingActive(disk) < 0) + return -1; + if (qemuDomainSnapshotPrepareDiskExternalOverlayActive(snapdisk) < 0) return -1; } -- 1.9.0