44a54eb libxl: fix ref counting of libxlMigrationDstArgs

Authored and Committed by Jim Fehlig 8 years ago
    libxl: fix ref counting of libxlMigrationDstArgs
    
    This patch fixes some flawed logic around ref counting the
    libxlMigrationDstArgs object.
    
    First, when adding sockets to the event loop with
    virNetSocketAddIOCallback(), the generic virObjectFreeCallback()
    was registered as a free function, with libxlMigrationDstArgs as
    its parameter. A reference was also taken on
    libxlMigrationDstArgs for each successful call to
    virNetSocketAddIOCallback(). The rational behind this logic was
    that the libxlMigrationDstArgs object had to out-live the socket
    objects. But virNetSocketAddIOCallback() already takes a
    reference on socket objects, ensuring their life until removed
    from the event loop and unref'ed in virNetSocketEventFree(). We
    only need to ensure libxlMigrationDstArgs lives until
    libxlDoMigrateReceive() finishes, which can be done by simply
    unref'ing libxlMigrationDstArgs at the end of
    libxlDoMigrateReceive().
    
    The second flaw was unref'ing the sockets in the failure path of
    libxlMigrateReceive() and at the end of libxlDoMigrateReceive().
    As mentioned above, the sockets are already unref'ed by
    virNetSocketEventFree() when removed from the event loop.
    Attempting to unref the socket a second time resulted in a
    libvirtd crash since the socket was previously unref'ed and
    disposed.
    
    Signed-off-by: Jim Fehlig <jfehlig@suse.com>
    
        
file modified
+6 -14