]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: snapshot: Forbid snapshots when backing is a scsi passthrough disk
authorPeter Krempa <pkrempa@redhat.com>
Tue, 21 Jan 2014 14:34:39 +0000 (15:34 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 21 Jan 2014 16:05:21 +0000 (17:05 +0100)
https://bugzilla.redhat.com/show_bug.cgi?id=1034993

SCSI passthrough disks (<disk .. device="lun">) 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.

src/qemu/qemu_driver.c

index b101d77c812cff78b925e228731a9805f1b29012..bc2971446be7ebb13bfb8b2a251791028d8b19e8 100644 (file)
@@ -12206,7 +12206,7 @@ endjob:
 }
 
 static int
-qemuDomainSnapshotPrepareDiskExternalBacking(virDomainDiskDefPtr disk)
+qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
 {
     int actualType = qemuDiskGetActualType(disk);
 
@@ -12249,6 +12249,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)
 {
@@ -12315,12 +12332,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;
     }