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

Michal Privoznik posted 3 patches 6 years, 5 months ago
[libvirt] [PATCH for 5.7.0 1/3] qemu_blockjob: Move active commit failed state handling into a function
Posted by Michal Privoznik 6 years, 5 months ago
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>
---
 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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH for 5.7.0 1/3] qemu_blockjob: Move active commit failed state handling into a function
Posted by Peter Krempa 6 years, 5 months ago
On Fri, Aug 30, 2019 at 15:19:06 +0200, Michal Privoznik wrote:
> 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>
> ---
>  src/qemu/qemu_blockjob.c | 19 +++++++++++++++----
>  1 file changed, 15 insertions(+), 4 deletions(-)

ACK
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list