[PATCH] qemu: agent: Reset agentError when qemuConnectAgent success

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

 



qemuAgentClose and qemuAgentIO have race condition,
as follows:

main thread:                          second thread:
virEventPollRunOnce                processSerialChangedEvent
  virEventPollDispatchHandles
    virMutexUnlock(&eventLoop.lock)
                                      qemuAgentClose
                                        virObjectLock(mon)
                                        virEventRemoveHandle
                                        VIR_FORCE_CLOSE(mon->fd)
                                        virObjectUnlock(mon)
                                      priv->agentError = false
    qemuAgentIO
      virObjectLock(mon)
        mon->fd != fd --> error = true
        qemuProcessHandleAgentError
          priv->agentError = true
      virObjectUnlock(mon)
    virMutexLock(&eventLoop.lock)

qemuAgentClose set the mon->fd to '-1', and then qemuAgentIO
check the mon->fd not equals to fd that registered before.
qemuProcessHandleAgentError will be called to set
priv->agentError to 'true', then the priv->agentError is
always 'true' except restart libvirtd or restart
qemu-guest-agent process in guest. We can't send any
qemu-agent-command anymore even if qemuConnectAgent return
success later.

This is accidently occurs when hot-add-vcpu in windows2012.
  virsh setvcpus ...
  virsh qemu-agent-command $vm '{"execute":"guest-get-vcpus"}'

Reset the priv->agentError to 'false' when qemuConnectAgent sucess
to fix this problem.

Signed-off-by: Wang Yechao <wang.yechao255@xxxxxxxxxx>
---
 src/qemu/qemu_process.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 29b0ba1..4fbb955 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -269,6 +269,7 @@ qemuConnectAgent(virQEMUDriverPtr driver, virDomainObjPtr vm)
         virResetLastError();
     }
 
+    priv->agentError = false;
     return 0;
 }
 
-- 
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