[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC 16/26] migration: Add save_live_complete_precopy_async{, wait
From: |
Maciej S. Szmigiero |
Subject: |
[PATCH RFC 16/26] migration: Add save_live_complete_precopy_async{, wait} handlers |
Date: |
Tue, 16 Apr 2024 16:42:55 +0200 |
From: "Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>
These SaveVMHandlers allow device to provide its own asynchronous
transmission of the remaining data at the end of a precopy phase.
The save_live_complete_precopy_async handler is supposed to start such
transmission (for example, by launching appropriate threads) while the
save_live_complete_precopy_async_wait handler is supposed to wait until
such transfer has finished (for example, until the sending threads
have exited).
Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
---
include/migration/register.h | 31 +++++++++++++++++++++++++++++++
migration/savevm.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+)
diff --git a/include/migration/register.h b/include/migration/register.h
index d7b70a8be68c..9d36e35bd612 100644
--- a/include/migration/register.h
+++ b/include/migration/register.h
@@ -102,6 +102,37 @@ typedef struct SaveVMHandlers {
*/
int (*save_live_complete_precopy)(QEMUFile *f, void *opaque);
+ /**
+ * @save_live_complete_precopy_async
+ *
+ * Arranges for handler-specific asynchronous transmission of the
+ * remaining data at the end of a precopy phase. When postcopy is
+ * enabled, devices that support postcopy will skip this step.
+ *
+ * @f: QEMUFile where the handler can synchronously send data before
returning
+ * @idstr: this device section idstr
+ * @instance_id: this device section instance_id
+ * @opaque: data pointer passed to register_savevm_live()
+ *
+ * Returns zero to indicate success and negative for error
+ */
+ int (*save_live_complete_precopy_async)(QEMUFile *f,
+ char *idstr, uint32_t instance_id,
+ void *opaque);
+ /**
+ * @save_live_complete_precopy_async_wait
+ *
+ * Waits for the asynchronous transmission started by the of the
+ * @save_live_complete_precopy_async handler to complete.
+ * When postcopy is enabled, devices that support postcopy will skip this
step.
+ *
+ * @f: QEMUFile where the handler can synchronously send data before
returning
+ * @opaque: data pointer passed to register_savevm_live()
+ *
+ * Returns zero to indicate success and negative for error
+ */
+ int (*save_live_complete_precopy_async_wait)(QEMUFile *f, void *opaque);
+
/* This runs both outside and inside the BQL. */
/**
diff --git a/migration/savevm.c b/migration/savevm.c
index 388d7af7cdd8..fa35504678bf 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -1497,6 +1497,27 @@ int qemu_savevm_state_complete_precopy_iterable(QEMUFile
*f, bool in_postcopy)
SaveStateEntry *se;
int ret;
+ QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
+ if (!se->ops || (in_postcopy && se->ops->has_postcopy &&
+ se->ops->has_postcopy(se->opaque)) ||
+ !se->ops->save_live_complete_precopy_async) {
+ continue;
+ }
+
+ save_section_header(f, se, QEMU_VM_SECTION_END);
+
+ ret = se->ops->save_live_complete_precopy_async(f,
+ se->idstr,
se->instance_id,
+ se->opaque);
+
+ save_section_footer(f, se);
+
+ if (ret < 0) {
+ qemu_file_set_error(f, ret);
+ return -1;
+ }
+ }
+
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
if (!se->ops ||
(in_postcopy && se->ops->has_postcopy &&
@@ -1528,6 +1549,20 @@ int qemu_savevm_state_complete_precopy_iterable(QEMUFile
*f, bool in_postcopy)
end_ts_each - start_ts_each);
}
+ QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
+ if (!se->ops || (in_postcopy && se->ops->has_postcopy &&
+ se->ops->has_postcopy(se->opaque)) ||
+ !se->ops->save_live_complete_precopy_async_wait) {
+ continue;
+ }
+
+ ret = se->ops->save_live_complete_precopy_async_wait(f, se->opaque);
+ if (ret < 0) {
+ qemu_file_set_error(f, ret);
+ return -1;
+ }
+ }
+
trace_vmstate_downtime_checkpoint("src-iterable-saved");
return 0;
- [PATCH RFC 06/26] multifd: pass MFDSendChannelConnectData when connecting sending socket, (continued)
- [PATCH RFC 06/26] multifd: pass MFDSendChannelConnectData when connecting sending socket, Maciej S. Szmigiero, 2024/04/16
- [PATCH RFC 07/26] migration/postcopy: pass PostcopyPChannelConnectData when connecting sending preempt socket, Maciej S. Szmigiero, 2024/04/16
- [PATCH RFC 09/26] migration: Add send/receive header for postcopy preempt channel, Maciej S. Szmigiero, 2024/04/16
- [PATCH RFC 08/26] migration: Allow passing migration header in migration channel creation, Maciej S. Szmigiero, 2024/04/16
- [PATCH RFC 10/26] migration: Add send/receive header for multifd channel, Maciej S. Szmigiero, 2024/04/16
- [PATCH RFC 11/26] migration/options: Mapped-ram is not channel header compatible, Maciej S. Szmigiero, 2024/04/16
- [PATCH RFC 12/26] migration: Enable x-channel-header pseudo-capability, Maciej S. Szmigiero, 2024/04/16
- [PATCH RFC 13/26] vfio/migration: Add save_{iterate, complete_precopy}_started trace events, Maciej S. Szmigiero, 2024/04/16
- [PATCH RFC 14/26] migration/ram: Add load start trace event, Maciej S. Szmigiero, 2024/04/16
- [PATCH RFC 15/26] migration/multifd: Zero p->flags before starting filling a packet, Maciej S. Szmigiero, 2024/04/16
- [PATCH RFC 16/26] migration: Add save_live_complete_precopy_async{, wait} handlers,
Maciej S. Szmigiero <=
- [PATCH RFC 18/26] migration: Add load_finish handler and associated functions, Maciej S. Szmigiero, 2024/04/16
- [PATCH RFC 17/26] migration: Add qemu_loadvm_load_state_buffer() and its handler, Maciej S. Szmigiero, 2024/04/16
- [PATCH RFC 22/26] migration/multifd: Convert multifd_send_pages::next_channel to atomic, Maciej S. Szmigiero, 2024/04/16
- [PATCH RFC 21/26] migration/multifd: Device state transfer support - receive side, Maciej S. Szmigiero, 2024/04/16
- [PATCH RFC 25/26] vfio/migration: Multifd device state transfer support - receive side, Maciej S. Szmigiero, 2024/04/16
- [PATCH RFC 23/26] migration/multifd: Device state transfer support - send side, Maciej S. Szmigiero, 2024/04/16
- [PATCH RFC 19/26] migration: Add x-multifd-channels-device-state parameter, Maciej S. Szmigiero, 2024/04/16
- [PATCH RFC 20/26] migration: Add MULTIFD_DEVICE_STATE migration channel type, Maciej S. Szmigiero, 2024/04/16
- [PATCH RFC 24/26] migration/multifd: Add migration_has_device_state_support(), Maciej S. Szmigiero, 2024/04/16