From patchwork Mon Nov 9 17:28:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 541864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1EAEB1402C2 for ; Tue, 10 Nov 2015 04:32:19 +1100 (AEDT) Received: from localhost ([::1]:54326 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvqIj-0000JC-1b for incoming@patchwork.ozlabs.org; Mon, 09 Nov 2015 12:32:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36290) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvqG7-0003Ww-Rg for qemu-devel@nongnu.org; Mon, 09 Nov 2015 12:29:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZvqG6-0004jc-Ie for qemu-devel@nongnu.org; Mon, 09 Nov 2015 12:29:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59143) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvqG6-0004jT-Bu for qemu-devel@nongnu.org; Mon, 09 Nov 2015 12:29:34 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 1551BC0A8495 for ; Mon, 9 Nov 2015 17:29:34 +0000 (UTC) Received: from trasno.mitica (ovpn-116-50.ams2.redhat.com [10.36.116.50]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tA9HT2wx001694; Mon, 9 Nov 2015 12:29:32 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 9 Nov 2015 18:28:23 +0100 Message-Id: <1447090141-29074-20-git-send-email-quintela@redhat.com> In-Reply-To: <1447090141-29074-1-git-send-email-quintela@redhat.com> References: <1447090141-29074-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: amit.shah@redhat.com, dgilbert@redhat.com Subject: [Qemu-devel] [PULL 19/57] Return path: Control commands X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Dr. David Alan Gilbert" Add two src->dest commands: * OPEN_RETURN_PATH - To request that the destination open the return path * PING - Request an acknowledge from the destination Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Amit Shah Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- include/migration/migration.h | 2 ++ include/sysemu/sysemu.h | 4 ++++ migration/savevm.c | 43 ++++++++++++++++++++++++++++++++++++++++++- trace-events | 3 +++ 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 0bb4383..98a6d07 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -48,6 +48,8 @@ typedef QLIST_HEAD(, LoadStateEntry) LoadStateEntry_Head; struct MigrationIncomingState { QEMUFile *from_src_file; + QEMUFile *to_src_file; + /* See savevm.c */ LoadStateEntry_Head loadvm_handlers; }; diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 0a8790e..70473f4 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -87,6 +87,8 @@ void qemu_announce_self(void); /* Subcommands for QEMU_VM_COMMAND */ enum qemu_vm_cmd { MIG_CMD_INVALID = 0, /* Must be 0 */ + MIG_CMD_OPEN_RETURN_PATH, /* Tell the dest to open the Return path */ + MIG_CMD_PING, /* Request a PONG on the RP */ MIG_CMD_MAX }; @@ -100,6 +102,8 @@ void qemu_savevm_state_complete_precopy(QEMUFile *f); 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_ping(QEMUFile *f, uint32_t value); +void qemu_savevm_send_open_return_path(QEMUFile *f); int qemu_loadvm_state(QEMUFile *f); typedef enum DisplayType diff --git a/migration/savevm.c b/migration/savevm.c index fd8e0c9..ea1d1b1 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -64,6 +64,8 @@ static struct mig_cmd_args { const char *name; } mig_cmd_args[] = { [MIG_CMD_INVALID] = { .len = -1, .name = "INVALID" }, + [MIG_CMD_OPEN_RETURN_PATH] = { .len = 0, .name = "OPEN_RETURN_PATH" }, + [MIG_CMD_PING] = { .len = sizeof(uint32_t), .name = "PING" }, [MIG_CMD_MAX] = { .len = -1, .name = "MAX" }, }; @@ -724,6 +726,21 @@ void qemu_savevm_command_send(QEMUFile *f, qemu_fflush(f); } +void qemu_savevm_send_ping(QEMUFile *f, uint32_t value) +{ + uint32_t buf; + + trace_savevm_send_ping(value); + buf = cpu_to_be32(value); + qemu_savevm_command_send(f, MIG_CMD_PING, sizeof(value), (uint8_t *)&buf); +} + +void qemu_savevm_send_open_return_path(QEMUFile *f) +{ + trace_savevm_send_open_return_path(); + qemu_savevm_command_send(f, MIG_CMD_OPEN_RETURN_PATH, 0, NULL); +} + bool qemu_savevm_state_blocked(Error **errp) { SaveStateEntry *se; @@ -1043,8 +1060,10 @@ static SaveStateEntry *find_se(const char *idstr, int instance_id) */ static int loadvm_process_command(QEMUFile *f) { + MigrationIncomingState *mis = migration_incoming_get_current(); uint16_t cmd; uint16_t len; + uint32_t tmp32; cmd = qemu_get_be16(f); len = qemu_get_be16(f); @@ -1062,7 +1081,29 @@ static int loadvm_process_command(QEMUFile *f) } switch (cmd) { - /* Filling added in next patch */ + case MIG_CMD_OPEN_RETURN_PATH: + if (mis->to_src_file) { + error_report("CMD_OPEN_RETURN_PATH called when RP already open"); + /* Not really a problem, so don't give up */ + return 0; + } + mis->to_src_file = qemu_file_get_return_path(f); + if (!mis->to_src_file) { + error_report("CMD_OPEN_RETURN_PATH failed"); + return -1; + } + break; + + case MIG_CMD_PING: + tmp32 = qemu_get_be32(f); + trace_loadvm_process_command_ping(tmp32); + if (!mis->to_src_file) { + error_report("CMD_PING (0x%x) received with no return path", + tmp32); + return -1; + } + /* migrate_send_rp_pong(mis, tmp32); TODO: gets added later */ + break; } return 0; diff --git a/trace-events b/trace-events index f077c23..500f1e3 100644 --- a/trace-events +++ b/trace-events @@ -1205,10 +1205,13 @@ 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" +loadvm_process_command_ping(uint32_t val) "%x" savevm_command_send(uint16_t command, 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_section_skip(const char *id, unsigned int section_id) "%s, section_id %u" +savevm_send_open_return_path(void) "" +savevm_send_ping(uint32_t val) "%x" savevm_state_begin(void) "" savevm_state_header(void) "" savevm_state_iterate(void) ""