@@ -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);
@@ -84,6 +84,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
};
@@ -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;
@@ -919,6 +932,7 @@ static int loadvm_process_command_simple_lencheck(const char *name,
*/
static int loadvm_process_command(QEMUFile *f)
{
+ MigrationIncomingState *mis = migration_incoming_get_current();
uint16_t com;
uint16_t len;
uint32_t tmp32;
@@ -928,6 +942,35 @@ static int loadvm_process_command(QEMUFile *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);
+ break;
default:
error_report("VM_COMMAND 0x%x unknown (len 0x%x)", com, len);