From patchwork Tue May 31 19:13:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Md Haris Iqbal X-Patchwork-Id: 9145531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2BDF860761 for ; Tue, 31 May 2016 19:13:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20B2C1FE7B for ; Tue, 31 May 2016 19:13:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1597D26240; Tue, 31 May 2016 19:13:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.7 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 92CA91FE7B for ; Tue, 31 May 2016 19:13:55 +0000 (UTC) Received: from localhost ([::1]:38035 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7p6v-0003yV-El for patchwork-qemu-devel@patchwork.kernel.org; Tue, 31 May 2016 15:13:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54641) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7p6Y-0003vj-NH for qemu-devel@nongnu.org; Tue, 31 May 2016 15:13:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b7p6U-00021L-FD for qemu-devel@nongnu.org; Tue, 31 May 2016 15:13:29 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:35012) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7p6U-000215-5P for qemu-devel@nongnu.org; Tue, 31 May 2016 15:13:26 -0400 Received: by mail-pf0-x244.google.com with SMTP id f144so19878416pfa.2 for ; Tue, 31 May 2016 12:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=ZansmEBTeCob17pNsdKPZY+acrGXhEq/ALakk0tniHU=; b=EnHQBjrfLXdzlHwns6Qq5B904S0omkm5DlGIVg/KqhmhOMyNEa8p7sQ82rALu7P7Nj w5CpQ+C8efFmTNEa2791+OY2LNGNEU0acqQi56WY/rUpB3cJ7uS2VHX66Ky16qWfWXXJ BF8eTfd/wVnG4G0+zlwDMOv5vi6DJhnO1919H+rZCTINJHn8LEjgsIsxOyHDmWwhatL8 JHj+x3gGRIi5lvZTz7sGxLEV2KNzuDDF2QACU1nUuYMrXzZcQcfNTWjQF0VaQ6DXEYPB VsygwUKAPLTICEXw5IrmXqNhjGbR0HhXdjE3oGkJNmX0Du6kbtrj8EFUJXYCmzZt7FdS BrWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZansmEBTeCob17pNsdKPZY+acrGXhEq/ALakk0tniHU=; b=EF1vhIZCnJVgaEJH6WgCD5HTb1cDv3pHveIz50+I6X7dVqATUbgxAA1MgDcFbQH/Ii XSJKtXoa/FzpSkX8Oa6kaW4RFuqF1RenKl6OTCWYIxecSvgv1pvEDClIm9d2jRhALC1E +I23XNgmTvd3viTlBmx2s/msjDB6Ee8RSg6nIa7qgyRyzk1nnzmWTTSne28eD+xCD72s ZKnaJTWs27XNOXuYta+4ohiy9iysuc4BN85b7m5DOKg6cDriV4XgCekzCTmFKORynsoX yZghGjFTYnOTOntF+UmlB9Z1FWztWTndpVHnkaaex71h+aJRMhHTDrvHHkPuApemQLXT dnhQ== X-Gm-Message-State: ALyK8tLxIcSL8VmUO2zV9U+MUdmy+Vn8euaZhBjZck/QoNE2Jb+vOZS+bRhUfYaYHWYpFw== X-Received: by 10.98.98.6 with SMTP id w6mr59138973pfb.0.1464722005468; Tue, 31 May 2016 12:13:25 -0700 (PDT) Received: from praveen-HP-Compaq-8200-Elite-MT-PC.nitk.ac.in ([14.139.155.210]) by smtp.googlemail.com with ESMTPSA id 17sm42129021pfa.59.2016.05.31.12.13.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 May 2016 12:13:25 -0700 (PDT) From: Md Haris Iqbal To: qemu-devel@nongnu.org Date: Wed, 1 Jun 2016 00:43:13 +0530 Message-Id: <1464721993-15682-1-git-send-email-haris.phnx@gmail.com> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [Qemu-devel [RFC] [WIP] v1] Keeping the Destination side alive incase of network failure (Migration recover from network failure) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dgilbert@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP --- include/migration/migration.h | 3 +++ migration/migration.c | 12 ++++++++++++ migration/savevm.c | 25 +++++++++++++++++-------- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index ac2c12c..73832ac 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -326,6 +326,9 @@ void flush_page_queue(MigrationState *ms); int ram_save_queue_pages(MigrationState *ms, const char *rbname, ram_addr_t start, ram_addr_t len); +// New added function for postcopy migration recovery in case of failure +void qemu_postcopy_migration_recovery(QEMUFile **f,MigrationIncomingState* mis); + PostcopyState postcopy_state_get(void); /* Set the state and return the old state */ PostcopyState postcopy_state_set(PostcopyState new_state); diff --git a/migration/migration.c b/migration/migration.c index 991313a..4301972 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1797,6 +1797,18 @@ void migrate_fd_connect(MigrationState *s) s->migration_thread_running = true; } +void qemu_postcopy_migration_recovery(QEMUFile **f, + MigrationIncomingState* mis) +{ + migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, + MIGRATION_STATUS_POSTCOPY_RECOVERING); + /* Code for network recovery to be added here */ + while(1) { + fprintf(stderr, "Not letting it fail\n"); + sleep(2); + } +} + PostcopyState postcopy_state_get(void) { return atomic_mb_read(&incoming_postcopy_state); diff --git a/migration/savevm.c b/migration/savevm.c index 16ba443..03467da 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1832,7 +1832,8 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis) static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis) { uint8_t section_type; - int ret; + PostcopyState ps; + int32_t ret; while ((section_type = qemu_get_byte(f)) != QEMU_VM_EOF) { @@ -1841,21 +1842,16 @@ static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis) case QEMU_VM_SECTION_START: case QEMU_VM_SECTION_FULL: ret = qemu_loadvm_section_start_full(f, mis); - if (ret < 0) { - return ret; - } break; case QEMU_VM_SECTION_PART: case QEMU_VM_SECTION_END: ret = qemu_loadvm_section_part_end(f, mis); - if (ret < 0) { - return ret; - } break; case QEMU_VM_COMMAND: ret = loadvm_process_command(f); trace_qemu_loadvm_state_section_command(ret); - if ((ret < 0) || (ret & LOADVM_QUIT)) { + if (ret & LOADVM_QUIT) { + fprintf(stderr, "LOADVM_QUIT\n"); return ret; } break; @@ -1863,6 +1859,19 @@ static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis) error_report("Unknown savevm section type %d", section_type); return -EINVAL; } + + if (ret < 0) { + fprintf(stderr, "Failure\n"); + + ps = postcopy_state_get(); + ret = qemu_file_get_error(f); + fprintf(stderr, "Error %s %d\n", strerror(-ret), -ret); + + if(ret != -EIO && ps == POSTCOPY_INCOMING_RUNNING) + qemu_postcopy_migration_recovery(&f, mis); + else + return ret; + } } return 0;