The remote process sends the VMSD to the Proxy object, on the source side Signed-off-by: Elena Ufimtseva <elena.ufimts...@oracle.com> Signed-off-by: John G Johnson <john.g.john...@oracle.com> Signed-off-by: Jagannathan Raman <jag.ra...@oracle.com> --- New patch in v4
migration/savevm.c | 27 +++++++++++++++++++++++++++ migration/savevm.h | 2 ++ remote/remote-main.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/migration/savevm.c b/migration/savevm.c index 8d95e26..0c84142 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2903,3 +2903,30 @@ bool vmstate_check_only_migratable(const VMStateDescription *vmsd) return !(vmsd && vmsd->unmigratable); } + +int qemu_remote_savevm(QEMUFile *f) +{ + SaveStateEntry *se; + int ret; + + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + if (!se->vmsd || !vmstate_save_needed(se->vmsd, se->opaque)) { + continue; + } + + save_section_header(f, se, QEMU_VM_SECTION_FULL); + + ret = vmstate_save(f, se, NULL); + if (ret) { + qemu_file_set_error(f, ret); + return ret; + } + + save_section_footer(f, se); + } + + qemu_put_byte(f, QEMU_VM_EOF); + qemu_fflush(f); + + return 0; +} diff --git a/migration/savevm.h b/migration/savevm.h index 51a4b9c..a6582ac 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -64,4 +64,6 @@ void qemu_loadvm_state_cleanup(void); int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis); int qemu_load_device_state(QEMUFile *f); +int qemu_remote_savevm(QEMUFile *f); + #endif diff --git a/remote/remote-main.c b/remote/remote-main.c index 341b7cf..0284039 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -66,6 +66,16 @@ #include "qemu/log.h" #include "qemu/cutils.h" #include "remote-opts.h" +#include "qapi/error.h" +#include "io/channel-util.h" + +#include "io/channel.h" +#include "io/channel-socket.h" +#include "migration/qemu-file-types.h" +#include "migration/savevm.h" +#include "migration/qemu-file-channel.h" +#include "migration/qemu-file.h" + #include "monitor/monitor.h" #include "chardev/char.h" #include "sysemu/reset.h" @@ -362,6 +372,36 @@ static int setup_device(MPQemuMsg *msg, Error **errp) return 0; } +static void process_start_mig_out(MPQemuMsg *msg) +{ + int wait = msg->fds[1]; + Error *err = NULL; + QIOChannel *ioc; + QEMUFile *f; + + ioc = qio_channel_new_fd(msg->fds[0], &err); + if (err) { + error_report_err(err); + return; + } + + qio_channel_set_name(QIO_CHANNEL(ioc), "remote-migration-channel"); + + f = qemu_fopen_channel_output(ioc); + + bdrv_drain_all(); + (void)bdrv_flush_all(); + + (void)qemu_remote_savevm(f); + + qemu_fflush(f); + + notify_proxy(wait, (uint64_t)qemu_ftell(f)); + PUT_REMOTE_WAIT(wait); + + qemu_fclose(f); +} + static void process_msg(GIOCondition cond, MPQemuChannel *chan) { MPQemuMsg *msg = NULL; @@ -454,6 +494,9 @@ static void process_msg(GIOCondition cond, MPQemuChannel *chan) case DEVICE_RESET: process_device_reset_msg(msg); break; + case START_MIG_OUT: + process_start_mig_out(msg); + break; default: error_setg(&err, "Unknown command"); goto finalize_loop; -- 1.8.3.1