qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v7 14/42] Return path: Send responses from desti


From: Dr. David Alan Gilbert
Subject: Re: [Qemu-devel] [PATCH v7 14/42] Return path: Send responses from destination to source
Date: Thu, 6 Aug 2015 13:18:23 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

* Juan Quintela (address@hidden) wrote:
> "Dr. David Alan Gilbert" <address@hidden> wrote:
> > * Juan Quintela (address@hidden) wrote:
> >> "Dr. David Alan Gilbert (git)" <address@hidden> 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 MSG_RP_PING handler
> >> >
> >> > Signed-off-by: Dr. David Alan Gilbert <address@hidden>
> >> > ---
> >> >  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?

OK, check removed in both cases.

Dave

(Resend: I dropped the list off the first message)
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK



reply via email to

[Prev in Thread] Current Thread [Next in Thread]