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

[libvirt] [PATCH for 5.7.0 v2 1/3] qemu_blockjob: Move active commit failed state handling into a function



Currently, there are only a few lines of code so a separate
function was not necessary, but this will change. So instead of
putting all the new code under 'case
QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT' create a separate function.
Just like every other case has one.

Signed-off-by: Michal Privoznik <mprivozn redhat com>
ACKed-by: Peter Krempa <pkrempa redhat com>
---
 src/qemu/qemu_blockjob.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 3003e9c518..c77a129bfc 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -1121,6 +1121,20 @@ qemuBlockJobProcessEventConcludedCopyAbort(virQEMUDriverPtr driver,
 }
 
 
+static void
+qemuBlockJobProcessEventFailedActiveCommit(virDomainObjPtr vm,
+                                           qemuBlockJobDataPtr job)
+{
+    VIR_DEBUG("active commit job '%s' on VM '%s' failed", job->name, vm->def->name);
+
+    if (!job->disk)
+        return;
+
+    virObjectUnref(job->disk->mirror);
+    job->disk->mirror = NULL;
+}
+
+
 static void
 qemuBlockJobProcessEventConcludedCreate(virQEMUDriverPtr driver,
                                         virDomainObjPtr vm,
@@ -1211,10 +1225,7 @@ qemuBlockJobEventProcessConcludedTransition(qemuBlockJobDataPtr job,
             break;
 
         case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT:
-            if (job->disk) {
-                virObjectUnref(job->disk->mirror);
-                job->disk->mirror = NULL;
-            }
+            qemuBlockJobProcessEventFailedActiveCommit(vm, job);
             break;
 
         case QEMU_BLOCKJOB_TYPE_CREATE:
-- 
2.21.0


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