[libvirt PATCH v2 23/31] qemu_snapshot: convert snapshot delete to async domain job

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Deleting external snapshots will require to run it as async domain job,
the same way as we do for snapshot creation.

For internal snapshots modify the job mask in order to forbid any other
job to be started.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
Reviewed-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_snapshot.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index 31e7087081..fe279a2374 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -2359,10 +2359,15 @@ qemuSnapshotDiscard(virQEMUDriver *driver,
             if (qemuDomainSnapshotForEachQcow2(driver, def, snap, "-d", true) < 0)
                 return -1;
         } else {
-            qemuDomainObjEnterMonitor(vm);
+            /* Similarly as internal snapshot creation we would use a regular job
+             * here so set a mask to forbid any other job. */
+            qemuDomainObjSetAsyncJobMask(vm, VIR_JOB_NONE);
+            if (qemuDomainObjEnterMonitorAsync(vm, VIR_ASYNC_JOB_SNAPSHOT) < 0)
+                return -1;
             /* we continue on even in the face of error */
             qemuMonitorDeleteSnapshot(qemuDomainGetMonitor(vm), snap->def->name);
             qemuDomainObjExitMonitor(vm);
+            qemuDomainObjSetAsyncJobMask(vm, VIR_JOB_DEFAULT_MASK);
         }
     }
 
@@ -2563,8 +2568,11 @@ qemuSnapshotDelete(virDomainObj *vm,
                   VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY |
                   VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY, -1);
 
-    if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
+    if (virDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_SNAPSHOT,
+                                  VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_DELETE,
+                                  flags) < 0) {
         return -1;
+    }
 
     if (!(snap = qemuSnapObjFromSnapshot(vm, snapshot)))
         goto endjob;
@@ -2583,7 +2591,7 @@ qemuSnapshotDelete(virDomainObj *vm,
     }
 
  endjob:
-    virDomainObjEndJob(vm);
+    virDomainObjEndAsyncJob(vm);
 
     return ret;
 }
-- 
2.39.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux