[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V1 01/26] migration: cpr helpers
From: |
Steve Sistare |
Subject: |
[PATCH V1 01/26] migration: cpr helpers |
Date: |
Wed, 29 Jan 2025 06:42:57 -0800 |
Add the cpr_needed_for_reuse and cpr_resave_fd helpers, for use when
adding cpr support for vfio and iommufd.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
include/migration/cpr.h | 3 +++
migration/cpr.c | 21 +++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/include/migration/cpr.h b/include/migration/cpr.h
index 3a6deb7..faeb0cc 100644
--- a/include/migration/cpr.h
+++ b/include/migration/cpr.h
@@ -18,6 +18,7 @@
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);
+void cpr_resave_fd(const char *name, int id, int fd);
MigMode cpr_get_incoming_mode(void);
void cpr_set_incoming_mode(MigMode mode);
@@ -27,6 +28,8 @@ int cpr_state_load(MigrationChannel *channel, Error **errp);
void cpr_state_close(void);
struct QIOChannel *cpr_state_ioc(void);
+bool cpr_needed_for_reuse(void *opaque);
+
QEMUFile *cpr_transfer_output(MigrationChannel *channel, Error **errp);
QEMUFile *cpr_transfer_input(MigrationChannel *channel, Error **errp);
diff --git a/migration/cpr.c b/migration/cpr.c
index 584b0b9..e3f27e9 100644
--- a/migration/cpr.c
+++ b/migration/cpr.c
@@ -95,6 +95,21 @@ int cpr_find_fd(const char *name, int id)
trace_cpr_find_fd(name, id, fd);
return fd;
}
+
+void cpr_resave_fd(const char *name, int id, int fd)
+{
+ CprFd *elem = find_fd(&cpr_state.fds, name, id);
+ int old_fd = elem ? elem->fd : -1;
+
+ if (old_fd < 0) {
+ cpr_save_fd(name, id, fd);
+ } else if (old_fd != fd) {
+ error_setg(&error_fatal,
+ "internal error: cpr fd '%s' id %d value %d "
+ "already saved with a different value %d",
+ name, id, fd, old_fd);
+ }
+}
/*************************************************************************/
#define CPR_STATE "CprState"
@@ -222,3 +237,9 @@ void cpr_state_close(void)
cpr_state_file = NULL;
}
}
+
+bool cpr_needed_for_reuse(void *opaque)
+{
+ MigMode mode = migrate_mode();
+ return mode == MIG_MODE_CPR_TRANSFER;
+}
--
1.8.3.1
- [PATCH V1 00/26] Live update: vfio and iommufd, Steve Sistare, 2025/01/29
- [PATCH V1 01/26] migration: cpr helpers,
Steve Sistare <=
- [PATCH V1 06/26] vfio/container: preserve DMA mappings, Steve Sistare, 2025/01/29
- [PATCH V1 04/26] vfio/container: register container for cpr, Steve Sistare, 2025/01/29
- [PATCH V1 02/26] migration: lower handler priority, Steve Sistare, 2025/01/29
- [PATCH V1 07/26] vfio/container: recover from unmap-all-vaddr failure, Steve Sistare, 2025/01/29
- [PATCH V1 11/26] vfio-pci: skip reset during cpr, Steve Sistare, 2025/01/29
- [PATCH V1 03/26] vfio: vfio_find_ram_discard_listener, Steve Sistare, 2025/01/29
- [PATCH V1 20/26] vfio/iommufd: export iommufd_cdev_get_info_iova_range, Steve Sistare, 2025/01/29
- [PATCH V1 08/26] pci: skip reset during cpr, Steve Sistare, 2025/01/29
- [PATCH V1 05/26] vfio/container: preserve descriptors, Steve Sistare, 2025/01/29
- [PATCH V1 09/26] pci: export msix_is_pending, Steve Sistare, 2025/01/29