Blame SOURCES/libvirt-qemu_migration_params-Avoid-deadlock-in-qemuMigrationParamsReset.patch

032100
From 0022c9aef2ecf60e9091e6df57e56065b14b67c5 Mon Sep 17 00:00:00 2001
032100
Message-Id: <0022c9aef2ecf60e9091e6df57e56065b14b67c5@dist-git>
032100
From: Jiri Denemark <jdenemar@redhat.com>
032100
Date: Thu, 28 Jul 2022 15:35:45 +0200
032100
Subject: [PATCH] qemu_migration_params: Avoid deadlock in
032100
 qemuMigrationParamsReset
032100
032100
In my recent comnmit v8.5.0-188-gc47f1abb81 I accidentally moved
032100
qemuMigrationParamsResetTLS after qemuDomainObjEnterMonitorAsync not
032100
noticing qemuMigrationParamsResetTLS will try to enter the monitor
032100
again. The second call will time out and return with a domain object
032100
locked. But we're still in monitor section and the object should be
032100
unlocked which means qemuDomainObjExitMonitor will deadlock trying to
032100
lock it again.
032100
032100
Fixes: c47f1abb81194461377a0c608a7ecd87f9ce9146
032100
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
032100
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
032100
(cherry picked from commit 8cb19a9b9a56ab6ebefc1f913c545e0bb86d4364)
032100
032100
https://bugzilla.redhat.com/show_bug.cgi?id=2107892
032100
032100
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
032100
---
032100
 src/qemu/qemu_migration_params.c | 12 +++++++++---
032100
 1 file changed, 9 insertions(+), 3 deletions(-)
032100
032100
diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c
032100
index 4a824ff5e1..4766d16e64 100644
032100
--- a/src/qemu/qemu_migration_params.c
032100
+++ b/src/qemu/qemu_migration_params.c
032100
@@ -1291,6 +1291,7 @@ qemuMigrationParamsReset(virQEMUDriver *driver,
032100
 {
032100
     virErrorPtr err;
032100
     g_autoptr(virBitmap) clearCaps = NULL;
032100
+    int rc;
032100
 
032100
     virErrorPreserveLast(&err;;
032100
 
032100
@@ -1305,11 +1306,16 @@ qemuMigrationParamsReset(virQEMUDriver *driver,
032100
 
032100
     clearCaps = virBitmapNew(0);
032100
 
032100
-    if (qemuMigrationParamsApplyCaps(vm, clearCaps) == 0 &&
032100
-        qemuMigrationParamsApplyValues(vm, origParams, false) == 0)
032100
-        qemuMigrationParamsResetTLS(driver, vm, asyncJob, origParams, apiFlags);
032100
+    rc = 0;
032100
+    if (qemuMigrationParamsApplyCaps(vm, clearCaps) < 0 ||
032100
+        qemuMigrationParamsApplyValues(vm, origParams, false) < 0)
032100
+        rc = -1;
032100
 
032100
     qemuDomainObjExitMonitor(vm);
032100
+    if (rc < 0)
032100
+        goto cleanup;
032100
+
032100
+    qemuMigrationParamsResetTLS(driver, vm, asyncJob, origParams, apiFlags);
032100
 
032100
  cleanup:
032100
     virErrorRestore(&err;;
032100
-- 
032100
2.35.1
032100