From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAEKS-0006Sy-Cj for qemu-devel@nongnu.org; Wed, 01 Jul 2015 05:29:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZAEKR-0001i1-9n for qemu-devel@nongnu.org; Wed, 01 Jul 2015 05:29:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52878) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAEKR-0001h2-2P for qemu-devel@nongnu.org; Wed, 01 Jul 2015 05:29:15 -0400 From: Juan Quintela In-Reply-To: <20150619184241.GM2147@work-vm> (David Alan Gilbert's message of "Fri, 19 Jun 2015 19:42:42 +0100") References: <1434450415-11339-1-git-send-email-dgilbert@redhat.com> <1434450415-11339-15-git-send-email-dgilbert@redhat.com> <877fr247s7.fsf@neno.neno> <20150619184241.GM2147@work-vm> Date: Wed, 01 Jul 2015 11:29:11 +0200 Message-ID: <87mvzg1b14.fsf@neno.neno> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v7 14/42] Return path: Send responses from destination to source Reply-To: quintela@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert" Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, liang.z.li@intel.com, qemu-devel@nongnu.org, luis@cs.umu.se, amit.shah@redhat.com, pbonzini@redhat.com, david@gibson.dropbear.id.au "Dr. David Alan Gilbert" wrote: > * Juan Quintela (quintela@redhat.com) wrote: >> "Dr. David Alan Gilbert (git)" wrote: >> > From: "Dr. David Alan Gilbert" >> > >> > 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 >> > --- >> > include/migration/migration.h | 17 ++++++++++++++++ >> > migration/migration.c | 45 +++++++++++++++++++++++++++++++++++++++++++ >> > migration/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 65fe5db..36caab9 100644 >> > --- a/include/migration/migration.h >> > +++ b/include/migration/migration.h >> > @@ -42,12 +42,20 @@ struct MigrationParams { >> > bool shared; >> > }; >> > >> > +/* Messages sent on the return path from destination to source */ >> > +enum mig_rp_message_type { >> > + MIG_RP_MSG_INVALID = 0, /* Must be 0 */ >> > + MIG_RP_MSG_SHUT, /* sibling will not send any more RP messages */ >> > + MIG_RP_MSG_PONG, /* Response to a PING; data (seq: be32 ) */ >> > +}; >> > + >> > typedef QLIST_HEAD(, LoadStateEntry) LoadStateEntry_Head; >> > /* State for the incoming migration */ >> > struct MigrationIncomingState { >> > QEMUFile *file; >> > >> > QEMUFile *return_path; >> > + QemuMutex rp_mutex; /* We send replies from multiple threads */ >> > >> > /* See savevm.c */ >> > LoadStateEntry_Head loadvm_handlers; >> > @@ -179,6 +187,15 @@ int migrate_compress_level(void); >> > int migrate_compress_threads(void); >> > int migrate_decompress_threads(void); >> > >> > +/* Sending on the return path - generic and then for each message type */ >> > +void migrate_send_rp_message(MigrationIncomingState *mis, >> > + enum mig_rp_message_type message_type, >> > + uint16_t len, void *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 295f15a..afb19a1 100644 >> > --- a/migration/migration.c >> > +++ b/migration/migration.c >> > @@ -85,6 +85,7 @@ MigrationIncomingState *migration_incoming_state_new(QEMUFile* f) >> > mis_current = g_malloc0(sizeof(MigrationIncomingState)); >> > mis_current->file = f; >> > QLIST_INIT(&mis_current->loadvm_handlers); >> > + qemu_mutex_init(&mis_current->rp_mutex); >> > >> > return mis_current; >> > } >> > @@ -182,6 +183,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->return_path, (unsigned int)message_type); >> > + qemu_put_be16(mis->return_path, len); >> if (len) { >> >> > + qemu_put_buffer(mis->return_path, data, len); >> } >> >> >> ? >> >> We check for zero sized command on control commands but not on >> responses? > > Or should I remove the check in the control commands case? > qemu_put_buffer looks like it's safe for size == 0 I would go for this just for consistence?