The idea is to make block commit callable from within the QEMU driver.

Signed-off-by: Pavel Mores <pmo...@redhat.com>
---
 src/qemu/qemu_driver.c | 84 +++++++++++++++++++++++++++---------------
 1 file changed, 55 insertions(+), 29 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e9a62684f0..f94636f651 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -154,6 +154,15 @@ static int qemuOpenFileAs(uid_t fallback_uid, gid_t 
fallback_gid,
 
 static virQEMUDriverPtr qemu_driver;
 
+static int
+qemuDomainBlockCommitImpl(virDomainObjPtr vm,
+                          virQEMUDriverPtr driver,
+                          const char *path,
+                          const char *base,
+                          const char *top,
+                          unsigned long bandwidth,
+                          unsigned int flags);
+
 /* Looks up the domain object from snapshot and unlocks the
  * driver. The returned domain object is locked and ref'd and the
  * caller must call virDomainObjEndAPI() on it. */
@@ -18314,18 +18323,16 @@ qemuDomainBlockPull(virDomainPtr dom, const char 
*path, unsigned long bandwidth,
     return qemuDomainBlockPullCommon(vm, path, NULL, bandwidth, flags);
 }
 
-
 static int
-qemuDomainBlockCommit(virDomainPtr dom,
-                      const char *path,
-                      const char *base,
-                      const char *top,
-                      unsigned long bandwidth,
-                      unsigned int flags)
+qemuDomainBlockCommitImpl(virDomainObjPtr vm,
+                          virQEMUDriverPtr driver,
+                          const char *path,
+                          const char *base,
+                          const char *top,
+                          unsigned long bandwidth,
+                          unsigned int flags)
 {
-    virQEMUDriverPtr driver = dom->conn->privateData;
-    qemuDomainObjPrivatePtr priv;
-    virDomainObjPtr vm = NULL;
+    qemuDomainObjPrivatePtr priv = vm->privateData;
     const char *device = NULL;
     const char *jobname = NULL;
     int ret = -1;
@@ -18347,25 +18354,6 @@ qemuDomainBlockCommit(virDomainPtr dom,
     bool persistjob = false;
     bool blockdev = false;
 
-    virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW |
-                  VIR_DOMAIN_BLOCK_COMMIT_ACTIVE |
-                  VIR_DOMAIN_BLOCK_COMMIT_RELATIVE |
-                  VIR_DOMAIN_BLOCK_COMMIT_DELETE |
-                  VIR_DOMAIN_BLOCK_COMMIT_BANDWIDTH_BYTES, -1);
-
-    if (!(vm = qemuDomainObjFromDomain(dom)))
-        goto cleanup;
-    priv = vm->privateData;
-
-    if (virDomainBlockCommitEnsureACL(dom->conn, vm->def) < 0)
-        goto cleanup;
-
-    if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0)
-        goto cleanup;
-
-    if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
-        goto cleanup;
-
     if (virDomainObjCheckActive(vm) < 0)
         goto endjob;
 
@@ -18558,6 +18546,43 @@ qemuDomainBlockCommit(virDomainPtr dom,
         virErrorRestore(&orig_err);
     }
     qemuBlockJobStartupFinalize(vm, job);
+
+    return ret;
+}
+
+
+static int
+qemuDomainBlockCommit(virDomainPtr dom,
+                      const char *path,
+                      const char *base,
+                      const char *top,
+                      unsigned long bandwidth,
+                      unsigned int flags)
+{
+    virQEMUDriverPtr driver = dom->conn->privateData;
+    virDomainObjPtr vm = NULL;
+    int ret = -1;
+
+    virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW |
+                  VIR_DOMAIN_BLOCK_COMMIT_ACTIVE |
+                  VIR_DOMAIN_BLOCK_COMMIT_RELATIVE |
+                  VIR_DOMAIN_BLOCK_COMMIT_DELETE |
+                  VIR_DOMAIN_BLOCK_COMMIT_BANDWIDTH_BYTES, -1);
+
+    if (!(vm = qemuDomainObjFromDomain(dom)))
+        goto cleanup;
+
+    if (virDomainBlockCommitEnsureACL(dom->conn, vm->def) < 0)
+        goto cleanup;
+
+    if (qemuDomainSupportsCheckpointsBlockjobs(vm) < 0)
+        goto cleanup;
+
+    if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
+        goto cleanup;
+
+    ret = qemuDomainBlockCommitImpl(vm, driver, path, base, top, bandwidth, 
flags);
+
     qemuDomainObjEndJob(driver, vm);
 
  cleanup:
@@ -18565,6 +18590,7 @@ qemuDomainBlockCommit(virDomainPtr dom,
     return ret;
 }
 
+
 static int
 qemuDomainOpenGraphics(virDomainPtr dom,
                        unsigned int idx,
-- 
2.24.1

Reply via email to