From patchwork Wed Apr 21 05:57:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshiaki Tamura X-Patchwork-Id: 50613 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 76BD7B7080 for ; Wed, 21 Apr 2010 16:03:10 +1000 (EST) Received: from localhost ([127.0.0.1]:53212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4T1e-0003DI-IG for incoming@patchwork.ozlabs.org; Wed, 21 Apr 2010 02:03:06 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O4T0d-0003CK-A4 for qemu-devel@nongnu.org; Wed, 21 Apr 2010 02:02:03 -0400 Received: from [140.186.70.92] (port=36779 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4T0E-0002zC-CG for qemu-devel@nongnu.org; Wed, 21 Apr 2010 02:02:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O4T0A-0006fu-0p for qemu-devel@nongnu.org; Wed, 21 Apr 2010 02:01:37 -0400 Received: from sh.osrg.net ([192.16.179.4]:35939) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O4T09-0006eA-A1 for qemu-devel@nongnu.org; Wed, 21 Apr 2010 02:01:33 -0400 Received: from fs.osrg.net (postfix@fs.osrg.net [10.0.0.12]) by sh.osrg.net (8.14.3/8.14.3/OSRG-NET) with ESMTP id o3L61QlI004165; Wed, 21 Apr 2010 15:01:27 +0900 Received: from localhost (hype-wd0.osrg.net [10.72.1.16]) by fs.osrg.net (Postfix) with ESMTP id 47A2D3E02FD; Wed, 21 Apr 2010 15:01:25 +0900 (JST) From: Yoshiaki Tamura To: kvm@vger.kernel.org, qemu-devel@nongnu.org Date: Wed, 21 Apr 2010 14:57:21 +0900 Message-Id: <1271829445-5328-17-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> X-Mailer: git-send-email 1.7.0.31.g1df487 In-Reply-To: <1271829445-5328-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> References: <1271829445-5328-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> X-Dispatcher: imput version 20070423(IM149) Lines: 150 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (sh.osrg.net [192.16.179.4]); Wed, 21 Apr 2010 15:01:27 +0900 (JST) X-Virus-Scanned: clamav-milter 0.95.3 at sh X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: aliguori@us.ibm.com, ohmura.kei@lab.ntt.co.jp, mtosatti@redhat.com, Yoshiaki Tamura , yoshikawa.takuya@oss.ntt.co.jp, avi@redhat.com Subject: [Qemu-devel] [RFC PATCH 16/20] Introduce event_tap fucntions and ft_tranx_ready(). X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org event_tap controls when to start ft transaction. do_event_tap() should be instered to the device emulators. ft_tranx_ready() kicks the transaction. Signed-off-by: Yoshiaki Tamura --- migration.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ migration.h | 2 + qemu-common.h | 19 ++++++++++++++ 3 files changed, 98 insertions(+), 0 deletions(-) diff --git a/migration.c b/migration.c index 4eed0b7..3cc47fc 100644 --- a/migration.c +++ b/migration.c @@ -39,6 +39,45 @@ static uint32_t max_throttle = (32 << 20); static MigrationState *current_migration; +#ifdef CONFIG_FT_MODE +static enum EVENT_TAP_STATE event_tap_state = EVENT_TAP_OFF; + +void event_tap_on(void) +{ + event_tap_state = EVENT_TAP_ON; +} + +void event_tap_off(void) +{ + event_tap_state = EVENT_TAP_OFF; +} + +void event_tap_suspend(void) +{ + if (event_tap_state == EVENT_TAP_ON) + event_tap_state = EVENT_TAP_SUSPEND; +} + +void event_tap_resume(void) +{ + if (event_tap_state == EVENT_TAP_SUSPEND) + event_tap_state = EVENT_TAP_ON; +} + +void do_event_tap(void) +{ + if (event_tap_state != EVENT_TAP_ON) + return; + + if (ft_mode == FT_TRANSACTION || ft_mode == FT_INIT) { + if (ft_tranx_ready(current_migration) < 0) { + event_tap_off(); + vm_start(); + } + } +} +#endif + void qemu_start_incoming_migration(const char *uri) { const char *p; @@ -390,6 +429,44 @@ void migrate_fd_connect(FdMigrationState *s) migrate_fd_put_ready(s); } +int ft_tranx_ready(void *opaque) +{ + FdMigrationState *s = migrate_to_fms(opaque); + int ret = -1; + + if (qemu_transaction_begin(s->file) < 0) { + fprintf(stderr, "tranx_begin failed\n"); + goto error_out; + } + + /* make the VM state consistent by flushing outstanding requests. */ + vm_stop(0); + qemu_aio_flush(); + bdrv_flush_all(); + + if (qemu_savevm_state_all(s->mon, s->file) < 0) { + fprintf(stderr, "savevm_state_all failed\n"); + goto error_out; + } + + if (qemu_transaction_commit(s->file) < 0) { + fprintf(stderr, "tranx_commit failed\n"); + goto error_out; + } + + ret = 0; + vm_start(); + + return ret; + +error_out: + ft_mode = FT_OFF; + qemu_savevm_state_cancel(s->mon, s->file); + migrate_fd_cleanup(s); + + return ret; +} + void migrate_fd_put_ready(void *opaque) { FdMigrationState *s = opaque; diff --git a/migration.h b/migration.h index ddc1d42..41ee3fe 100644 --- a/migration.h +++ b/migration.h @@ -133,6 +133,8 @@ void migrate_fd_wait_for_unfreeze(void *opaque); int migrate_fd_close(void *opaque); +int ft_tranx_ready(void *opaque); + static inline FdMigrationState *migrate_to_fms(MigrationState *mig_state) { return container_of(mig_state, FdMigrationState, mig_state); diff --git a/qemu-common.h b/qemu-common.h index 0af30d2..5753af2 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -294,4 +294,23 @@ static inline uint8_t from_bcd(uint8_t val) #endif /* dyngen-exec.h hack */ +#ifdef CONFIG_FT_MODE +enum EVENT_TAP_STATE { + EVENT_TAP_OFF, + EVENT_TAP_ON, + EVENT_TAP_SUSPEND, +}; +void event_tap_on(void); +void event_tap_off(void); +void event_tap_suspend(void); +void event_tap_resume(void); +void do_event_tap(void); +#else +#define event_tap_on() do { } while (0) +#define event_tap_off() do { } while (0) +#define event_tap_suspend() do { } while (0) +#define event_tap_resume() do { } while (0) +#define do_event_tap() do { } while (0) +#endif + #endif