qemu/migration
Denis V. Lunev 60be634079 migration: fix deadlock
Release qemu global mutex before call synchronize_rcu().
synchronize_rcu() waiting for all readers to finish their critical
sections. There is at least one critical section in which we try
to get QGM (critical section is in address_space_rw() and
prepare_mmio_access() is trying to aquire QGM).

Both functions (migration_end() and migration_bitmap_extend())
are called from main thread which is holding QGM.

Thus there is a race condition that ends up with deadlock:
main thread     working thread
Lock QGA                |
|             Call KVM_EXIT_IO handler
|                       |
|        Open rcu reader's critical section
Migration cleanup bh    |
|                       |
synchronize_rcu() is    |
waiting for readers     |
|            prepare_mmio_access() is waiting for QGM
  \                   /
         deadlock

The patch changes bitmap freeing from direct g_free after synchronize_rcu
to free inside call_rcu.

Signed-off-by: Denis V. Lunev <den@openvz.org>
Reported-by: Igor Redko <redkoi@virtuozzo.com>
Tested-by: Igor Redko <redkoi@virtuozzo.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>

CC: Anna Melekhova <annam@virtuozzo.com>
CC: Juan Quintela <quintela@redhat.com>
CC: Amit Shah <amit.shah@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Wen Congyang <wency@cn.fujitsu.com>
2015-10-15 08:14:13 +02:00
..
block.c block: Use bdrv_drain to replace uncessary bdrv_drain_all 2015-07-07 14:27:14 +01:00
exec.c Change qemu_set_fd_handler2(..., NULL, ...) to qemu_set_fd_handler 2015-06-12 13:26:21 +01:00
fd.c Change qemu_set_fd_handler2(..., NULL, ...) to qemu_set_fd_handler 2015-06-12 13:26:21 +01:00
Makefile.objs Split the QEMU buffered file code out 2014-12-16 17:47:36 +05:30
migration.c migration: announce VM's new home just before VM is runnable 2015-10-15 08:13:03 +02:00
qemu-file-buf.c migration: Use g_new() & friends where that makes obvious sense 2015-09-29 11:36:35 +05:30
qemu-file-internal.h Split struct QEMUFile out 2014-12-16 17:47:36 +05:30
qemu-file-stdio.c migration: Use g_new() & friends where that makes obvious sense 2015-09-29 11:36:35 +05:30
qemu-file-unix.c migration: Use g_new() & friends where that makes obvious sense 2015-09-29 11:36:35 +05:30
qemu-file.c migration: Use g_new() & friends where that makes obvious sense 2015-09-29 11:36:35 +05:30
ram.c migration: fix deadlock 2015-10-15 08:14:13 +02:00
rdma.c migration: Use g_new() & friends where that makes obvious sense 2015-09-29 11:36:35 +05:30
savevm.c migration: Use g_new() & friends where that makes obvious sense 2015-09-29 11:36:35 +05:30
tcp.c Change qemu_set_fd_handler2(..., NULL, ...) to qemu_set_fd_handler 2015-06-12 13:26:21 +01:00
unix.c Change qemu_set_fd_handler2(..., NULL, ...) to qemu_set_fd_handler 2015-06-12 13:26:21 +01:00
vmstate.c vmstate: Create optional sections 2015-07-07 14:54:52 +02:00
xbzrle.c Start migrating migration code into a migration directory 2014-12-16 17:47:36 +05:30