diff options
author | Yuval Shaia <yuval.shaia@oracle.com> | 2019-03-11 03:29:07 -0700 |
---|---|---|
committer | Marcel Apfelbaum <marcel.apfelbaum@gmail.com> | 2019-03-16 15:52:44 +0200 |
commit | 2cfa95300908f401f5b9bdf3de734cf6228a2722 (patch) | |
tree | c1b3ef94eb46a9a8f205bd22b5f9757ed9000859 /hw/rdma/rdma_backend.c | |
parent | b20fc7951084bb77e867d114c916e409c3a6821a (diff) | |
download | qemu-2cfa95300908f401f5b9bdf3de734cf6228a2722.zip qemu-2cfa95300908f401f5b9bdf3de734cf6228a2722.tar.gz qemu-2cfa95300908f401f5b9bdf3de734cf6228a2722.tar.bz2 |
hw/rdma: Protect against concurrent execution of poll_cq
The function rdma_poll_cq is called from two contexts - completion
handler thread which sense new completion on backend channel and
explicitly as result of guest issuing poll_cq command.
Add lock to protect against concurrent executions.
Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
Reviewed-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Message-Id: <1552300155-25216-4-git-send-email-yuval.shaia@oracle.com>
Reviewed-by: Kamal Heib <kamalheib1@gmail.com>
Signed-off-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Diffstat (limited to 'hw/rdma/rdma_backend.c')
-rw-r--r-- | hw/rdma/rdma_backend.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c index 37edf42..1897540 100644 --- a/hw/rdma/rdma_backend.c +++ b/hw/rdma/rdma_backend.c @@ -70,6 +70,7 @@ static void rdma_poll_cq(RdmaDeviceResources *rdma_dev_res, struct ibv_cq *ibcq) BackendCtx *bctx; struct ibv_wc wc[2]; + qemu_mutex_lock(&rdma_dev_res->lock); do { ne = ibv_poll_cq(ibcq, ARRAY_SIZE(wc), wc); @@ -89,6 +90,7 @@ static void rdma_poll_cq(RdmaDeviceResources *rdma_dev_res, struct ibv_cq *ibcq) g_free(bctx); } } while (ne > 0); + qemu_mutex_unlock(&rdma_dev_res->lock); if (ne < 0) { rdma_error_report("ibv_poll_cq fail, rc=%d, errno=%d", ne, errno); |