[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 11/45] Return path: Send responses from desti
From: |
David Gibson |
Subject: |
Re: [Qemu-devel] [PATCH v5 11/45] Return path: Send responses from destination to source |
Date: |
Tue, 10 Mar 2015 16:47:25 +1100 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Wed, Feb 25, 2015 at 04:51:34PM +0000, Dr. David Alan Gilbert (git) wrote:
> 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_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 CMD_PING handler
>
> Signed-off-by: Dr. David Alan Gilbert <address@hidden>
> ---
> include/migration/migration.h | 17 ++++++++++++++++
> migration/migration.c | 45
> +++++++++++++++++++++++++++++++++++++++++++
> savevm.c | 2 +-
> trace-events | 1 +
> 4 files changed, 64 insertions(+), 1 deletion(-)
>
> diff --git a/include/migration/migration.h b/include/migration/migration.h
> index c514dd4..6775747 100644
> --- a/include/migration/migration.h
> +++ b/include/migration/migration.h
> @@ -41,6 +41,13 @@ struct MigrationParams {
> bool shared;
> };
>
> +/* Commands sent on the return path from destination to source*/
> +enum mig_rpcomm_cmd {
"command" doesn't seem like quite the right description for these rp
messages.
> + MIG_RP_CMD_INVALID = 0, /* Must be 0 */
> + MIG_RP_CMD_SHUT, /* sibling will not send any more RP messages */
> + MIG_RP_CMD_PONG, /* Response to a PING; data (seq: be32 ) */
> +};
> +
> typedef struct MigrationState MigrationState;
>
> /* State for the incoming migration */
> @@ -48,6 +55,7 @@ struct MigrationIncomingState {
> QEMUFile *file;
>
> QEMUFile *return_path;
> + QemuMutex rp_mutex; /* We send replies from multiple threads */
> };
>
> MigrationIncomingState *migration_incoming_get_current(void);
> @@ -169,6 +177,15 @@ 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_shut(MigrationIncomingState *mis,
> + uint32_t value);
> +void migrate_send_rp_pong(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/migration.c b/migration/migration.c
> index a36ea65..80d234c 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -78,6 +78,7 @@ MigrationIncomingState
> *migration_incoming_state_new(QEMUFile* f)
> {
> mis_current = g_malloc0(sizeof(MigrationIncomingState));
> mis_current->file = f;
> + qemu_mutex_init(&mis_current->rp_mutex);
>
> return mis_current;
> }
> @@ -88,6 +89,50 @@ void migration_incoming_state_destroy(void)
> mis_current = NULL;
> }
>
> +/*
> + * 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)
Using (void *) for data would avoid casts in a bunch of the callers.
> +{
> + trace_migrate_send_rp_message((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 a 'SHUT' message on the return channel with the given value
> + * to indicate that we've finished with the RP. None-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_CMD_SHUT, 4, (uint8_t *)&buf);
^ sizeof(buf)
would be safer
> +}
> +
> +/*
> + * 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_CMD_PONG, 4, (uint8_t *)&buf);
It occurs to me that you could define PONG as returning the whole
buffer that PING sends, instead of just 4-bytes. Might allow for some
more testing of variable sized messages.
> +}
> +
> void qemu_start_incoming_migration(const char *uri, Error **errp)
> {
> const char *p;
> diff --git a/savevm.c b/savevm.c
> index d082738..7084d07 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -1008,7 +1008,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;
>
> default:
> diff --git a/trace-events b/trace-events
> index 99e00b5..4f3eff8 100644
> --- a/trace-events
> +++ b/trace-events
> @@ -1379,6 +1379,7 @@ migrate_fd_cleanup(void) ""
> migrate_fd_error(void) ""
> migrate_fd_cancel(void) ""
> migrate_pending(uint64_t size, uint64_t max) "pending size %" PRIu64 " max
> %" PRIu64
> +migrate_send_rp_message(int cmd, uint16_t len) "cmd=%d, len=%d"
> migrate_transferred(uint64_t tranferred, uint64_t time_spent, double
> bandwidth, uint64_t size) "transferred %" PRIu64 " time_spent %" PRIu64 "
> bandwidth %g max_size %" PRId64
>
> # migration/rdma.c
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
pgp4mwFoikdtr.pgp
Description: PGP signature
- Re: [Qemu-devel] [PATCH v5 11/45] Return path: Send responses from destination to source,
David Gibson <=