mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
Return path: Send responses from destination to source
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_shut to send a 'shut' message to indicate the destination is finished with the RP. Add migrate_send_rp_ack to send a 'PONG' message in response to a PING Use it in the MSG_RP_PING handler Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Amit Shah <amit.shah@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
2e37701efd
commit
6decec9311
4 changed files with 66 additions and 1 deletions
|
@ -97,6 +97,7 @@ MigrationIncomingState *migration_incoming_state_new(QEMUFile* f)
|
|||
mis_current = g_new0(MigrationIncomingState, 1);
|
||||
mis_current->from_src_file = f;
|
||||
QLIST_INIT(&mis_current->loadvm_handlers);
|
||||
qemu_mutex_init(&mis_current->rp_mutex);
|
||||
|
||||
return mis_current;
|
||||
}
|
||||
|
@ -344,6 +345,50 @@ void process_incoming_migration(QEMUFile *f)
|
|||
qemu_coroutine_enter(co, f);
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a message on the return channel back to the source
|
||||
* of the migration.
|
||||
*/
|
||||
void migrate_send_rp_message(MigrationIncomingState *mis,
|
||||
enum mig_rp_message_type message_type,
|
||||
uint16_t len, void *data)
|
||||
{
|
||||
trace_migrate_send_rp_message((int)message_type, len);
|
||||
qemu_mutex_lock(&mis->rp_mutex);
|
||||
qemu_put_be16(mis->to_src_file, (unsigned int)message_type);
|
||||
qemu_put_be16(mis->to_src_file, len);
|
||||
qemu_put_buffer(mis->to_src_file, data, len);
|
||||
qemu_fflush(mis->to_src_file);
|
||||
qemu_mutex_unlock(&mis->rp_mutex);
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a 'SHUT' message on the return channel with the given value
|
||||
* to indicate that we've finished with the RP. Non-0 value indicates
|
||||
* error.
|
||||
*/
|
||||
void migrate_send_rp_shut(MigrationIncomingState *mis,
|
||||
uint32_t value)
|
||||
{
|
||||
uint32_t buf;
|
||||
|
||||
buf = cpu_to_be32(value);
|
||||
migrate_send_rp_message(mis, MIG_RP_MSG_SHUT, sizeof(buf), &buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a 'PONG' message on the return channel with the given value
|
||||
* (normally in response to a 'PING')
|
||||
*/
|
||||
void migrate_send_rp_pong(MigrationIncomingState *mis,
|
||||
uint32_t value)
|
||||
{
|
||||
uint32_t buf;
|
||||
|
||||
buf = cpu_to_be32(value);
|
||||
migrate_send_rp_message(mis, MIG_RP_MSG_PONG, sizeof(buf), &buf);
|
||||
}
|
||||
|
||||
/* amount of nanoseconds we are willing to wait for migration to be down.
|
||||
* the choice of nanoseconds is because it is the maximum resolution that
|
||||
* get_clock() can achieve. It is an internal measure. All user-visible
|
||||
|
|
|
@ -1103,7 +1103,7 @@ static int loadvm_process_command(QEMUFile *f)
|
|||
tmp32);
|
||||
return -1;
|
||||
}
|
||||
/* migrate_send_rp_pong(mis, tmp32); TODO: gets added later */
|
||||
migrate_send_rp_pong(mis, tmp32);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue