Message ID | 1434450415-11339-13-git-send-email-dgilbert@redhat.com |
---|---|
State | New |
Headers | show |
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote: > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com> > > Create QEMU_VM_COMMAND section type for sending commands from > source to destination. These commands are not intended to convey > guest state but to control the migration process. > > For use in postcopy. > > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> > --- > include/migration/migration.h | 1 + > include/sysemu/sysemu.h | 7 +++++++ > migration/savevm.c | 46 +++++++++++++++++++++++++++++++++++++++++++ > trace-events | 1 + > 4 files changed, 55 insertions(+) > > diff --git a/include/migration/migration.h b/include/migration/migration.h > index 414c5cf..8adaa45 100644 > --- a/include/migration/migration.h > +++ b/include/migration/migration.h > @@ -34,6 +34,7 @@ > #define QEMU_VM_SECTION_FULL 0x04 > #define QEMU_VM_SUBSECTION 0x05 > #define QEMU_VM_VMDESCRIPTION 0x06 > +#define QEMU_VM_COMMAND 0x07 conflicts with configuration section just sent > #define QEMU_VM_SECTION_FOOTER 0x7e > > struct MigrationParams { > diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h > index 6dae2db..5869607 100644 > --- a/include/sysemu/sysemu.h > +++ b/include/sysemu/sysemu.h > @@ -82,6 +82,11 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict); > > void qemu_announce_self(void); > > +/* Subcommands for QEMU_VM_COMMAND */ > +enum qemu_vm_cmd { > + MIG_CMD_INVALID = 0, /* Must be 0 */ > +}; > + > bool qemu_savevm_state_blocked(Error **errp); > void qemu_savevm_state_begin(QEMUFile *f, > const MigrationParams *params); > @@ -90,6 +95,8 @@ int qemu_savevm_state_iterate(QEMUFile *f); > void qemu_savevm_state_complete_precopy(QEMUFile *f); > 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); > int qemu_loadvm_state(QEMUFile *f); > > typedef enum DisplayType > diff --git a/migration/savevm.c b/migration/savevm.c > index f9168ac..7ce9d21 100644 > --- a/migration/savevm.c > +++ b/migration/savevm.c > @@ -686,6 +686,23 @@ static bool check_section_footer(QEMUFile *f, SaveStateEntry *se) > return true; > } > > +/* Send a 'QEMU_VM_COMMAND' type element with the command > + * and associated data. Please, use doxygen comments for new functions :p > + */ > +void qemu_savevm_command_send(QEMUFile *f, > + enum qemu_vm_cmd command, > + uint16_t len, > + uint8_t *data) > +{ > + qemu_put_byte(f, QEMU_VM_COMMAND); > + qemu_put_be16(f, (uint16_t)command); > + qemu_put_be16(f, len); > + if (len) { > + qemu_put_buffer(f, data, len); > + } > + qemu_fflush(f); > +} > + > bool qemu_savevm_state_blocked(Error **errp) > { > SaveStateEntry *se; > @@ -982,6 +999,29 @@ static SaveStateEntry *find_se(const char *idstr, int instance_id) > return NULL; > } > > +/* > + * Process an incoming 'QEMU_VM_COMMAND' > + * negative return on error (will issue error message) > + */ > +static int loadvm_process_command(QEMUFile *f) > +{ > + uint16_t cmd; > + uint16_t len; > + > + cmd = qemu_get_be16(f); > + len = qemu_get_be16(f); > + > + trace_loadvm_process_command(cmd, len); trace for load but not for sending? > + switch (cmd) { > + > + default: > + error_report("VM_COMMAND 0x%x unknown (len 0x%x)", cmd, len); > + return -1; > + } > + > + return 0; > +} > + > struct LoadStateEntry { > QLIST_ENTRY(LoadStateEntry) entry; > SaveStateEntry *se; > @@ -1114,6 +1154,12 @@ int qemu_loadvm_state(QEMUFile *f) > goto out; > } > break; > + case QEMU_VM_COMMAND: > + ret = loadvm_process_command(f); > + if (ret < 0) { > + goto out; > + } > + break; > default: > error_report("Unknown savevm section type %d", section_type); > ret = -EINVAL; > diff --git a/trace-events b/trace-events > index d539528..73a65c3 100644 > --- a/trace-events > +++ b/trace-events > @@ -1183,6 +1183,7 @@ virtio_gpu_fence_resp(uint64_t fence) "fence 0x%" PRIx64 > qemu_loadvm_state_section(unsigned int section_type) "%d" > qemu_loadvm_state_section_partend(uint32_t section_id) "%u" > qemu_loadvm_state_section_startfull(uint32_t section_id, const char *idstr, uint32_t instance_id, uint32_t version_id) "%u(%s) %u %u" > +loadvm_process_command(uint16_t com, uint16_t len) "com=0x%x len=%d" > savevm_section_start(const char *id, unsigned int section_id) "%s, section_id %u" > savevm_section_end(const char *id, unsigned int section_id, int ret) "%s, section_id %u -> %d" > savevm_state_begin(void) ""
* Juan Quintela (quintela@redhat.com) wrote: > "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> wrote: > > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com> > > > > Create QEMU_VM_COMMAND section type for sending commands from > > source to destination. These commands are not intended to convey > > guest state but to control the migration process. > > > > For use in postcopy. > > > > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> > > --- > > include/migration/migration.h | 1 + > > include/sysemu/sysemu.h | 7 +++++++ > > migration/savevm.c | 46 +++++++++++++++++++++++++++++++++++++++++++ > > trace-events | 1 + > > 4 files changed, 55 insertions(+) > > > > diff --git a/include/migration/migration.h b/include/migration/migration.h > > index 414c5cf..8adaa45 100644 > > --- a/include/migration/migration.h > > +++ b/include/migration/migration.h > > @@ -34,6 +34,7 @@ > > #define QEMU_VM_SECTION_FULL 0x04 > > #define QEMU_VM_SUBSECTION 0x05 > > #define QEMU_VM_VMDESCRIPTION 0x06 > > +#define QEMU_VM_COMMAND 0x07 > > conflicts with configuration section just sent Inc'd to 8. > > #define QEMU_VM_SECTION_FOOTER 0x7e > > > > struct MigrationParams { > > diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h > > index 6dae2db..5869607 100644 > > --- a/include/sysemu/sysemu.h > > +++ b/include/sysemu/sysemu.h > > @@ -82,6 +82,11 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict); > > > > void qemu_announce_self(void); > > > > +/* Subcommands for QEMU_VM_COMMAND */ > > +enum qemu_vm_cmd { > > + MIG_CMD_INVALID = 0, /* Must be 0 */ > > +}; > > + > > bool qemu_savevm_state_blocked(Error **errp); > > void qemu_savevm_state_begin(QEMUFile *f, > > const MigrationParams *params); > > @@ -90,6 +95,8 @@ int qemu_savevm_state_iterate(QEMUFile *f); > > void qemu_savevm_state_complete_precopy(QEMUFile *f); > > 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); > > int qemu_loadvm_state(QEMUFile *f); > > > > typedef enum DisplayType > > diff --git a/migration/savevm.c b/migration/savevm.c > > index f9168ac..7ce9d21 100644 > > --- a/migration/savevm.c > > +++ b/migration/savevm.c > > @@ -686,6 +686,23 @@ static bool check_section_footer(QEMUFile *f, SaveStateEntry *se) > > return true; > > } > > > > +/* Send a 'QEMU_VM_COMMAND' type element with the command > > + * and associated data. > > Please, use doxygen comments for new functions :p Done. > > > + */ > > +void qemu_savevm_command_send(QEMUFile *f, > > + enum qemu_vm_cmd command, > > + uint16_t len, > > + uint8_t *data) > > +{ > > + qemu_put_byte(f, QEMU_VM_COMMAND); > > + qemu_put_be16(f, (uint16_t)command); > > + qemu_put_be16(f, len); > > + if (len) { > > + qemu_put_buffer(f, data, len); > > + } > > + qemu_fflush(f); > > +} > > + > > bool qemu_savevm_state_blocked(Error **errp) > > { > > SaveStateEntry *se; > > @@ -982,6 +999,29 @@ static SaveStateEntry *find_se(const char *idstr, int instance_id) > > return NULL; > > } > > > > +/* > > + * Process an incoming 'QEMU_VM_COMMAND' > > + * negative return on error (will issue error message) > > + */ > > +static int loadvm_process_command(QEMUFile *f) > > +{ > > + uint16_t cmd; > > + uint16_t len; > > + > > + cmd = qemu_get_be16(f); > > + len = qemu_get_be16(f); > > + > > + trace_loadvm_process_command(cmd, len); > > trace for load but not for sending? Added. Dave > > + switch (cmd) { > > + > > + default: > > + error_report("VM_COMMAND 0x%x unknown (len 0x%x)", cmd, len); > > + return -1; > > + } > > + > > + return 0; > > +} > > + > > struct LoadStateEntry { > > QLIST_ENTRY(LoadStateEntry) entry; > > SaveStateEntry *se; > > @@ -1114,6 +1154,12 @@ int qemu_loadvm_state(QEMUFile *f) > > goto out; > > } > > break; > > + case QEMU_VM_COMMAND: > > + ret = loadvm_process_command(f); > > + if (ret < 0) { > > + goto out; > > + } > > + break; > > default: > > error_report("Unknown savevm section type %d", section_type); > > ret = -EINVAL; > > diff --git a/trace-events b/trace-events > > index d539528..73a65c3 100644 > > --- a/trace-events > > +++ b/trace-events > > @@ -1183,6 +1183,7 @@ virtio_gpu_fence_resp(uint64_t fence) "fence 0x%" PRIx64 > > qemu_loadvm_state_section(unsigned int section_type) "%d" > > qemu_loadvm_state_section_partend(uint32_t section_id) "%u" > > qemu_loadvm_state_section_startfull(uint32_t section_id, const char *idstr, uint32_t instance_id, uint32_t version_id) "%u(%s) %u %u" > > +loadvm_process_command(uint16_t com, uint16_t len) "com=0x%x len=%d" > > savevm_section_start(const char *id, unsigned int section_id) "%s, section_id %u" > > savevm_section_end(const char *id, unsigned int section_id, int ret) "%s, section_id %u -> %d" > > savevm_state_begin(void) "" -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
On (Tue) 16 Jun 2015 [11:26:25], Dr. David Alan Gilbert (git) wrote: > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com> > > Create QEMU_VM_COMMAND section type for sending commands from > source to destination. These commands are not intended to convey > guest state but to control the migration process. > > For use in postcopy. > > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Amit Shah <amit.shah@redhat.com> Amit
diff --git a/include/migration/migration.h b/include/migration/migration.h index 414c5cf..8adaa45 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -34,6 +34,7 @@ #define QEMU_VM_SECTION_FULL 0x04 #define QEMU_VM_SUBSECTION 0x05 #define QEMU_VM_VMDESCRIPTION 0x06 +#define QEMU_VM_COMMAND 0x07 #define QEMU_VM_SECTION_FOOTER 0x7e struct MigrationParams { diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 6dae2db..5869607 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -82,6 +82,11 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qdict); void qemu_announce_self(void); +/* Subcommands for QEMU_VM_COMMAND */ +enum qemu_vm_cmd { + MIG_CMD_INVALID = 0, /* Must be 0 */ +}; + bool qemu_savevm_state_blocked(Error **errp); void qemu_savevm_state_begin(QEMUFile *f, const MigrationParams *params); @@ -90,6 +95,8 @@ int qemu_savevm_state_iterate(QEMUFile *f); void qemu_savevm_state_complete_precopy(QEMUFile *f); 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); int qemu_loadvm_state(QEMUFile *f); typedef enum DisplayType diff --git a/migration/savevm.c b/migration/savevm.c index f9168ac..7ce9d21 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -686,6 +686,23 @@ static bool check_section_footer(QEMUFile *f, SaveStateEntry *se) return true; } +/* Send a 'QEMU_VM_COMMAND' type element with the command + * and associated data. + */ +void qemu_savevm_command_send(QEMUFile *f, + enum qemu_vm_cmd command, + uint16_t len, + uint8_t *data) +{ + qemu_put_byte(f, QEMU_VM_COMMAND); + qemu_put_be16(f, (uint16_t)command); + qemu_put_be16(f, len); + if (len) { + qemu_put_buffer(f, data, len); + } + qemu_fflush(f); +} + bool qemu_savevm_state_blocked(Error **errp) { SaveStateEntry *se; @@ -982,6 +999,29 @@ static SaveStateEntry *find_se(const char *idstr, int instance_id) return NULL; } +/* + * Process an incoming 'QEMU_VM_COMMAND' + * negative return on error (will issue error message) + */ +static int loadvm_process_command(QEMUFile *f) +{ + uint16_t cmd; + uint16_t len; + + cmd = qemu_get_be16(f); + len = qemu_get_be16(f); + + trace_loadvm_process_command(cmd, len); + switch (cmd) { + + default: + error_report("VM_COMMAND 0x%x unknown (len 0x%x)", cmd, len); + return -1; + } + + return 0; +} + struct LoadStateEntry { QLIST_ENTRY(LoadStateEntry) entry; SaveStateEntry *se; @@ -1114,6 +1154,12 @@ int qemu_loadvm_state(QEMUFile *f) goto out; } break; + case QEMU_VM_COMMAND: + ret = loadvm_process_command(f); + if (ret < 0) { + goto out; + } + break; default: error_report("Unknown savevm section type %d", section_type); ret = -EINVAL; diff --git a/trace-events b/trace-events index d539528..73a65c3 100644 --- a/trace-events +++ b/trace-events @@ -1183,6 +1183,7 @@ virtio_gpu_fence_resp(uint64_t fence) "fence 0x%" PRIx64 qemu_loadvm_state_section(unsigned int section_type) "%d" qemu_loadvm_state_section_partend(uint32_t section_id) "%u" qemu_loadvm_state_section_startfull(uint32_t section_id, const char *idstr, uint32_t instance_id, uint32_t version_id) "%u(%s) %u %u" +loadvm_process_command(uint16_t com, uint16_t len) "com=0x%x len=%d" savevm_section_start(const char *id, unsigned int section_id) "%s, section_id %u" savevm_section_end(const char *id, unsigned int section_id, int ret) "%s, section_id %u -> %d" savevm_state_begin(void) ""