[PATCH 2/2] qemuBackupJobTerminate: Fix job termination for inactive VMs

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

 



Commit cb29e4e801d didn't take into account that the VM can be inactive
when it's destroyed. This means that the job would remain active also
when the VM became inactive.

To fix this properly:

1) Remove the bogus VM liveness check and early return
    (reverts the aforementioned commit)

2) Conditionalize the stats assignment only when the stats object is
   present
    (properly fix the crash when VM dies when reconnecting)

3) end the asyncjob only when it was already set
   (prevent corruption of priv->jobs_queued)

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1937598
Fixes: cb29e4e801d
Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---

I didn't come up with a reasonable split so that I'd avoid the
'technically' 3 changes in one patch so that it'd still make sense.

 src/qemu/qemu_backup.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c
index f6096f643f..f91d632715 100644
--- a/src/qemu/qemu_backup.c
+++ b/src/qemu/qemu_backup.c
@@ -583,27 +583,28 @@ qemuBackupJobTerminate(virDomainObjPtr vm,
         }
     }

-    if (!virDomainObjIsActive(vm))
-        return;
-
-    qemuDomainJobInfoUpdateTime(priv->job.current);
+    if (priv->job.current) {
+        qemuDomainJobInfoUpdateTime(priv->job.current);

-    g_clear_pointer(&priv->job.completed, qemuDomainJobInfoFree);
-    priv->job.completed = qemuDomainJobInfoCopy(priv->job.current);
+        g_clear_pointer(&priv->job.completed, qemuDomainJobInfoFree);
+        priv->job.completed = qemuDomainJobInfoCopy(priv->job.current);

-    priv->job.completed->stats.backup.total = priv->backup->push_total;
-    priv->job.completed->stats.backup.transferred = priv->backup->push_transferred;
-    priv->job.completed->stats.backup.tmp_used = priv->backup->pull_tmp_used;
-    priv->job.completed->stats.backup.tmp_total = priv->backup->pull_tmp_total;
+        priv->job.completed->stats.backup.total = priv->backup->push_total;
+        priv->job.completed->stats.backup.transferred = priv->backup->push_transferred;
+        priv->job.completed->stats.backup.tmp_used = priv->backup->pull_tmp_used;
+        priv->job.completed->stats.backup.tmp_total = priv->backup->pull_tmp_total;

-    priv->job.completed->status = jobstatus;
-    priv->job.completed->errmsg = g_strdup(priv->backup->errmsg);
+        priv->job.completed->status = jobstatus;
+        priv->job.completed->errmsg = g_strdup(priv->backup->errmsg);

-    qemuDomainEventEmitJobCompleted(priv->driver, vm);
+        qemuDomainEventEmitJobCompleted(priv->driver, vm);
+    }

     virDomainBackupDefFree(priv->backup);
     priv->backup = NULL;
-    qemuDomainObjEndAsyncJob(priv->driver, vm);
+
+    if (priv->job.asyncJob == QEMU_ASYNC_JOB_BACKUP)
+        qemuDomainObjEndAsyncJob(priv->driver, vm);
 }


-- 
2.29.2




[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