[PATCH 3/3] qemu: agent: take monitor lock in qemuAgentNotifyEvent

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

 



qemuAgentNotifyEvent notify on a lock condition without taking
the lock. This works but it is a subject to race conditions.
---
 src/qemu/qemu_agent.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 5230cbc..ad031d0 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1248,6 +1248,8 @@ qemuAgentMakeStringsArray(const char **strings, unsigned int len)
 void qemuAgentNotifyEvent(qemuAgentPtr mon,
                           qemuAgentEvent event)
 {
+    virObjectLock(mon);
+
     VIR_DEBUG("mon=%p event=%d await_event=%d", mon, event, mon->await_event);
     if (mon->await_event == event) {
         mon->await_event = QEMU_AGENT_EVENT_NONE;
@@ -1257,6 +1259,8 @@ void qemuAgentNotifyEvent(qemuAgentPtr mon,
             virCondSignal(&mon->notify);
         }
     }
+
+    virObjectUnlock(mon);
 }
 
 VIR_ENUM_DECL(qemuAgentShutdownMode);
-- 
1.8.3.1

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



[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