From patchwork Tue Mar 13 08:33:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Junyan" X-Patchwork-Id: 886231 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=intel.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4028g94x2Bz9sT0 for ; Fri, 16 Mar 2018 00:33:24 +1100 (AEDT) Received: from localhost ([::1]:51595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ewT0S-0001u2-Vt for incoming@patchwork.ozlabs.org; Thu, 15 Mar 2018 09:33:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49771) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ewSzy-0001tY-6L for qemu-devel@nongnu.org; Thu, 15 Mar 2018 09:32:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ewSzu-0000tE-7n for qemu-devel@nongnu.org; Thu, 15 Mar 2018 09:32:50 -0400 Received: from [112.64.68.174] (port=39094 helo=robinhe-hp.sh.intel.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ewSzt-0000r1-NH for qemu-devel@nongnu.org; Thu, 15 Mar 2018 09:32:46 -0400 Received: from robinhe-hp.sh.intel.com (localhost [127.0.0.1]) by robinhe-hp (8.15.2/8.15.2/Debian-3) with ESMTP id w2D8Y0UG018980; Tue, 13 Mar 2018 16:34:00 +0800 Received: (from robinhe@localhost) by robinhe-hp.sh.intel.com (8.15.2/8.15.2/Submit) id w2D8Y0rO018979; Tue, 13 Mar 2018 16:34:00 +0800 From: junyan.he@intel.com To: qemu-devel@nongnu.org Date: Tue, 13 Mar 2018 16:33:53 +0800 Message-Id: <1520930033-18885-11-git-send-email-junyan.he@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520930033-18885-1-git-send-email-junyan.he@intel.com> References: <1520930033-18885-1-git-send-email-junyan.he@intel.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 112.64.68.174 Subject: [Qemu-devel] [PATCH 10/10] RFC: Enable nvdimm snapshot functions. 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: kwolf@redhat.com, famz@redhat.com, crosthwaite.peter@gmail.com, quintela@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, Junyan He , pbonzini@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Junyan He In snapshot saving, all nvdimm kind memory will be saved in different way and we exclude all nvdimm kind memory region in ram.c Signed-off-by: Junyan He --- migration/ram.c | 17 +++++++++++++++++ vl.c | 1 + 2 files changed, 18 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index d1db422..ad32469 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1219,9 +1219,15 @@ static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, bool *again) /* Didn't find anything in this RAM Block */ pss->page = 0; pss->block = QLIST_NEXT_RCU(pss->block, next); + while (ram_block_is_nvdimm_active(pss->block)) { + pss->block = QLIST_NEXT_RCU(pss->block, next); + } if (!pss->block) { /* Hit the end of the list */ pss->block = QLIST_FIRST_RCU(&ram_list.blocks); + while (ram_block_is_nvdimm_active(pss->block)) { + pss->block = QLIST_NEXT_RCU(pss->block, next); + } /* Flag that we've looped */ pss->complete_round = true; rs->ram_bulk_stage = false; @@ -1541,6 +1547,9 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage) if (!pss.block) { pss.block = QLIST_FIRST_RCU(&ram_list.blocks); + while (ram_block_is_nvdimm_active(pss.block)) { + pss.block = QLIST_NEXT_RCU(pss.block, next); + } } do { @@ -1583,6 +1592,10 @@ uint64_t ram_bytes_total(void) rcu_read_lock(); RAMBLOCK_FOREACH(block) { + if (ram_block_is_nvdimm_active(block)) { + // If snapshot and the block is nvdimm, let nvdimm do the job + continue; + } total += block->used_length; } rcu_read_unlock(); @@ -2222,6 +2235,10 @@ static int ram_save_setup(QEMUFile *f, void *opaque) qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE); RAMBLOCK_FOREACH(block) { + if (ram_block_is_nvdimm_active(block)) { + // If snapshot and the block is nvdimm, let nvdimm do the job + continue; + } qemu_put_byte(f, strlen(block->idstr)); qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr)); qemu_put_be64(f, block->used_length); diff --git a/vl.c b/vl.c index 3ef04ce..1bd5711 100644 --- a/vl.c +++ b/vl.c @@ -4502,6 +4502,7 @@ int main(int argc, char **argv, char **envp) blk_mig_init(); ram_mig_init(); + nvdimm_snapshot_init(); /* If the currently selected machine wishes to override the units-per-bus * property of its default HBA interface type, do so now. */