From patchwork Sun Aug 21 20:58:52 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: 9292719 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 BCC1C607FF for ; Sun, 21 Aug 2016 21:07:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA81328988 for ; Sun, 21 Aug 2016 21:07:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F3222898A; Sun, 21 Aug 2016 21:07:21 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 26B2F28988 for ; Sun, 21 Aug 2016 21:07:20 +0000 (UTC) Received: from localhost ([::1]:38212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bbZxf-0005Ij-Pf for patchwork-qemu-devel@patchwork.kernel.org; Sun, 21 Aug 2016 17:07:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bbZq9-0007cG-Ai for qemu-devel@nongnu.org; Sun, 21 Aug 2016 16:59:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bbZpz-000604-Ao for qemu-devel@nongnu.org; Sun, 21 Aug 2016 16:59:32 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:35986) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bbZpz-0005zv-0V for qemu-devel@nongnu.org; Sun, 21 Aug 2016 16:59:23 -0400 Received: by mail-pf0-x242.google.com with SMTP id y134so5013400pfg.3 for ; Sun, 21 Aug 2016 13:59:22 -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:in-reply-to:references; bh=LzujdhpNQVHPszLFM1snUUpkkn7YjMzhXbT1WF3HBh4=; b=UDxiFh8jtyEXSpVs2kqg24Vg1WEXPNB+YQ1l9Qv6VzDWzjFtYGpdKaGsT9H+55wK2N S6MykH3caiAw0y3XcrgSBSly6L4GHGQDeJEhSRjK2j41UC+t9TK9fRCjpkAHDJJpXHLB oBRW2+vG0L+eskMmA3dRqJyw4Sd8dRr3LMCpWS0fgKcNoIbuTZxy8OKBwjdUpHWGlY8M X9ij0Ra6tyMnUA0ois852lBSQgZv72HEujpBOTO5qQmBhurUObyk9IOkuoRKL/Ud6FUj HULHUXuGVopPNa53zWXakoOB5krfvJGr8Pw2aFkMoYi1J/rZ3QvXSuc3/Id1cwzzblpg aTMQ== 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:in-reply-to :references; bh=LzujdhpNQVHPszLFM1snUUpkkn7YjMzhXbT1WF3HBh4=; b=PPjM+RdphX/Ij+KsExWvjAUPbb17ZUIxd1PbmXbMxHtuEDZQkZkKIaQb/84Fch6A9E FuZ02jDlHKnZ1hLQC6zIuReq6FUpfUU3FVLO2vttUtz86QMgyvXxJo9QphfAP+rfQSc1 Jo6FNVuj8BZ5PXvUOXtDJ/+Z3yAloUCBwg87nxHVxdL9Qo9/7aYOAignhx7jArbl5JPi Bsvpyrnjz/h2vDOctkQ7WxY4Qz7z2x5HWD4Cx1Jkse1E0J9+Yzf9uAOvEP6D1UEXK3hM bBBcTVJbc9FSm+CaqSJsFFNFWECsAcpFngvEFjDYayG6tFpaVKAZsljzLg5aGc94FE8G 3d5Q== X-Gm-Message-State: AEkoouvDnINFC9+4kXTLtRDCfs1qvoaduv2qfjzkPmnOnZ6S8M8qhTasNYiksobxjQ6eXQ== X-Received: by 10.98.207.6 with SMTP id b6mr36104325pfg.25.1471813162047; Sun, 21 Aug 2016 13:59:22 -0700 (PDT) Received: from deepak.domain.name ([103.252.25.179]) by smtp.googlemail.com with ESMTPSA id ra13sm27025890pac.29.2016.08.21.13.59.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 21 Aug 2016 13:59:21 -0700 (PDT) From: Md Haris Iqbal To: qemu-devel@nongnu.org Date: Mon, 22 Aug 2016 02:28:52 +0530 Message-Id: <1471813132-13836-7-git-send-email-haris.phnx@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1471813132-13836-1-git-send-email-haris.phnx@gmail.com> References: <1471813132-13836-1-git-send-email-haris.phnx@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH 6/6] Migration: Recovering pages lost due to n/w failure during pc migration (destination) 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: Md Haris Iqbal , 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 Signed-off-by: Md Haris Iqbal --- include/migration/migration.h | 1 + include/sysemu/sysemu.h | 1 + migration/ram.c | 35 +++++++++++++++++++++++++++++++++++ migration/savevm.c | 12 ++++++++++++ 4 files changed, 49 insertions(+) diff --git a/include/migration/migration.h b/include/migration/migration.h index 5533832..cda5ece 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -366,6 +366,7 @@ int qemu_migrate_postcopy_incoming_recovery(QEMUFile **f,MigrationIncomingState* void migrate_incoming_ram_bitmap_init(void); void migrate_incoming_ram_bitmap_update(RAMBlock *rb, ram_addr_t addr); void migrate_incoming_ram_bitmap_free(void); +void *migrate_incoming_ram_req_pages(void *opaque); PostcopyState postcopy_state_get(void); /* Set the state and return the old state */ diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index ee7c760..af5630c 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -100,6 +100,7 @@ enum qemu_vm_cmd { were previously sent during precopy but are dirty. */ MIG_CMD_PACKAGED, /* Send a wrapped stream within this stream */ + MIG_CMD_POSTCOPY_RECOVERY, /* Send pages lost due to n/w failure */ MIG_CMD_MAX }; diff --git a/migration/ram.c b/migration/ram.c index ea1382b..28381b6 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2649,6 +2649,41 @@ void migrate_incoming_ram_bitmap_free(void) } } +void *migrate_incoming_ram_req_pages(void* opaque) +{ + MigrationIncomingState *mis = opaque; + struct RAMBlock *rb; + size_t hostpagesize = getpagesize(); + uint64_t addr; + unsigned long base; + unsigned long nr; + unsigned long rb_end; + unsigned long next; + unsigned long *not_received; + + not_received = atomic_rcu_read(&migration_bitmap_rcu)->not_received; + QLIST_FOREACH_RCU(rb, &ram_list.blocks, next) { + addr = 0; + base = rb->offset >> TARGET_PAGE_BITS; + rb_end = base + (rb->used_length >> TARGET_PAGE_BITS); + while (true) { + nr = base + (addr >> TARGET_PAGE_BITS); + next = find_next_bit(not_received, rb_end, nr); + addr = (next - base) << TARGET_PAGE_BITS; + + if (addr >= rb->used_length) { + break; + } + else { + migrate_send_rp_req_pages(mis, qemu_ram_get_idstr(rb), + addr, hostpagesize); + addr++; + } + } + } + return NULL; +} + static SaveVMHandlers savevm_ram_handlers = { .save_live_setup = ram_save_setup, .save_live_iterate = ram_save_iterate, diff --git a/migration/savevm.c b/migration/savevm.c index aa4f777..2301b74 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1621,6 +1621,7 @@ static int loadvm_process_command(QEMUFile *f) uint16_t cmd; uint16_t len; uint32_t tmp32; + QemuThread req_pages_not_received; cmd = qemu_get_be16(f); len = qemu_get_be16(f); @@ -1677,6 +1678,17 @@ static int loadvm_process_command(QEMUFile *f) case MIG_CMD_POSTCOPY_RAM_DISCARD: return loadvm_postcopy_ram_handle_discard(mis, len); + + case MIG_CMD_POSTCOPY_RECOVERY: + /* + * This case will only be used when migration recovers from a + * network failure during a postcopy migration. + * Now, send the requests for pages that were lost due to the + * network failure. + */ + qemu_thread_create(&req_pages_not_received, "pc/recovery", + migrate_incoming_ram_req_pages, mis, QEMU_THREAD_DETACHED); + break; } return 0;