]> git.ipfire.org Git - thirdparty/libvirt.git/commit
libxl: fix ref counting of libxlMigrationDstArgs
authorJim Fehlig <jfehlig@suse.com>
Wed, 15 Jul 2015 22:35:50 +0000 (16:35 -0600)
committerJim Fehlig <jfehlig@suse.com>
Thu, 27 Aug 2015 21:51:03 +0000 (15:51 -0600)
commit44a54eb073d2ae52ebf1661ae73bb1f0f98599f9
treed92754227234279a9154d93173089a4c6bbfc03b
parentc63b088035d240ffa8156a284a15955819ba1017
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>
src/libxl/libxl_migration.c