[PATCH v2] qemu: fix locking in qemuProcessHandleMemoryFailure

Thomas Prescher posted 1 patch 3 weeks, 3 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20260108140303.165678-1-thomas.prescher@cyberus-technology.de
src/qemu/qemu_process.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
[PATCH v2] qemu: fix locking in qemuProcessHandleMemoryFailure
Posted by Thomas Prescher 3 weeks, 3 days ago
Fix locking in qemuProcessHandleMemoryFailure. We use a lock guard
now because we can directly return from the default switch cases.

Issue has been discovered by johannes.kulik@sap.com

On-behalf-of: SAP thomas.prescher@sap.com
Signed-off-by: Thomas Prescher <thomas.prescher@cyberus-technology.de>
---
 src/qemu/qemu_process.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 4e1d713809..a53bb40783 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1939,8 +1939,8 @@ qemuProcessHandleMemoryFailure(qemuMonitor *mon G_GNUC_UNUSED,
     virDomainMemoryFailureRecipientType recipient;
     virDomainMemoryFailureActionType action;
     unsigned int flags = 0;
+    VIR_LOCK_GUARD lock = virObjectLockGuard(vm);
 
-    virObjectLock(vm);
     driver = QEMU_DOMAIN_PRIVATE(vm)->driver;
 
     switch (mfp->recipient) {
@@ -1980,8 +1980,6 @@ qemuProcessHandleMemoryFailure(qemuMonitor *mon G_GNUC_UNUSED,
 
     event = virDomainEventMemoryFailureNewFromObj(vm, recipient, action, flags);
 
-    virObjectUnlock(vm);
-
     virObjectEventStateQueue(driver->domainEventState, event);
 }
 
-- 
2.52.0
Re: [PATCH v2] qemu: fix locking in qemuProcessHandleMemoryFailure
Posted by Michal Prívozník via Devel 3 weeks, 2 days ago
On 1/8/26 15:03, Thomas Prescher wrote:
> Fix locking in qemuProcessHandleMemoryFailure. We use a lock guard
> now because we can directly return from the default switch cases.
> 
> Issue has been discovered by johannes.kulik@sap.com
> 
> On-behalf-of: SAP thomas.prescher@sap.com
> Signed-off-by: Thomas Prescher <thomas.prescher@cyberus-technology.de>
> ---
>  src/qemu/qemu_process.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)

Ah, sorry. Should have been more specific in my earlier review. When I
gave this my Reviewed-by I also pushed it:

https://gitlab.com/libvirt/libvirt/-/commit/871a8f872d434c21c7e8f339e4a9d49e230daa58

Michal