qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/8] Convert live migration to memory API
@ 2011-12-21 13:34 Avi Kivity
  2011-12-21 13:34 ` [Qemu-devel] [PATCH 1/8] Store MemoryRegion in RAMBlock Avi Kivity
                   ` (8 more replies)
  0 siblings, 9 replies; 14+ messages in thread
From: Avi Kivity @ 2011-12-21 13:34 UTC (permalink / raw)
  To: Anthony Liguori, qemu-devel, quintela

These patches, on top of "vmstate, memory: decouple vmstate from memory API",
convert live migration to use the memory API.

Patch 4 is an ABI change, please review carefully.

Avi Kivity (8):
  Store MemoryRegion in RAMBlock
  Switch ram_save to the memory API
  Sort RAMBlocks by ID for migration, not by ram_addr
  Remove support for version 3 ram_load
  Convert ram_load() to the memory API
  memory: obsolete cpu_physical_memory_[gs]et_dirty_tracking()
  xen: convert framebuffer dirty tracking to memory API
  memory: obsolete more dirty memory related functions

 arch_init.c     |   71 +++++++++++++++++++-----------------------------------
 cpu-all.h       |   54 +-----------------------------------------
 exec-obsolete.h |   51 +++++++++++++++++++++++++++++++++++++++
 exec.c          |   11 +-------
 memory.c        |    2 +
 xen-all.c       |    5 +--
 6 files changed, 82 insertions(+), 112 deletions(-)

-- 
1.7.7.1

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH 1/8] Store MemoryRegion in RAMBlock
  2011-12-21 13:34 [Qemu-devel] [PATCH 0/8] Convert live migration to memory API Avi Kivity
@ 2011-12-21 13:34 ` Avi Kivity
  2011-12-21 13:34 ` [Qemu-devel] [PATCH 2/8] Switch ram_save to the memory API Avi Kivity
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Avi Kivity @ 2011-12-21 13:34 UTC (permalink / raw)
  To: Anthony Liguori, qemu-devel, quintela

As a step in moving live migration from RAMBlocks to MemoryRegions,
store the MemoryRegion in a RAMBlock.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 cpu-all.h |    1 +
 exec.c    |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/cpu-all.h b/cpu-all.h
index 734833a..4acaa8b 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -476,6 +476,7 @@ extern ram_addr_t ram_size;
 #define RAM_PREALLOC_MASK   (1 << 0)
 
 typedef struct RAMBlock {
+    struct MemoryRegion *mr;
     uint8_t *host;
     ram_addr_t offset;
     ram_addr_t length;
diff --git a/exec.c b/exec.c
index dffceb9..a4116d9 100644
--- a/exec.c
+++ b/exec.c
@@ -2793,6 +2793,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
     size = TARGET_PAGE_ALIGN(size);
     new_block = g_malloc0(sizeof(*new_block));
 
+    new_block->mr = mr;
     new_block->offset = find_ram_offset(size);
     if (host) {
         new_block->host = host;
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH 2/8] Switch ram_save to the memory API
  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
  2011-12-21 13:34 ` [Qemu-devel] [PATCH 3/8] Sort RAMBlocks by ID for migration, not by ram_addr Avi Kivity
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Avi Kivity @ 2011-12-21 13:34 UTC (permalink / raw)
  To: Anthony Liguori, qemu-devel, quintela

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH 3/8] Sort RAMBlocks by ID for migration, not by ram_addr
  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 ` [Qemu-devel] [PATCH 2/8] Switch ram_save to the memory API Avi Kivity
@ 2011-12-21 13:34 ` Avi Kivity
  2011-12-21 13:55   ` Anthony Liguori
  2011-12-21 13:34 ` [Qemu-devel] [PATCH 4/8] Remove support for version 3 ram_load Avi Kivity
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Avi Kivity @ 2011-12-21 13:34 UTC (permalink / raw)
  To: Anthony Liguori, qemu-devel, quintela

ram_addr is (a) unstable (b) going away.  Sort by idstr instead.

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

diff --git a/arch_init.c b/arch_init.c
index 2743bfd..8a3f052 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -217,12 +217,8 @@ static int block_compar(const void *a, const void *b)
 {
     RAMBlock * const *ablock = a;
     RAMBlock * const *bblock = b;
-    if ((*ablock)->offset < (*bblock)->offset) {
-        return -1;
-    } else if ((*ablock)->offset > (*bblock)->offset) {
-        return 1;
-    }
-    return 0;
+
+    return strcmp((*ablock)->idstr, (*bblock)->idstr);
 }
 
 static void sort_ram_list(void)
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH 4/8] Remove support for version 3 ram_load
  2011-12-21 13:34 [Qemu-devel] [PATCH 0/8] Convert live migration to memory API Avi Kivity
                   ` (2 preceding siblings ...)
  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:34 ` Avi Kivity
  2011-12-21 13:57   ` Anthony Liguori
  2011-12-21 13:34 ` [Qemu-devel] [PATCH 5/8] Convert ram_load() to the memory API Avi Kivity
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Avi Kivity @ 2011-12-21 13:34 UTC (permalink / raw)
  To: Anthony Liguori, qemu-devel, quintela

Version 3 ram_load depends on ram_addrs, which are not stable.  Version 4
was introduced in 0.13 (and RHEL 6), so this means live migration from 0.12
and earlier to 1.1 or later will not work.

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

diff --git a/arch_init.c b/arch_init.c
index 8a3f052..9b8a1f3 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -366,7 +366,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)
     int flags;
     int error;
 
-    if (version_id < 3 || version_id > 4) {
+    if (version_id < 4 || version_id > 4) {
         return -EINVAL;
     }
 
@@ -377,11 +377,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)
         addr &= TARGET_PAGE_MASK;
 
         if (flags & RAM_SAVE_FLAG_MEM_SIZE) {
-            if (version_id == 3) {
-                if (addr != ram_bytes_total()) {
-                    return -EINVAL;
-                }
-            } else {
+            if (version_id == 4) {
                 /* Synchronize RAM block list */
                 char id[256];
                 ram_addr_t length;
@@ -419,10 +415,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)
             void *host;
             uint8_t ch;
 
-            if (version_id == 3)
-                host = qemu_get_ram_ptr(addr);
-            else
-                host = host_from_stream_offset(f, addr, flags);
+            host = host_from_stream_offset(f, addr, flags);
             if (!host) {
                 return -EINVAL;
             }
@@ -438,10 +431,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)
         } else if (flags & RAM_SAVE_FLAG_PAGE) {
             void *host;
 
-            if (version_id == 3)
-                host = qemu_get_ram_ptr(addr);
-            else
-                host = host_from_stream_offset(f, addr, flags);
+            host = host_from_stream_offset(f, addr, flags);
 
             qemu_get_buffer(f, host, TARGET_PAGE_SIZE);
         }
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH 5/8] Convert ram_load() to the memory API
  2011-12-21 13:34 [Qemu-devel] [PATCH 0/8] Convert live migration to memory API Avi Kivity
                   ` (3 preceding siblings ...)
  2011-12-21 13:34 ` [Qemu-devel] [PATCH 4/8] Remove support for version 3 ram_load Avi Kivity
@ 2011-12-21 13:34 ` Avi Kivity
  2011-12-21 13:34 ` [Qemu-devel] [PATCH 6/8] memory: obsolete cpu_physical_memory_[gs]et_dirty_tracking() Avi Kivity
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Avi Kivity @ 2011-12-21 13:34 UTC (permalink / raw)
  To: Anthony Liguori, qemu-devel, quintela

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

diff --git a/arch_init.c b/arch_init.c
index 9b8a1f3..381c055 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -344,7 +344,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
             return NULL;
         }
 
-        return block->host + offset;
+        return memory_region_get_ram_ptr(block->mr) + offset;
     }
 
     len = qemu_get_byte(f);
@@ -353,7 +353,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
 
     QLIST_FOREACH(block, &ram_list.blocks, next) {
         if (!strncmp(id, block->idstr, sizeof(id)))
-            return block->host + offset;
+            return memory_region_get_ram_ptr(block->mr) + offset;
     }
 
     fprintf(stderr, "Can't find block %s!\n", id);
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH 6/8] memory: obsolete cpu_physical_memory_[gs]et_dirty_tracking()
  2011-12-21 13:34 [Qemu-devel] [PATCH 0/8] Convert live migration to memory API Avi Kivity
                   ` (4 preceding siblings ...)
  2011-12-21 13:34 ` [Qemu-devel] [PATCH 5/8] Convert ram_load() to the memory API Avi Kivity
@ 2011-12-21 13:34 ` Avi Kivity
  2011-12-21 13:34 ` [Qemu-devel] [PATCH 7/8] xen: convert framebuffer dirty tracking to memory API Avi Kivity
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Avi Kivity @ 2011-12-21 13:34 UTC (permalink / raw)
  To: Anthony Liguori, qemu-devel, quintela

The getter is no longer used, so it is completely removed.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch_init.c     |    7 +++----
 cpu-all.h       |    4 ----
 exec-obsolete.h |    2 ++
 exec.c          |   10 ----------
 memory.c        |    2 ++
 5 files changed, 7 insertions(+), 18 deletions(-)

diff --git a/arch_init.c b/arch_init.c
index 381c055..d3adacf 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -251,7 +251,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
     int ret;
 
     if (stage < 0) {
-        cpu_physical_memory_set_dirty_tracking(0);
+        memory_global_dirty_log_stop();
         return 0;
     }
 
@@ -274,8 +274,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
             }
         }
 
-        /* Enable dirty memory tracking */
-        cpu_physical_memory_set_dirty_tracking(1);
+        memory_global_dirty_log_start();
 
         qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE);
 
@@ -320,7 +319,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)
         while ((bytes_sent = ram_save_block(f)) != 0) {
             bytes_transferred += bytes_sent;
         }
-        cpu_physical_memory_set_dirty_tracking(0);
+        memory_global_dirty_log_stop();
     }
 
     qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
diff --git a/cpu-all.h b/cpu-all.h
index 4acaa8b..2fdb856 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -566,10 +566,6 @@ void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
                                      int dirty_flags);
 void cpu_tlb_update_dirty(CPUState *env);
 
-int cpu_physical_memory_set_dirty_tracking(int enable);
-
-int cpu_physical_memory_get_dirty_tracking(void);
-
 void dump_exec_info(FILE *f, fprintf_function cpu_fprintf);
 #endif /* !CONFIG_USER_ONLY */
 
diff --git a/exec-obsolete.h b/exec-obsolete.h
index 3a2faae..880105e 100644
--- a/exec-obsolete.h
+++ b/exec-obsolete.h
@@ -61,6 +61,8 @@ static inline void cpu_register_physical_memory(target_phys_addr_t start_addr,
 void qemu_register_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size);
 void qemu_unregister_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size);
 
+int cpu_physical_memory_set_dirty_tracking(int enable);
+
 #endif
 
 #endif
diff --git a/exec.c b/exec.c
index a4116d9..28c057c 100644
--- a/exec.c
+++ b/exec.c
@@ -2008,19 +2008,9 @@ int cpu_physical_memory_set_dirty_tracking(int enable)
 {
     int ret = 0;
     in_migration = enable;
-    if (enable) {
-        memory_global_dirty_log_start();
-    } else {
-        memory_global_dirty_log_stop();
-    }
     return ret;
 }
 
-int cpu_physical_memory_get_dirty_tracking(void)
-{
-    return in_migration;
-}
-
 static inline void tlb_update_dirty(CPUTLBEntry *tlb_entry)
 {
     ram_addr_t ram_addr;
diff --git a/memory.c b/memory.c
index f7b3d50..868ffd0 100644
--- a/memory.c
+++ b/memory.c
@@ -1493,6 +1493,7 @@ void memory_global_dirty_log_start(void)
 {
     MemoryListener *listener;
 
+    cpu_physical_memory_set_dirty_tracking(1);
     global_dirty_log = true;
     QLIST_FOREACH(listener, &memory_listeners, link) {
         listener->log_global_start(listener);
@@ -1507,6 +1508,7 @@ void memory_global_dirty_log_stop(void)
     QLIST_FOREACH(listener, &memory_listeners, link) {
         listener->log_global_stop(listener);
     }
+    cpu_physical_memory_set_dirty_tracking(0);
 }
 
 static void listener_add_address_space(MemoryListener *listener,
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH 7/8] xen: convert framebuffer dirty tracking to memory API
  2011-12-21 13:34 [Qemu-devel] [PATCH 0/8] Convert live migration to memory API Avi Kivity
                   ` (5 preceding siblings ...)
  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 ` 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
  8 siblings, 0 replies; 14+ messages in thread
From: Avi Kivity @ 2011-12-21 13:34 UTC (permalink / raw)
  To: Anthony Liguori, qemu-devel, quintela

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 xen-all.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/xen-all.c b/xen-all.c
index df70592..8f9db95 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -408,7 +408,6 @@ static int xen_sync_dirty_bitmap(XenIOState *state,
                                  ram_addr_t size)
 {
     target_phys_addr_t npages = size >> TARGET_PAGE_BITS;
-    target_phys_addr_t vram_offset = 0;
     const int width = sizeof(unsigned long) * 8;
     unsigned long bitmap[(npages + width - 1) / width];
     int rc, i, j;
@@ -425,7 +424,6 @@ static int xen_sync_dirty_bitmap(XenIOState *state,
     } else if (state->log_for_dirtybit != physmap) {
         return -1;
     }
-    vram_offset = physmap->phys_offset;
 
     rc = xc_hvm_track_dirty_vram(xen_xc, xen_domid,
                                  start_addr >> TARGET_PAGE_BITS, npages,
@@ -439,7 +437,8 @@ static int xen_sync_dirty_bitmap(XenIOState *state,
         while (map != 0) {
             j = ffsl(map) - 1;
             map &= ~(1ul << j);
-            cpu_physical_memory_set_dirty(vram_offset + (i * width + j) * TARGET_PAGE_SIZE);
+            memory_region_set_dirty(framebuffer,
+                                    (i * width + j) * TARGET_PAGE_SIZE);
         };
     }
 
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Qemu-devel] [PATCH 8/8] memory: obsolete more dirty memory related functions
  2011-12-21 13:34 [Qemu-devel] [PATCH 0/8] Convert live migration to memory API Avi Kivity
                   ` (6 preceding siblings ...)
  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 ` Avi Kivity
  2011-12-21 13:59 ` [Qemu-devel] [PATCH 0/8] Convert live migration to memory API Anthony Liguori
  8 siblings, 0 replies; 14+ messages in thread
From: Avi Kivity @ 2011-12-21 13:34 UTC (permalink / raw)
  To: Anthony Liguori, qemu-devel, quintela

No longer used outside memory.c and exec.c.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 cpu-all.h       |   49 -------------------------------------------------
 exec-obsolete.h |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/cpu-all.h b/cpu-all.h
index 2fdb856..31d5b27 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -515,55 +515,6 @@ extern int mem_prealloc;
 /* Set if TLB entry is an IO callback.  */
 #define TLB_MMIO        (1 << 5)
 
-#define VGA_DIRTY_FLAG       0x01
-#define CODE_DIRTY_FLAG      0x02
-#define MIGRATION_DIRTY_FLAG 0x08
-
-/* read dirty bit (return 0 or 1) */
-static inline int cpu_physical_memory_is_dirty(ram_addr_t addr)
-{
-    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] == 0xff;
-}
-
-static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr)
-{
-    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS];
-}
-
-static inline int cpu_physical_memory_get_dirty(ram_addr_t addr,
-                                                int dirty_flags)
-{
-    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] & dirty_flags;
-}
-
-static inline void cpu_physical_memory_set_dirty(ram_addr_t addr)
-{
-    ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] = 0xff;
-}
-
-static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr,
-                                                      int dirty_flags)
-{
-    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags;
-}
-
-static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start,
-                                                        int length,
-                                                        int dirty_flags)
-{
-    int i, mask, len;
-    uint8_t *p;
-
-    len = length >> TARGET_PAGE_BITS;
-    mask = ~dirty_flags;
-    p = ram_list.phys_dirty + (start >> TARGET_PAGE_BITS);
-    for (i = 0; i < len; i++) {
-        p[i] &= mask;
-    }
-}
-
-void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
-                                     int dirty_flags);
 void cpu_tlb_update_dirty(CPUState *env);
 
 void dump_exec_info(FILE *f, fprintf_function cpu_fprintf);
diff --git a/exec-obsolete.h b/exec-obsolete.h
index 880105e..698d7fc 100644
--- a/exec-obsolete.h
+++ b/exec-obsolete.h
@@ -63,6 +63,55 @@ void qemu_unregister_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size);
 
 int cpu_physical_memory_set_dirty_tracking(int enable);
 
+#define VGA_DIRTY_FLAG       0x01
+#define CODE_DIRTY_FLAG      0x02
+#define MIGRATION_DIRTY_FLAG 0x08
+
+/* read dirty bit (return 0 or 1) */
+static inline int cpu_physical_memory_is_dirty(ram_addr_t addr)
+{
+    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] == 0xff;
+}
+
+static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr)
+{
+    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS];
+}
+
+static inline int cpu_physical_memory_get_dirty(ram_addr_t addr,
+                                                int dirty_flags)
+{
+    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] & dirty_flags;
+}
+
+static inline void cpu_physical_memory_set_dirty(ram_addr_t addr)
+{
+    ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] = 0xff;
+}
+
+static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr,
+                                                      int dirty_flags)
+{
+    return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags;
+}
+
+static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start,
+                                                        int length,
+                                                        int dirty_flags)
+{
+    int i, mask, len;
+    uint8_t *p;
+
+    len = length >> TARGET_PAGE_BITS;
+    mask = ~dirty_flags;
+    p = ram_list.phys_dirty + (start >> TARGET_PAGE_BITS);
+    for (i = 0; i < len; i++) {
+        p[i] &= mask;
+    }
+}
+
+void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
+                                     int dirty_flags);
 #endif
 
 #endif
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 3/8] Sort RAMBlocks by ID for migration, not by ram_addr
  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
  0 siblings, 1 reply; 14+ messages in thread
From: Anthony Liguori @ 2011-12-21 13:55 UTC (permalink / raw)
  To: Avi Kivity; +Cc: qemu-devel, quintela

On 12/21/2011 07:34 AM, Avi Kivity wrote:
> ram_addr is (a) unstable (b) going away.  Sort by idstr instead.
>
> Signed-off-by: Avi Kivity<avi@redhat.com>

I don't see this as a problem, per say, but this is a significant behavioral 
change.  ram_addr does correspond roughly to the location in memory and 
historically we would send memory starting from 0 upward whereas now, the order 
that we send RAMBlocks will be random for all intents and purposes.

Again, I don't think it's a problem, but we should note this in the commit 
message in case it creates a problem down the road.

Regards,

Anthony Liguori

> ---
>   arch_init.c |    8 ++------
>   1 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/arch_init.c b/arch_init.c
> index 2743bfd..8a3f052 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -217,12 +217,8 @@ static int block_compar(const void *a, const void *b)
>   {
>       RAMBlock * const *ablock = a;
>       RAMBlock * const *bblock = b;
> -    if ((*ablock)->offset<  (*bblock)->offset) {
> -        return -1;
> -    } else if ((*ablock)->offset>  (*bblock)->offset) {
> -        return 1;
> -    }
> -    return 0;
> +
> +    return strcmp((*ablock)->idstr, (*bblock)->idstr);
>   }
>
>   static void sort_ram_list(void)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 4/8] Remove support for version 3 ram_load
  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
  0 siblings, 1 reply; 14+ messages in thread
From: Anthony Liguori @ 2011-12-21 13:57 UTC (permalink / raw)
  To: Avi Kivity; +Cc: qemu-devel, quintela

On 12/21/2011 07:34 AM, Avi Kivity wrote:
> Version 3 ram_load depends on ram_addrs, which are not stable.  Version 4
> was introduced in 0.13 (and RHEL 6), so this means live migration from 0.12
> and earlier to 1.1 or later will not work.

Can you please make a note on http://wiki.qemu.org/ChangeLog/Next

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

>
> Signed-off-by: Avi Kivity<avi@redhat.com>
> ---
>   arch_init.c |   18 ++++--------------
>   1 files changed, 4 insertions(+), 14 deletions(-)
>
> diff --git a/arch_init.c b/arch_init.c
> index 8a3f052..9b8a1f3 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -366,7 +366,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)
>       int flags;
>       int error;
>
> -    if (version_id<  3 || version_id>  4) {
> +    if (version_id<  4 || version_id>  4) {
>           return -EINVAL;
>       }
>
> @@ -377,11 +377,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)
>           addr&= TARGET_PAGE_MASK;
>
>           if (flags&  RAM_SAVE_FLAG_MEM_SIZE) {
> -            if (version_id == 3) {
> -                if (addr != ram_bytes_total()) {
> -                    return -EINVAL;
> -                }
> -            } else {
> +            if (version_id == 4) {
>                   /* Synchronize RAM block list */
>                   char id[256];
>                   ram_addr_t length;
> @@ -419,10 +415,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)
>               void *host;
>               uint8_t ch;
>
> -            if (version_id == 3)
> -                host = qemu_get_ram_ptr(addr);
> -            else
> -                host = host_from_stream_offset(f, addr, flags);
> +            host = host_from_stream_offset(f, addr, flags);
>               if (!host) {
>                   return -EINVAL;
>               }
> @@ -438,10 +431,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)
>           } else if (flags&  RAM_SAVE_FLAG_PAGE) {
>               void *host;
>
> -            if (version_id == 3)
> -                host = qemu_get_ram_ptr(addr);
> -            else
> -                host = host_from_stream_offset(f, addr, flags);
> +            host = host_from_stream_offset(f, addr, flags);
>
>               qemu_get_buffer(f, host, TARGET_PAGE_SIZE);
>           }

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 0/8] Convert live migration to memory API
  2011-12-21 13:34 [Qemu-devel] [PATCH 0/8] Convert live migration to memory API Avi Kivity
                   ` (7 preceding siblings ...)
  2011-12-21 13:34 ` [Qemu-devel] [PATCH 8/8] memory: obsolete more dirty memory related functions Avi Kivity
@ 2011-12-21 13:59 ` Anthony Liguori
  8 siblings, 0 replies; 14+ messages in thread
From: Anthony Liguori @ 2011-12-21 13:59 UTC (permalink / raw)
  To: Avi Kivity; +Cc: qemu-devel, quintela

On 12/21/2011 07:34 AM, Avi Kivity wrote:
> These patches, on top of "vmstate, memory: decouple vmstate from memory API",
> convert live migration to use the memory API.
>
> Patch 4 is an ABI change, please review carefully.

Using ram_addr_t for migration was badly, badly broken.  I think it's been long 
enough that we can safely remove that logic.

Other than my request for a better commit message, this whole series:

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

Regards,

Anthony Liguori

>
> Avi Kivity (8):
>    Store MemoryRegion in RAMBlock
>    Switch ram_save to the memory API
>    Sort RAMBlocks by ID for migration, not by ram_addr
>    Remove support for version 3 ram_load
>    Convert ram_load() to the memory API
>    memory: obsolete cpu_physical_memory_[gs]et_dirty_tracking()
>    xen: convert framebuffer dirty tracking to memory API
>    memory: obsolete more dirty memory related functions
>
>   arch_init.c     |   71 +++++++++++++++++++-----------------------------------
>   cpu-all.h       |   54 +-----------------------------------------
>   exec-obsolete.h |   51 +++++++++++++++++++++++++++++++++++++++
>   exec.c          |   11 +-------
>   memory.c        |    2 +
>   xen-all.c       |    5 +--
>   6 files changed, 82 insertions(+), 112 deletions(-)
>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 3/8] Sort RAMBlocks by ID for migration, not by ram_addr
  2011-12-21 13:55   ` Anthony Liguori
@ 2011-12-21 15:15     ` Avi Kivity
  0 siblings, 0 replies; 14+ messages in thread
From: Avi Kivity @ 2011-12-21 15:15 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel, quintela

On 12/21/2011 03:55 PM, Anthony Liguori wrote:
> On 12/21/2011 07:34 AM, Avi Kivity wrote:
>> ram_addr is (a) unstable (b) going away.  Sort by idstr instead.
>>
>> Signed-off-by: Avi Kivity<avi@redhat.com>
>
> I don't see this as a problem, per say, but this is a significant
> behavioral change.  ram_addr does correspond roughly to the location
> in memory and historically we would send memory starting from 0 upward
> whereas now, the order that we send RAMBlocks will be random for all
> intents and purposes.
>
> Again, I don't think it's a problem, but we should note this in the
> commit message in case it creates a problem down the road.
>

I (and the new commit message) note that the sort order used to be
random a while ago (before b2e0a138e), so this isn't entirely new.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Qemu-devel] [PATCH 4/8] Remove support for version 3 ram_load
  2011-12-21 13:57   ` Anthony Liguori
@ 2011-12-21 15:18     ` Avi Kivity
  0 siblings, 0 replies; 14+ messages in thread
From: Avi Kivity @ 2011-12-21 15:18 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel, quintela

On 12/21/2011 03:57 PM, Anthony Liguori wrote:
> On 12/21/2011 07:34 AM, Avi Kivity wrote:
>> Version 3 ram_load depends on ram_addrs, which are not stable. 
>> Version 4
>> was introduced in 0.13 (and RHEL 6), so this means live migration
>> from 0.12
>> and earlier to 1.1 or later will not work.
>
> Can you please make a note on http://wiki.qemu.org/ChangeLog/Next

Done.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-12-21 15:19 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [Qemu-devel] [PATCH 2/8] Switch ram_save to the memory API Avi Kivity
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

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).