qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>,
	qemu-devel@nongnu.org, quintela@redhat.com
Subject: [Qemu-devel] [PATCH 2/8] Switch ram_save to the memory API
Date: Wed, 21 Dec 2011 15:34:31 +0200	[thread overview]
Message-ID: <1324474477-22267-3-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1324474477-22267-1-git-send-email-avi@redhat.com>

Avoid using ram_addr_t, instead use (MemoryRegion *, offset) pairs.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch_init.c |   34 ++++++++++++++--------------------
 1 files changed, 14 insertions(+), 20 deletions(-)

diff --git a/arch_init.c b/arch_init.c
index ceef26e..2743bfd 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -117,24 +117,22 @@ static int ram_save_block(QEMUFile *f)
 {
     RAMBlock *block = last_block;
     ram_addr_t offset = last_offset;
-    ram_addr_t current_addr;
     int bytes_sent = 0;
+    MemoryRegion *mr;
 
     if (!block)
         block = QLIST_FIRST(&ram_list.blocks);
 
-    current_addr = block->offset + offset;
-
     do {
-        if (cpu_physical_memory_get_dirty(current_addr, MIGRATION_DIRTY_FLAG)) {
+        mr = block->mr;
+        if (memory_region_get_dirty(mr, offset, DIRTY_MEMORY_MIGRATION)) {
             uint8_t *p;
             int cont = (block == last_block) ? RAM_SAVE_FLAG_CONTINUE : 0;
 
-            cpu_physical_memory_reset_dirty(current_addr,
-                                            current_addr + TARGET_PAGE_SIZE,
-                                            MIGRATION_DIRTY_FLAG);
+            memory_region_reset_dirty(mr, offset, TARGET_PAGE_SIZE,
+                                      DIRTY_MEMORY_MIGRATION);
 
-            p = block->host + offset;
+            p = memory_region_get_ram_ptr(mr) + offset;
 
             if (is_dup_page(p, *p)) {
                 qemu_put_be64(f, offset | cont | RAM_SAVE_FLAG_COMPRESS);
@@ -166,10 +164,7 @@ static int ram_save_block(QEMUFile *f)
             if (!block)
                 block = QLIST_FIRST(&ram_list.blocks);
         }
-
-        current_addr = block->offset + offset;
-
-    } while (current_addr != last_block->offset + last_offset);
+    } while (block != last_block || offset != last_offset);
 
     last_block = block;
     last_offset = offset;
@@ -186,9 +181,9 @@ static ram_addr_t ram_save_remaining(void)
 
     QLIST_FOREACH(block, &ram_list.blocks, next) {
         ram_addr_t addr;
-        for (addr = block->offset; addr < block->offset + block->length;
-             addr += TARGET_PAGE_SIZE) {
-            if (cpu_physical_memory_get_dirty(addr, MIGRATION_DIRTY_FLAG)) {
+        for (addr = 0; addr < block->length; addr += TARGET_PAGE_SIZE) {
+            if (memory_region_get_dirty(block->mr, addr,
+                                        DIRTY_MEMORY_MIGRATION)) {
                 count++;
             }
         }
@@ -275,11 +270,10 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
 
         /* Make sure all dirty bits are set */
         QLIST_FOREACH(block, &ram_list.blocks, next) {
-            for (addr = block->offset; addr < block->offset + block->length;
-                 addr += TARGET_PAGE_SIZE) {
-                if (!cpu_physical_memory_get_dirty(addr,
-                                                   MIGRATION_DIRTY_FLAG)) {
-                    cpu_physical_memory_set_dirty(addr);
+            for (addr = 0; addr < block->length; addr += TARGET_PAGE_SIZE) {
+                if (!memory_region_get_dirty(block->mr, addr,
+                                             DIRTY_MEMORY_MIGRATION)) {
+                    memory_region_set_dirty(block->mr, addr);
                 }
             }
         }
-- 
1.7.7.1

  parent reply	other threads:[~2011-12-21 13:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-21 13:34 [Qemu-devel] [PATCH 0/8] Convert live migration to memory API Avi Kivity
2011-12-21 13:34 ` [Qemu-devel] [PATCH 1/8] Store MemoryRegion in RAMBlock Avi Kivity
2011-12-21 13:34 ` Avi Kivity [this message]
2011-12-21 13:34 ` [Qemu-devel] [PATCH 3/8] Sort RAMBlocks by ID for migration, not by ram_addr Avi Kivity
2011-12-21 13:55   ` Anthony Liguori
2011-12-21 15:15     ` Avi Kivity
2011-12-21 13:34 ` [Qemu-devel] [PATCH 4/8] Remove support for version 3 ram_load Avi Kivity
2011-12-21 13:57   ` Anthony Liguori
2011-12-21 15:18     ` Avi Kivity
2011-12-21 13:34 ` [Qemu-devel] [PATCH 5/8] Convert ram_load() to the memory API Avi Kivity
2011-12-21 13:34 ` [Qemu-devel] [PATCH 6/8] memory: obsolete cpu_physical_memory_[gs]et_dirty_tracking() Avi Kivity
2011-12-21 13:34 ` [Qemu-devel] [PATCH 7/8] xen: convert framebuffer dirty tracking to memory API Avi Kivity
2011-12-21 13:34 ` [Qemu-devel] [PATCH 8/8] memory: obsolete more dirty memory related functions Avi Kivity
2011-12-21 13:59 ` [Qemu-devel] [PATCH 0/8] Convert live migration to memory API Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1324474477-22267-3-git-send-email-avi@redhat.com \
    --to=avi@redhat.com \
    --cc=anthony@codemonkey.ws \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).