From: Steve Sistare <[email protected]> Add the cpr_delete_fd_all function to delete all fds associated with a device.
Signed-off-by: Steve Sistare <[email protected]> Signed-off-by: Ben Chaney <[email protected]> --- include/migration/cpr.h | 1 + migration/cpr.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/migration/cpr.h b/include/migration/cpr.h index 027cb98073..d585fadc5b 100644 --- a/include/migration/cpr.h +++ b/include/migration/cpr.h @@ -29,6 +29,7 @@ extern CprState cpr_state; void cpr_save_fd(const char *name, int id, int fd); void cpr_delete_fd(const char *name, int id); +void cpr_delete_fd_all(const char *name); int cpr_find_fd(const char *name, int id); void cpr_resave_fd(const char *name, int id, int fd); int cpr_open_fd(const char *path, int flags, const char *name, int id, diff --git a/migration/cpr.c b/migration/cpr.c index adee2a919a..c0bf93a7ba 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -85,6 +85,19 @@ void cpr_delete_fd(const char *name, int id) trace_cpr_delete_fd(name, id); } +void cpr_delete_fd_all(const char *name) +{ + CprFd *elem, *next_elem; + + QLIST_FOREACH_SAFE(elem, &cpr_state.fds, next, next_elem) { + if (!strcmp(elem->name, name)) { + QLIST_REMOVE(elem, next); + g_free(elem->name); + g_free(elem); + } + } +} + int cpr_find_fd(const char *name, int id) { CprFd *elem = find_fd(&cpr_state.fds, name, id); -- 2.34.1
