From patchwork Thu Aug 28 15:03:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 383894 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 36365140132 for ; Fri, 29 Aug 2014 01:12:43 +1000 (EST) Received: from localhost ([::1]:37172 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XN1NR-0005Eo-7x for incoming@patchwork.ozlabs.org; Thu, 28 Aug 2014 11:12:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XN1Fi-0000XM-7n for qemu-devel@nongnu.org; Thu, 28 Aug 2014 11:04:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XN1FY-0001xi-8W for qemu-devel@nongnu.org; Thu, 28 Aug 2014 11:04:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62666) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XN1FX-0001xZ-Q7 for qemu-devel@nongnu.org; Thu, 28 Aug 2014 11:04:32 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s7SF4SdY002387 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 28 Aug 2014 11:04:29 -0400 Received: from dgilbert-t530.home.treblig.org (vpn1-5-132.ams2.redhat.com [10.36.5.132]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s7SF44vn003726; Thu, 28 Aug 2014 11:04:27 -0400 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org Date: Thu, 28 Aug 2014 16:03:29 +0100 Message-Id: <1409238244-31720-13-git-send-email-dgilbert@redhat.com> In-Reply-To: <1409238244-31720-1-git-send-email-dgilbert@redhat.com> References: <1409238244-31720-1-git-send-email-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, amit.shah@redhat.com, lilei@linux.vnet.ibm.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH v3 12/47] 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: * OPENRP - To request that the destination open the return path * REQACK - Request an acknowledge from the destination Signed-off-by: Dr. David Alan Gilbert --- include/migration/migration.h | 2 ++ include/sysemu/sysemu.h | 4 +++ savevm.c | 57 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/include/migration/migration.h b/include/migration/migration.h index e23947a..173775b 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -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); diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index a0a91e3..4dd6ba0 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -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 }; @@ -97,6 +99,8 @@ 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); +void qemu_savevm_send_reqack(QEMUFile *f, uint32_t value); +void qemu_savevm_send_openrp(QEMUFile *f); int qemu_loadvm_state(QEMUFile *f); /* SLIRP */ diff --git a/savevm.c b/savevm.c index 3cae292..793384a 100644 --- a/savevm.c +++ b/savevm.c @@ -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; @@ -900,20 +913,64 @@ static SaveStateEntry *find_se(const char *idstr, int instance_id) return NULL; } +static int loadvm_process_command_simple_lencheck(const char *name, + unsigned int actual, + unsigned int expected) +{ + if (actual != expected) { + error_report("%s received with bad length - expecting %d, got %d", + name, expected, actual); + return -1; + } + + return 0; +} + /* * Process an incoming 'QEMU_VM_COMMAND' * negative return on error (will issue error message) */ static int loadvm_process_command(QEMUFile *f) { + MigrationIncomingState *mis = migration_incoming_get_current(); uint16_t com; uint16_t len; + uint32_t tmp32; com = qemu_get_be16(f); len = qemu_get_be16(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); TODO: gets added later */ + break; default: error_report("VM_COMMAND 0x%x unknown (len 0x%x)", com, len);