• D
    Fix reference handling leak on qemuMonitor · c2121602
    Daniel P. Berrange 提交于
    The current code pattern requires that callers of qemuMonitorClose
    check for the return value == 0, and if so, set priv->mon = NULL
    and release the reference held on the associated virDomainObjPtr
    
    The change d84bb6d6 violated that
    requirement, meaning that priv->mon never gets set to NULL, and
    a reference count is leaked on virDomainObjPtr.
    
    This design was a bad one, so remove the need to check the return
    valueof qemuMonitorClose(). Instead allow registration of a
    callback that's invoked just when the last reference on qemuMonitorPtr
    is released.
    
    Finally there was a potential reference leak in qemuConnectMonitor
    in the failure path.
    
    * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add a destroy
      callback invoked from qemuMonitorFree
    * src/qemu/qemu_driver.c: Use the destroy callback to release the
      reference on virDomainObjPtr when the monitor is freed. Fix other
      potential reference count leak in connecting to monitor
    c2121602
qemu_driver.c 374.7 KB