Message ID | 1412358473-31398-15-git-send-email-dgilbert@redhat.com |
---|---|
State | New |
Headers | show |
Il 03/10/2014 19:47, Dr. David Alan Gilbert (git) ha scritto: > QEMU_VM_CMD_INVALID = 0, /* Must be 0 */ > + QEMU_VM_CMD_OPENRP, /* Tell the dest to open the Return path */ OPEN_RETURN_PATH? > + QEMU_VM_CMD_REQACK, /* Request an ACK on the RP */ SEND_ACK or ACK_REQUESTED? > QEMU_VM_CMD_AFTERLASTVALID Pleaseseparatewords. Is this enum actually used at all? Please avoid the difference between QEMU_VM_CMD and MIG_RPCOMM_. Perhaps MIG_CMD and MIG_RPCMD_? Paolo
* Paolo Bonzini (pbonzini@redhat.com) wrote: > Il 03/10/2014 19:47, Dr. David Alan Gilbert (git) ha scritto: > > QEMU_VM_CMD_INVALID = 0, /* Must be 0 */ > > + QEMU_VM_CMD_OPENRP, /* Tell the dest to open the Return path */ > > OPEN_RETURN_PATH? > > > + QEMU_VM_CMD_REQACK, /* Request an ACK on the RP */ > > SEND_ACK or ACK_REQUESTED? > > > QEMU_VM_CMD_AFTERLASTVALID > > Pleaseseparatewords. Is this enum actually used at all? > > Please avoid the difference between QEMU_VM_CMD and MIG_RPCOMM_. > > Perhaps MIG_CMD and MIG_RPCMD_? Almost, I went with: MIG_CMD_INVALID = 0, /* Must be 0 */ MIG_CMD_OPEN_RETURN_PATH, /* Tell the dest to open the Return path */ MIG_CMD_SEND_ACK, /* Request an ACK on the RP */ MIG_CMD_PACKAGED, /* Send a wrapped stream within this stream */ MIG_CMD_POSTCOPY_ADVISE = 20, /* Prior to any page transfers, just warn we might want to do PC */ MIG_CMD_POSTCOPY_LISTEN, /* Start listening for incoming pages as it's running. */ MIG_CMD_POSTCOPY_RUN, /* Start execution */ MIG_CMD_POSTCOPY_END, /* Postcopy is finished. */ MIG_CMD_POSTCOPY_RAM_DISCARD, /* A list of pages to discard that were previously sent during precopy but are dirty. */ and MIG_RP_CMD_INVALID = 0, /* Must be 0 */ MIG_RP_CMD_SHUT, /* sibling will not send any more RP messages */ MIG_RP_CMD_ACK, /* data (seq: be32 ) */ MIG_RP_CMD_REQ_PAGES, /* data (start: be64, len: be64) */ the only oddity I get from that is from the 'SEND_ACK' you suggested; since all my functions to send commands are send_ I currently have 'qemu_savevm_send_send_ack' which while consistent looks a bit odd. Dave -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
On 10/23/2014 06:23 PM, Dr. David Alan Gilbert wrote: > * Paolo Bonzini (pbonzini@redhat.com) wrote: >> Il 03/10/2014 19:47, Dr. David Alan Gilbert (git) ha scritto: >>> QEMU_VM_CMD_INVALID = 0, /* Must be 0 */ >>> + QEMU_VM_CMD_OPENRP, /* Tell the dest to open the Return path */ >> >> OPEN_RETURN_PATH? >> >>> + QEMU_VM_CMD_REQACK, /* Request an ACK on the RP */ >> >> SEND_ACK or ACK_REQUESTED? >> >>> QEMU_VM_CMD_AFTERLASTVALID >> >> Pleaseseparatewords. Is this enum actually used at all? >> >> Please avoid the difference between QEMU_VM_CMD and MIG_RPCOMM_. >> >> Perhaps MIG_CMD and MIG_RPCMD_? > > Almost, I went with: > > MIG_CMD_INVALID = 0, /* Must be 0 */ > MIG_CMD_OPEN_RETURN_PATH, /* Tell the dest to open the Return path */ > MIG_CMD_SEND_ACK, /* Request an ACK on the RP */ > MIG_CMD_PACKAGED, /* Send a wrapped stream within this stream */ > > MIG_CMD_POSTCOPY_ADVISE = 20, /* Prior to any page transfers, just > warn we might want to do PC */ > MIG_CMD_POSTCOPY_LISTEN, /* Start listening for incoming > pages as it's running. */ > MIG_CMD_POSTCOPY_RUN, /* Start execution */ > MIG_CMD_POSTCOPY_END, /* Postcopy is finished. */ > > MIG_CMD_POSTCOPY_RAM_DISCARD, /* A list of pages to discard that > were previously sent during > precopy but are dirty. */ > > and > MIG_RP_CMD_INVALID = 0, /* Must be 0 */ > MIG_RP_CMD_SHUT, /* sibling will not send any more RP messages */ > MIG_RP_CMD_ACK, /* data (seq: be32 ) */ > MIG_RP_CMD_REQ_PAGES, /* data (start: be64, len: be64) */ > > the only oddity I get from that is from the 'SEND_ACK' you suggested; > since all my functions to send commands are send_ I currently have > 'qemu_savevm_send_send_ack' which while consistent looks a bit odd. Perhaps ping/pong? Paolo
On Thu, Oct 23, 2014 at 10:15:20PM +0200, Paolo Bonzini wrote: > > > On 10/23/2014 06:23 PM, Dr. David Alan Gilbert wrote: > > * Paolo Bonzini (pbonzini@redhat.com) wrote: > >> Il 03/10/2014 19:47, Dr. David Alan Gilbert (git) ha scritto: > >>> QEMU_VM_CMD_INVALID = 0, /* Must be 0 */ > >>> + QEMU_VM_CMD_OPENRP, /* Tell the dest to open the Return path */ > >> > >> OPEN_RETURN_PATH? > >> > >>> + QEMU_VM_CMD_REQACK, /* Request an ACK on the RP */ > >> > >> SEND_ACK or ACK_REQUESTED? > >> > >>> QEMU_VM_CMD_AFTERLASTVALID > >> > >> Pleaseseparatewords. Is this enum actually used at all? > >> > >> Please avoid the difference between QEMU_VM_CMD and MIG_RPCOMM_. > >> > >> Perhaps MIG_CMD and MIG_RPCMD_? > > > > Almost, I went with: > > > > MIG_CMD_INVALID = 0, /* Must be 0 */ > > MIG_CMD_OPEN_RETURN_PATH, /* Tell the dest to open the Return path */ > > MIG_CMD_SEND_ACK, /* Request an ACK on the RP */ > > MIG_CMD_PACKAGED, /* Send a wrapped stream within this stream */ > > > > MIG_CMD_POSTCOPY_ADVISE = 20, /* Prior to any page transfers, just > > warn we might want to do PC */ > > MIG_CMD_POSTCOPY_LISTEN, /* Start listening for incoming > > pages as it's running. */ > > MIG_CMD_POSTCOPY_RUN, /* Start execution */ > > MIG_CMD_POSTCOPY_END, /* Postcopy is finished. */ > > > > MIG_CMD_POSTCOPY_RAM_DISCARD, /* A list of pages to discard that > > were previously sent during > > precopy but are dirty. */ > > > > and > > MIG_RP_CMD_INVALID = 0, /* Must be 0 */ > > MIG_RP_CMD_SHUT, /* sibling will not send any more RP messages */ > > MIG_RP_CMD_ACK, /* data (seq: be32 ) */ > > MIG_RP_CMD_REQ_PAGES, /* data (start: be64, len: be64) */ > > > > the only oddity I get from that is from the 'SEND_ACK' you suggested; > > since all my functions to send commands are send_ I currently have > > 'qemu_savevm_send_send_ack' which while consistent looks a bit odd. > > Perhaps ping/pong? I like that idea. Calling it "send_ack" looks like it's just asking for confusing names somewhere.
* Paolo Bonzini (pbonzini@redhat.com) wrote: > > the only oddity I get from that is from the 'SEND_ACK' you suggested; > > since all my functions to send commands are send_ I currently have > > 'qemu_savevm_send_send_ack' which while consistent looks a bit odd. > > Perhaps ping/pong? Done (although I'm sure I'll find 'ack' in the comments somewhere). Dave -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
diff --git a/include/migration/migration.h b/include/migration/migration.h index e23947a..173775b 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -45,6 +45,8 @@ typedef struct MigrationState MigrationState; /* State for the incoming migration */ struct MigrationIncomingState { QEMUFile *file; + + QEMUFile *return_path; }; MigrationIncomingState *migration_incoming_get_current(void); diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index eed7e77..ad96f2a 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -85,6 +85,8 @@ void qemu_announce_self(void); /* Subcommands for QEMU_VM_COMMAND */ enum qemu_vm_cmd { QEMU_VM_CMD_INVALID = 0, /* Must be 0 */ + QEMU_VM_CMD_OPENRP, /* Tell the dest to open the Return path */ + QEMU_VM_CMD_REQACK, /* Request an ACK on the RP */ QEMU_VM_CMD_AFTERLASTVALID }; @@ -98,6 +100,8 @@ void qemu_savevm_state_cancel(void); uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size); void qemu_savevm_command_send(QEMUFile *f, enum qemu_vm_cmd command, uint16_t len, uint8_t *data); +void qemu_savevm_send_reqack(QEMUFile *f, uint32_t value); +void qemu_savevm_send_openrp(QEMUFile *f); int qemu_loadvm_state(QEMUFile *f); /* SLIRP */ diff --git a/savevm.c b/savevm.c index 3cae292..793384a 100644 --- a/savevm.c +++ b/savevm.c @@ -611,6 +611,19 @@ void qemu_savevm_command_send(QEMUFile *f, qemu_fflush(f); } +void qemu_savevm_send_reqack(QEMUFile *f, uint32_t value) +{ + uint32_t buf; + + DPRINTF("send_reqack %d", value); + buf = cpu_to_be32(value); + qemu_savevm_command_send(f, QEMU_VM_CMD_REQACK, 4, (uint8_t *)&buf); +} + +void qemu_savevm_send_openrp(QEMUFile *f) +{ + qemu_savevm_command_send(f, QEMU_VM_CMD_OPENRP, 0, NULL); +} bool qemu_savevm_state_blocked(Error **errp) { SaveStateEntry *se; @@ -900,20 +913,64 @@ static SaveStateEntry *find_se(const char *idstr, int instance_id) return NULL; } +static int loadvm_process_command_simple_lencheck(const char *name, + unsigned int actual, + unsigned int expected) +{ + if (actual != expected) { + error_report("%s received with bad length - expecting %d, got %d", + name, expected, actual); + return -1; + } + + return 0; +} + /* * Process an incoming 'QEMU_VM_COMMAND' * negative return on error (will issue error message) */ static int loadvm_process_command(QEMUFile *f) { + MigrationIncomingState *mis = migration_incoming_get_current(); uint16_t com; uint16_t len; + uint32_t tmp32; com = qemu_get_be16(f); len = qemu_get_be16(f); /* fprintf(stderr,"loadvm_process_command: com=0x%x len=%d\n", com,len); */ switch (com) { + case QEMU_VM_CMD_OPENRP: + if (loadvm_process_command_simple_lencheck("CMD_OPENRP", len, 0)) { + return -1; + } + if (mis->return_path) { + error_report("CMD_OPENRP called when RP already open"); + /* Not really a problem, so don't give up */ + return 0; + } + mis->return_path = qemu_file_get_return_path(f); + if (!mis->return_path) { + error_report("CMD_OPENRP failed - could not open return path"); + return -1; + } + break; + + case QEMU_VM_CMD_REQACK: + if (loadvm_process_command_simple_lencheck("CMD_REQACK", len, 4)) { + return -1; + } + tmp32 = qemu_get_be32(f); + DPRINTF("Received REQACK 0x%x", tmp32); + if (!mis->return_path) { + error_report("CMD_REQACK (0x%x) received with no open return path", + tmp32); + return -1; + } + /* migrate_send_rp_ack(mis, tmp32); TODO: gets added later */ + break; default: error_report("VM_COMMAND 0x%x unknown (len 0x%x)", com, len);