]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: snapshot: Properly handle image locking
authorPeter Krempa <pkrempa@redhat.com>
Fri, 16 Dec 2016 14:45:26 +0000 (15:45 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 10 Jan 2017 18:12:19 +0000 (19:12 +0100)
Images that became the backing chain of the current image due to the
snapshot need to be unlocked in the lock manager. Also if qemu was
paused during the snapshot the current top level images need to be
released until qemu is resumed so that they can be acquired properly.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1191901

src/qemu/qemu_driver.c

index 4dc97e0191e005087a60f2a9412a85e28186f0e8..da49088bd007a2903a8aeacf2b064e8f76287707 100644 (file)
@@ -14486,6 +14486,23 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
                 virStorageFileUnlink(diskdata[i].src) < 0)
                 VIR_WARN("Unable to remove just-created %s", diskdata[i].src->path);
         }
+    } else {
+        /* on successful snapshot we need to remove locks from the now-old
+         * disks and if the VM is paused release locks on the images since qemu
+         * stopped using them*/
+        bool paused = virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING;
+
+        for (i = 0; i < snap->def->ndisks; i++) {
+            if (!diskdata[i].disk)
+                continue;
+
+            if (paused)
+                virDomainLockImageDetach(driver->lockManager, vm,
+                                         diskdata[i].disk->src);
+
+            virDomainLockImageDetach(driver->lockManager, vm,
+                                     diskdata[i].disk->src->backingStore);
+        }
     }
 
     if (ret == 0 || !actions) {