aboutsummaryrefslogtreecommitdiff
path: root/hw/rdma/rdma_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/rdma/rdma_utils.c')
-rw-r--r--hw/rdma/rdma_utils.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/hw/rdma/rdma_utils.c b/hw/rdma/rdma_utils.c
index b9f07fcda7..0a8abe572d 100644
--- a/hw/rdma/rdma_utils.c
+++ b/hw/rdma/rdma_utils.c
@@ -14,6 +14,8 @@
*/
#include "qemu/osdep.h"
+#include "qapi/qmp/qlist.h"
+#include "qapi/qmp/qnum.h"
#include "trace.h"
#include "rdma_utils.h"
@@ -51,3 +53,40 @@ void rdma_pci_dma_unmap(PCIDevice *dev, void *buffer, dma_addr_t len)
pci_dma_unmap(dev, buffer, len, DMA_DIRECTION_TO_DEVICE, 0);
}
}
+
+void rdma_protected_qlist_init(RdmaProtectedQList *list)
+{
+ qemu_mutex_init(&list->lock);
+ list->list = qlist_new();
+}
+
+void rdma_protected_qlist_destroy(RdmaProtectedQList *list)
+{
+ if (list->list) {
+ qlist_destroy_obj(QOBJECT(list->list));
+ qemu_mutex_destroy(&list->lock);
+ list->list = NULL;
+ }
+}
+
+void rdma_protected_qlist_append_int64(RdmaProtectedQList *list, int64_t value)
+{
+ qemu_mutex_lock(&list->lock);
+ qlist_append_int(list->list, value);
+ qemu_mutex_unlock(&list->lock);
+}
+
+int64_t rdma_protected_qlist_pop_int64(RdmaProtectedQList *list)
+{
+ QObject *obj;
+
+ qemu_mutex_lock(&list->lock);
+ obj = qlist_pop(list->list);
+ qemu_mutex_unlock(&list->lock);
+
+ if (!obj) {
+ return -ENOENT;
+ }
+
+ return qnum_get_uint(qobject_to(QNum, obj));
+}