• J
    qemu: Avoid calling qemuProcessStop without a job · 81f50cb9
    Jiri Denemark 提交于
    Calling qemuProcessStop without a job opens a way to race conditions
    with qemuDomainObjExitMonitor called in another thread. A real world
    example of such a race condition:
    
      - migration thread (A) calls qemuMigrationWaitForSpice
      - another thread (B) starts processing qemuDomainAbortJob API
      - thread B signals thread A via qemuDomainObjAbortAsyncJob
      - thread B enters monitor (qemuDomainObjEnterMonitor)
      - thread B calls qemuMonitorSend
      - thread A awakens and calls qemuProcessStop
      - thread A calls qemuMonitorClose and sets priv->mon to NULL
      - thread B calls qemuDomainObjExitMonitor with priv->mon == NULL
      => monitor stays ref'ed and locked
    
    Depending on how lucky we are, the race may result in a memory leak or
    it can even deadlock libvirtd's event loop if it tries to lock the
    monitor to process an event received before qemuMonitorClose was called.
    Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
    81f50cb9
qemu_process.h 7.0 KB