[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC V1 04/12] migration: cpr_find_fd_any
From: |
Steve Sistare |
Subject: |
[RFC V1 04/12] migration: cpr_find_fd_any |
Date: |
Sat, 20 Jul 2024 12:15:29 -0700 |
Add a function for finding a CPR fd by name, for any value of id, and
return the id.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
include/migration/cpr.h | 1 +
migration/cpr.c | 15 +++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/include/migration/cpr.h b/include/migration/cpr.h
index bfd9864..c9e6111 100644
--- a/include/migration/cpr.h
+++ b/include/migration/cpr.h
@@ -19,6 +19,7 @@ typedef int (*cpr_walk_fd_cb)(int fd);
void cpr_save_fd(const char *name, int id, int fd);
void cpr_delete_fd(const char *name, int id);
int cpr_find_fd(const char *name, int id);
+int cpr_find_fd_any(const char *name, int *id_p);
int cpr_walk_fd(cpr_walk_fd_cb cb);
void cpr_resave_fd(const char *name, int id, int fd);
diff --git a/migration/cpr.c b/migration/cpr.c
index 853d3a1..096e8d8 100644
--- a/migration/cpr.c
+++ b/migration/cpr.c
@@ -109,6 +109,21 @@ int cpr_find_fd(const char *name, int id)
return fd;
}
+int cpr_find_fd_any(const char *name, int *id_p)
+{
+ CprFd *elem;
+
+ QLIST_FOREACH(elem, &cpr_state.fds, next) {
+ if (!strcmp(elem->name, name)) {
+ trace_cpr_find_fd(name, elem->id, elem->fd);
+ *id_p = elem->id;
+ return elem->fd;
+ }
+ }
+ trace_cpr_find_fd(name, -1, -1);
+ return -1;
+}
+
int cpr_walk_fd(cpr_walk_fd_cb cb)
{
CprFd *elem;
--
1.8.3.1
- [RFC V1 10/12] migration/ram: old host address, (continued)
- [RFC V1 10/12] migration/ram: old host address, Steve Sistare, 2024/07/20
- [RFC V1 07/12] iommufd: change_process kernel interface, Steve Sistare, 2024/07/20
- [RFC V1 05/12] iommufd: preserve device fd, Steve Sistare, 2024/07/20
- [RFC V1 02/12] iommufd: no DMA to BARs, Steve Sistare, 2024/07/20
- [RFC V1 08/12] vfio/iommufd: register container for cpr, Steve Sistare, 2024/07/20
- [RFC V1 03/12] iommufd: pass name to connect, Steve Sistare, 2024/07/20
- [RFC V1 09/12] vfio/iommufd: rebuild device, Steve Sistare, 2024/07/20
- [RFC V1 12/12] vfio: mdev blocker, Steve Sistare, 2024/07/20
- [RFC V1 06/12] iommufd: export iommufd_cdev_get_info_iova_range, Steve Sistare, 2024/07/20
- [RFC V1 11/12] iommufd: update DMA virtual addresses, Steve Sistare, 2024/07/20
- [RFC V1 04/12] migration: cpr_find_fd_any,
Steve Sistare <=
- [RFC V1 01/12] vfio: move cpr_exec_notifier, Steve Sistare, 2024/07/20