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: 93808 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3L62Lmd005310 for ; Wed, 21 Apr 2010 06:02:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752206Ab0DUGCH (ORCPT ); Wed, 21 Apr 2010 02:02:07 -0400 Received: from sh.osrg.net ([192.16.179.4]:58779 "EHLO sh.osrg.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751955Ab0DUGCB (ORCPT ); Wed, 21 Apr 2010 02:02:01 -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 Cc: avi@redhat.com, aliguori@us.ibm.com, mtosatti@redhat.com, ohmura.kei@lab.ntt.co.jp, yoshikawa.takuya@oss.ntt.co.jp, Yoshiaki Tamura Subject: [RFC PATCH 16/20] Introduce event_tap fucntions and ft_tranx_ready(). 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: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 21 Apr 2010 06:02:26 +0000 (UTC) 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 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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