@@ -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;
+}
@@ -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
@@ -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;