]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuDomainSnapshotCreateActiveExternal: Grab agent job
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 19 Jun 2018 17:26:44 +0000 (19:26 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 20 Jun 2018 11:24:17 +0000 (13:24 +0200)
Now that we have agent job we can grab it while freezing/thawing
guest file system before/after doing snapshot.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_driver.c

index 66125f25f6e48950b9f1ec3d9adda2e9b38e858f..b2c8e2d4824042546b447e0f5db9296d5a9e60ae 100644 (file)
@@ -15144,7 +15144,19 @@ qemuDomainSnapshotCreateActiveExternal(virQEMUDriverPtr driver,
      * The command will fail if the guest is paused or the guest agent
      * is not running, or is already quiesced.  */
     if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE) {
-        int freeze = qemuDomainSnapshotFSFreeze(driver, vm, NULL, 0);
+        int freeze;
+
+        if (qemuDomainObjBeginAgentJob(driver, vm, QEMU_AGENT_JOB_MODIFY) < 0)
+            goto cleanup;
+
+        if (virDomainObjCheckActive(vm) < 0) {
+            qemuDomainObjEndAgentJob(vm);
+            goto cleanup;
+        }
+
+        freeze = qemuDomainSnapshotFSFreeze(driver, vm, NULL, 0);
+        qemuDomainObjEndAgentJob(vm);
+
         if (freeze < 0) {
             /* the helper reported the error */
             if (freeze == -2)
@@ -15281,10 +15293,15 @@ qemuDomainSnapshotCreateActiveExternal(virQEMUDriverPtr driver,
     }
 
     if (thaw != 0 &&
-        qemuDomainSnapshotFSThaw(driver, vm, ret == 0 && thaw > 0) < 0) {
-        /* helper reported the error, if it was needed */
-        if (thaw > 0)
-            ret = -1;
+        qemuDomainObjBeginAgentJob(driver, vm, QEMU_AGENT_JOB_MODIFY) >= 0 &&
+        virDomainObjIsActive(vm)) {
+        if (qemuDomainSnapshotFSThaw(driver, vm, ret == 0 && thaw > 0) < 0) {
+            /* helper reported the error, if it was needed */
+            if (thaw > 0)
+                ret = -1;
+        }
+
+        qemuDomainObjEndAgentJob(vm);
     }
 
     virQEMUSaveDataFree(data);