From patchwork Fri Jul 13 07:23:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 170804 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 771BB2C02F2 for ; Fri, 13 Jul 2012 17:24:33 +1000 (EST) Received: from localhost ([::1]:51889 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpaEp-00085r-C0 for incoming@patchwork.ozlabs.org; Fri, 13 Jul 2012 03:24:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpaEJ-0007a9-O4 for qemu-devel@nongnu.org; Fri, 13 Jul 2012 03:24:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SpaED-0004Ng-Hl for qemu-devel@nongnu.org; Fri, 13 Jul 2012 03:23:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23106) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpaED-0004Na-9S for qemu-devel@nongnu.org; Fri, 13 Jul 2012 03:23:53 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6D7Nqp9003594 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Jul 2012 03:23:52 -0400 Received: from trasno.mitica (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q6D7NjQt014276; Fri, 13 Jul 2012 03:23:51 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 13 Jul 2012 09:23:27 +0200 Message-Id: <1342164224-32709-6-git-send-email-quintela@redhat.com> In-Reply-To: <1342164224-32709-1-git-send-email-quintela@redhat.com> References: <1342164224-32709-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 05/22] savevm: Refactor cancel operation in its own operation 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 Intead of abusing stage with value -1. Signed-off-by: Juan Quintela --- arch_init.c | 11 ++++++----- block-migration.c | 10 ++++++---- savevm.c | 4 ++-- vmstate.h | 1 + 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/arch_init.c b/arch_init.c index 606b848..f6bc3fe 100644 --- a/arch_init.c +++ b/arch_init.c @@ -296,6 +296,11 @@ static void migration_end(void) memory_global_dirty_log_stop(); } +static void ram_migration_cancel(void *opaque) +{ + migration_end(); +} + #define MAX_WAIT 50 /* ms, half buffered_file limit */ static int ram_save_live(QEMUFile *f, int stage, void *opaque) @@ -306,11 +311,6 @@ static int ram_save_live(QEMUFile *f, int stage, void *opaque) int ret; int i; - if (stage < 0) { - migration_end(); - return 0; - } - memory_global_sync_dirty_bitmap(get_system_memory()); if (stage == 1) { @@ -537,6 +537,7 @@ done: SaveVMHandlers savevm_ram_handlers = { .save_live_state = ram_save_live, .load_state = ram_load, + .cancel = ram_migration_cancel, }; #ifdef HAS_AUDIO diff --git a/block-migration.c b/block-migration.c index 00151a0..cd8a8dd 100644 --- a/block-migration.c +++ b/block-migration.c @@ -536,6 +536,11 @@ static void blk_mig_cleanup(void) } } +static void block_migration_cancel(void *opaque) +{ + blk_mig_cleanup(); +} + static int block_save_live(QEMUFile *f, int stage, void *opaque) { int ret; @@ -543,10 +548,6 @@ static int block_save_live(QEMUFile *f, int stage, void *opaque) DPRINTF("Enter save live stage %d submitted %d transferred %d\n", stage, block_mig_state.submitted, block_mig_state.transferred); - if (stage < 0) { - blk_mig_cleanup(); - return 0; - } if (block_mig_state.blk_enable != 1) { /* no need to migrate storage */ @@ -713,6 +714,7 @@ SaveVMHandlers savevm_block_handlers = { .set_params = block_set_params, .save_live_state = block_save_live, .load_state = block_load, + .cancel = block_migration_cancel, }; void blk_mig_init(void) diff --git a/savevm.c b/savevm.c index a451be2..888c5a2 100644 --- a/savevm.c +++ b/savevm.c @@ -1703,8 +1703,8 @@ void qemu_savevm_state_cancel(QEMUFile *f) SaveStateEntry *se; QTAILQ_FOREACH(se, &savevm_handlers, entry) { - if (se->ops && se->ops->save_live_state) { - se->ops->save_live_state(f, -1, se->opaque); + if (se->ops && se->ops->cancel) { + se->ops->cancel(se->opaque); } } } diff --git a/vmstate.h b/vmstate.h index 0e24834..1dd42f5 100644 --- a/vmstate.h +++ b/vmstate.h @@ -33,6 +33,7 @@ typedef struct SaveVMHandlers { void (*set_params)(const MigrationParams *params, void * opaque); SaveStateHandler *save_state; int (*save_live_state)(QEMUFile *f, int stage, void *opaque); + void (*cancel)(void *opaque); LoadStateHandler *load_state; } SaveVMHandlers;