[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 11/46] Return path: Send responses from destination
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PATCH 11/46] Return path: Send responses from destination to source |
Date: |
Fri, 4 Jul 2014 18:41:22 +0100 |
From: "Dr. David Alan Gilbert" <address@hidden>
Add migrate_send_rp_message to send a message from destination to source along
the return path.
(It uses a mutex to let it be called from multiple threads)
Add migrate_send_rp_ack to send an 'ack' message
Use it in the CMD_REQACK handler
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
include/migration/migration.h | 15 +++++++++++++++
migration.c | 27 +++++++++++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/include/migration/migration.h b/include/migration/migration.h
index 0e21c5d..375efec 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -40,6 +40,12 @@ struct MigrationParams {
bool shared;
};
+/* Commands sent on the return path from destination to source*/
+enum mig_rpcomm_cmd {
+ MIG_RPCOMM_INVALID = 0, /* Must be 0 */
+ MIG_RPCOMM_ACK, /* data (seq: be32 ) */
+ MIG_RPCOMM_AFTERLASTVALID
+};
typedef struct MigrationState MigrationState;
/* State for the incoming migration */
@@ -47,6 +53,7 @@ struct MigrationIncomingState {
QEMUFile *file;
QEMUFile *return_path;
+ QemuMutex rp_mutex; /* We send replies from multiple threads */
};
MigrationIncomingState *migration_incoming_state_init(QEMUFile *f);
@@ -167,6 +174,14 @@ int64_t migrate_xbzrle_cache_size(void);
int64_t xbzrle_cache_resize(int64_t new_size);
+/* Sending on the return path - generic and then for each message type */
+void migrate_send_rp_message(MigrationIncomingState *mis,
+ enum mig_rpcomm_cmd cmd,
+ uint16_t len, uint8_t *data);
+void migrate_send_rp_ack(MigrationIncomingState *mis,
+ uint32_t value);
+
+
void ram_control_before_iterate(QEMUFile *f, uint64_t flags);
void ram_control_after_iterate(QEMUFile *f, uint64_t flags);
void ram_control_load_hook(QEMUFile *f, uint64_t flags);
diff --git a/migration.c b/migration.c
index c5b133d..74bffbc 100644
--- a/migration.c
+++ b/migration.c
@@ -77,6 +77,32 @@ MigrationState *migrate_get_current(void)
return ¤t_migration;
}
+/* Send a message on the return channel back to the source
+ * of the migration.
+ */
+void migrate_send_rp_message(MigrationIncomingState *mis,
+ enum mig_rpcomm_cmd cmd,
+ uint16_t len, uint8_t *data)
+{
+ DPRINTF("migrate_send_rp_message: cmd=%d, len=%d\n", (int)cmd, len);
+ qemu_mutex_lock(&mis->rp_mutex);
+ qemu_put_be16(mis->return_path, (unsigned int)cmd);
+ qemu_put_be16(mis->return_path, len);
+ qemu_put_buffer(mis->return_path, data, len);
+ qemu_fflush(mis->return_path);
+ qemu_mutex_unlock(&mis->rp_mutex);
+}
+
+/* Send an 'ACK' message on the return channel with the given value */
+void migrate_send_rp_ack(MigrationIncomingState *mis,
+ uint32_t value)
+{
+ uint32_t buf;
+
+ buf = cpu_to_be32(value);
+ migrate_send_rp_message(mis, MIG_RPCOMM_ACK, 4, (uint8_t *)&buf);
+}
+
void qemu_start_incoming_migration(const char *uri, Error **errp)
{
const char *p;
@@ -104,6 +130,7 @@ MigrationIncomingState
*migration_incoming_state_init(QEMUFile* f)
{
MigrationIncomingState *mis = g_malloc0(sizeof(MigrationIncomingState));
mis->file = f;
+ qemu_mutex_init(&mis->rp_mutex);
return mis;
}
--
1.9.3
- [Qemu-devel] [PATCH 00/46] Postcopy implementation, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 02/46] Move QEMUFile structure to qemu-file.h, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 01/46] qemu_ram_foreach_block: pass up error value, and down the ramblock name, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 03/46] QEMUSizedBuffer/QEMUFile, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 04/46] improve DPRINTF macros, add to savevm, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 06/46] Create MigrationIncomingState, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 05/46] Add qemu_get_counted_string to read a string prefixed by a count byte, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 07/46] Return path: Open a return path on QEMUFile for sockets, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 10/46] Return path: Control commands, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 12/46] Return path: Source handling of return path, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 11/46] Return path: Send responses from destination to source,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [PATCH 23/46] MIG_STATE_POSTCOPY_ACTIVE: Add new migration state, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 24/46] qemu_savevm_state_complete: Postcopy changes, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 25/46] Postcopy: Maintain sentmap during postcopy pre phase, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 26/46] Postcopy page-map-incoming (PMI) structure, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 27/46] postcopy: Add incoming_init/cleanup functions, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 29/46] postcopy: ram_enable_notify to switch on userfault, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 28/46] postcopy: Incoming initialisation, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 30/46] Postcopy: postcopy_start, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 32/46] mig fd_connect: open return path, Dr. David Alan Gilbert (git), 2014/07/04
- [Qemu-devel] [PATCH 31/46] Postcopy: Rework migration thread for postcopy mode, Dr. David Alan Gilbert (git), 2014/07/04