]> git.proxmox.com Git - mirror_qemu.git/commit - block/nbd-client.c
nbd: make it thread-safe, fix qcow2 over nbd
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 1 Jun 2017 10:44:56 +0000 (12:44 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 7 Jun 2017 16:22:02 +0000 (18:22 +0200)
commit6bdcc018a6ed760b9dfe43539124e420aed83092
tree28864efb950ffa58600716b6890f1eb672cd6542
parentb8158192fadb3e346372456c25cbbc4be584a85c
nbd: make it thread-safe, fix qcow2 over nbd

NBD is not thread safe, because it accesses s->in_flight without
a CoMutex.  Fixing this will be required for multiqueue.
CoQueue doesn't have spurious wakeups but, when another coroutine can
run between qemu_co_queue_next's wakeup and qemu_co_queue_wait's
re-locking of the mutex, the wait condition can become false and
a loop is necessary.

In fact, it turns out that the loop is necessary even without this
multi-threaded scenario.  A particular sequence of coroutine wakeups
is happening ~80% of the time when starting a guest with qcow2 image
served over NBD (i.e. qemu-nbd --format=raw, and QEMU's -drive option
has -format=qcow2).  This patch fixes that issue too.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block/nbd-client.c