mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03:55 -06:00
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>
This commit is contained in:
parent
b20fc79510
commit
2cfa953009
3 changed files with 7 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue